Commit 70ecc5b5 authored by Daniel P. Berrange's avatar Daniel P. Berrange

Add missing binding for storage pool refresh event

Signed-off-by: default avatarDaniel P. Berrange <berrange@redhat.com>
parent 4c5caa0b
......@@ -47,6 +47,8 @@ type StoragePoolEventLifecycle struct {
type StoragePoolEventLifecycleCallback func(c *Connect, n *StoragePool, event *StoragePoolEventLifecycle)
type StoragePoolEventGenericCallback func(c *Connect, n *StoragePool)
//export storagePoolEventLifecycleCallback
func storagePoolEventLifecycleCallback(c C.virConnectPtr, s C.virStoragePoolPtr,
event int, detail int,
......@@ -68,6 +70,21 @@ func storagePoolEventLifecycleCallback(c C.virConnectPtr, s C.virStoragePoolPtr,
callback(connection, storage_pool, eventDetails)
}
//export storagePoolEventGenericCallback
func storagePoolEventGenericCallback(c C.virConnectPtr, s C.virStoragePoolPtr,
goCallbackId int) {
storage_pool := &StoragePool{ptr: s}
connection := &Connect{ptr: c}
callbackFunc := getCallbackId(goCallbackId)
callback, ok := callbackFunc.(StoragePoolEventGenericCallback)
if !ok {
panic("Inappropriate callback type called")
}
callback(connection, storage_pool)
}
func (c *Connect) StoragePoolEventLifecycleRegister(pool *StoragePool, callback StoragePoolEventLifecycleCallback) (int, error) {
if C.LIBVIR_VERSION_NUMBER < 2000000 {
return 0, GetNotImplementedError()
......@@ -91,6 +108,29 @@ func (c *Connect) StoragePoolEventLifecycleRegister(pool *StoragePool, callback
return int(ret), nil
}
func (c *Connect) StoragePoolEventRefreshRegister(pool *StoragePool, callback StoragePoolEventGenericCallback) (int, error) {
if C.LIBVIR_VERSION_NUMBER < 2000000 {
return 0, GetNotImplementedError()
}
goCallBackId := registerCallbackId(callback)
callbackPtr := unsafe.Pointer(C.storagePoolEventGenericCallback_cgo)
var cpool C.virStoragePoolPtr
if pool != nil {
cpool = pool.ptr
}
ret := C.virConnectStoragePoolEventRegisterAny_cgo(c.ptr, cpool,
C.VIR_STORAGE_POOL_EVENT_ID_REFRESH,
C.virConnectStoragePoolEventGenericCallback(callbackPtr),
C.long(goCallBackId))
if ret == -1 {
freeCallbackId(goCallBackId)
return 0, GetLastError()
}
return int(ret), nil
}
func (c *Connect) StoragePoolEventDeregister(callbackId int) error {
if C.LIBVIR_VERSION_NUMBER < 2000000 {
return GetNotImplementedError()
......
......@@ -43,6 +43,13 @@ void storagePoolEventLifecycleCallback_cgo(virConnectPtr c, virStoragePoolPtr d,
storagePoolEventLifecycleCallback(c, d, event, detail, (int)(intptr_t)data);
}
extern void storagePoolEventGenericCallback(virConnectPtr, virStoragePoolPtr, int);
void storagePoolEventGenericCallback_cgo(virConnectPtr c, virStoragePoolPtr d,
void *data)
{
storagePoolEventGenericCallback(c, d, (int)(intptr_t)data);
}
int virConnectStoragePoolEventRegisterAny_cgo(virConnectPtr c, virStoragePoolPtr d,
int eventID, virConnectStoragePoolEventGenericCallback cb,
long goCallbackId) {
......
......@@ -29,6 +29,8 @@
void storagePoolEventLifecycleCallback_cgo(virConnectPtr c, virStoragePoolPtr d,
int event, int detail, void* data);
void storagePoolEventGenericCallback_cgo(virConnectPtr c, virStoragePoolPtr d,
void* data);
int virConnectStoragePoolEventRegisterAny_cgo(virConnectPtr c, virStoragePoolPtr d,
int eventID, virConnectStoragePoolEventGenericCallback cb,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment