[PATCH go 1/3] Add support for domain metadata change event

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 api_test.go             |  1 +
 domain_compat.h         |  3 +++
 domain_events.go        | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 domain_events_cfuncs.go | 10 ++++++++++
 domain_events_cfuncs.h  |  5 +++++
 5 files changed, 65 insertions(+)

diff --git a/api_test.go b/api_test.go
index 93adf7f..fafd35e 100644
--- a/api_test.go
+++ b/api_test.go
@@ -107,6 +107,7 @@ var (
 		"virConnectDomainEventTrayChangeCallback",
 		"virConnectDomainEventTunableCallback",
 		"virConnectDomainEventWatchdogCallback",
+		"virConnectDomainEventMetadataChangeCallback",
 
 		/* Network event callback typedefs */
 		"virConnectNetworkEventGenericCallback",
diff --git a/domain_compat.h b/domain_compat.h
index cb806b9..14072d0 100644
--- a/domain_compat.h
+++ b/domain_compat.h
@@ -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 */
 
diff --git a/domain_events.go b/domain_events.go
index c65ce3b..8b34960 100644
--- a/domain_events.go
+++ b/domain_events.go
@@ -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 {
diff --git a/domain_events_cfuncs.go b/domain_events_cfuncs.go
index 8bdfb98..c23fac6 100644
--- a/domain_events_cfuncs.go
+++ b/domain_events_cfuncs.go
@@ -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) {
diff --git a/domain_events_cfuncs.h b/domain_events_cfuncs.h
index ba427aa..039da8e 100644
--- a/domain_events_cfuncs.h
+++ b/domain_events_cfuncs.h
@@ -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,
-- 
2.9.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux