Commit 9389448e authored by Daniel P. Berrange's avatar Daniel P. Berrange

Add virConnectDomainEventBlockThresholdCallback binding

Signed-off-by: default avatarDaniel P. Berrange <berrange@redhat.com>
parent 4ac334a6
......@@ -108,6 +108,7 @@ var (
"virConnectDomainEventTunableCallback",
"virConnectDomainEventWatchdogCallback",
"virConnectDomainEventMetadataChangeCallback",
"virConnectDomainEventBlockThresholdCallback",
/* Network event callback typedefs */
"virConnectNetworkEventGenericCallback",
......
......@@ -210,6 +210,15 @@ type DomainEventMetadataChange struct {
type DomainEventMetadataChangeCallback func(c *Connect, d *Domain, event *DomainEventMetadataChange)
type DomainEventBlockThreshold struct {
Dev string
Path string
Threshold uint64
Excess uint64
}
type DomainEventBlockThresholdCallback func(c *Connect, d *Domain, event *DomainEventBlockThreshold)
//export domainEventLifecycleCallback
func domainEventLifecycleCallback(c C.virConnectPtr, d C.virDomainPtr,
event int, detail int,
......@@ -931,6 +940,26 @@ func domainEventDeviceRemovalFailedCallback(c C.virConnectPtr, d C.virDomainPtr,
}
//export domainEventBlockThresholdCallback
func domainEventBlockThresholdCallback(c C.virConnectPtr, d C.virDomainPtr, dev *C.char, path *C.char, threshold C.ulonglong, excess C.ulonglong, goCallbackId int) {
domain := &Domain{ptr: d}
connection := &Connect{ptr: c}
eventDetails := &DomainEventBlockThreshold{
Dev: C.GoString(dev),
Path: C.GoString(path),
Threshold: uint64(threshold),
Excess: uint64(excess),
}
callbackFunc := getCallbackId(goCallbackId)
callback, ok := callbackFunc.(DomainEventBlockThresholdCallback)
if !ok {
panic("Inappropriate callback type called")
}
callback(connection, domain, eventDetails)
}
func (c *Connect) DomainEventLifecycleRegister(dom *Domain, callback DomainEventLifecycleCallback) (int, error) {
goCallBackId := registerCallbackId(callback)
......@@ -1387,6 +1416,25 @@ func (c *Connect) DomainEventMetadataChangeRegister(dom *Domain, callback Domain
return int(ret), nil
}
func (c *Connect) DomainEventBlockThresholdRegister(dom *Domain, callback DomainEventBlockThresholdCallback) (int, error) {
goCallBackId := registerCallbackId(callback)
callbackPtr := unsafe.Pointer(C.domainEventBlockThresholdCallback_cgo)
var cdom C.virDomainPtr
if dom != nil {
cdom = dom.ptr
}
ret := C.virConnectDomainEventRegisterAny_cgo(c.ptr, cdom,
C.VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD,
C.virConnectDomainEventGenericCallback(callbackPtr),
C.long(goCallBackId))
if ret == -1 {
freeCallbackId(goCallBackId)
return 0, GetLastError()
}
return int(ret), nil
}
func (c *Connect) DomainEventDeregister(callbackId int) error {
// Deregister the callback
if i := int(C.virConnectDomainEventDeregisterAny(c.ptr, C.int(callbackId))); i != 0 {
......
......@@ -215,6 +215,18 @@ void domainEventMetadataChangeCallback_cgo(virConnectPtr conn,
domainEventMetadataChangeCallback(conn, dom, type, nsuri, (int)(intptr_t)opaque);
}
extern void domainEventBlockThresholdCallback(virConnectPtr, virDomainPtr, const char *, const char *, unsigned long long, unsigned long long, int);
void domainEventBlockThresholdCallback_cgo(virConnectPtr conn,
virDomainPtr dom,
const char *dev,
const char *path,
unsigned long long threshold,
unsigned long long excess,
void *opaque)
{
domainEventBlockThresholdCallback(conn, dom, dev, path, threshold, excess, (int)(intptr_t)opaque);
}
int virConnectDomainEventRegisterAny_cgo(virConnectPtr c, virDomainPtr d,
int eventID, virConnectDomainEventGenericCallback cb,
long goCallbackId) {
......
......@@ -108,6 +108,13 @@ void domainEventMetadataChangeCallback_cgo(virConnectPtr conn,
int type,
const char *nsuri,
void *opaque);
void domainEventBlockThresholdCallback_cgo(virConnectPtr conn,
virDomainPtr dom,
const char *dev,
const char *path,
unsigned long long threshold,
unsigned long long excess,
void *opaque);
int virConnectDomainEventRegisterAny_cgo(virConnectPtr c, virDomainPtr d,
int eventID, virConnectDomainEventGenericCallback 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