Commit 4c5caa0b authored by Daniel P. Berrange's avatar Daniel P. Berrange

Add support for domain metadata change event

Signed-off-by: default avatarDaniel P. Berrange <berrange@redhat.com>
parent 601d71df
......@@ -107,6 +107,7 @@ var (
"virConnectDomainEventTrayChangeCallback",
"virConnectDomainEventTunableCallback",
"virConnectDomainEventWatchdogCallback",
"virConnectDomainEventMetadataChangeCallback",
/* Network event callback typedefs */
"virConnectNetworkEventGenericCallback",
......
......@@ -45,6 +45,9 @@
#define VIR_PERF_PARAM_REF_CPU_CYCLES "ref_cpu_cycles"
#endif
#ifndef VIR_DOMAIN_EVENT_ID_METADATA_CHANGE
#define VIR_DOMAIN_EVENT_ID_METADATA_CHANGE 23
#endif
/* 1.2.2 */
......
......@@ -203,6 +203,13 @@ type DomainEventDeviceRemovalFailed struct {
type DomainEventDeviceRemovalFailedCallback func(c *Connect, d *Domain, event *DomainEventDeviceRemovalFailed)
type DomainEventMetadataChange struct {
Type int
NSURI string
}
type DomainEventMetadataChangeCallback func(c *Connect, d *Domain, event *DomainEventMetadataChange)
//export domainEventLifecycleCallback
func domainEventLifecycleCallback(c C.virConnectPtr, d C.virDomainPtr,
event int, detail int,
......@@ -540,6 +547,26 @@ func domainEventDeviceRemovedCallback(c C.virConnectPtr, d C.virDomainPtr,
}
//export domainEventMetadataChangeCallback
func domainEventMetadataChangeCallback(c C.virConnectPtr, d C.virDomainPtr,
mtype int, nsuri *C.char, goCallbackId int) {
domain := &Domain{ptr: d}
connection := &Connect{ptr: c}
eventDetails := &DomainEventMetadataChange{
Type: (int)(mtype),
NSURI: C.GoString(nsuri),
}
callbackFunc := getCallbackId(goCallbackId)
callback, ok := callbackFunc.(DomainEventMetadataChangeCallback)
if !ok {
panic("Inappropriate callback type called")
}
callback(connection, domain, eventDetails)
}
func getDomainTuneSchedulerParametersFieldInfo(params *DomainSchedulerParameters) map[string]typedParamsFieldInfo {
return map[string]typedParamsFieldInfo{
C.VIR_DOMAIN_TUNABLE_CPU_CPU_SHARES: typedParamsFieldInfo{
......@@ -1341,6 +1368,25 @@ func (c *Connect) DomainEventDeviceRemovalFailedRegister(dom *Domain, callback D
return int(ret), nil
}
func (c *Connect) DomainEventMetadataChangeRegister(dom *Domain, callback DomainEventMetadataChangeCallback) (int, error) {
goCallBackId := registerCallbackId(callback)
callbackPtr := unsafe.Pointer(C.domainEventMetadataChangeCallback_cgo)
var cdom C.virDomainPtr
if dom != nil {
cdom = dom.ptr
}
ret := C.virConnectDomainEventRegisterAny_cgo(c.ptr, cdom,
C.VIR_DOMAIN_EVENT_ID_METADATA_CHANGE,
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 {
......
......@@ -205,6 +205,16 @@ void domainEventDeviceRemovalFailedCallback_cgo(virConnectPtr conn,
domainEventDeviceRemovalFailedCallback(conn, dom, devAlias, (int)(intptr_t)opaque);
}
extern void domainEventMetadataChangeCallback(virConnectPtr, virDomainPtr, int, const char *, int);
void domainEventMetadataChangeCallback_cgo(virConnectPtr conn,
virDomainPtr dom,
int type,
const char *nsuri,
void *opaque)
{
domainEventMetadataChangeCallback(conn, dom, type, nsuri, (int)(intptr_t)opaque);
}
int virConnectDomainEventRegisterAny_cgo(virConnectPtr c, virDomainPtr d,
int eventID, virConnectDomainEventGenericCallback cb,
long goCallbackId) {
......
......@@ -103,6 +103,11 @@ void domainEventDeviceRemovalFailedCallback_cgo(virConnectPtr conn,
virDomainPtr dom,
const char *devAlias,
void *opaque);
void domainEventMetadataChangeCallback_cgo(virConnectPtr conn,
virDomainPtr dom,
int type,
const char *nsuri,
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