Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx> --- libvirt-override-virConnect.py | 9 +++++++ libvirt-override.c | 57 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/libvirt-override-virConnect.py b/libvirt-override-virConnect.py index d26b480..dfd25d4 100644 --- a/libvirt-override-virConnect.py +++ b/libvirt-override-virConnect.py @@ -243,6 +243,15 @@ cb(self, virDomain(self, _obj=dom), devAlias, opaque) return 0 + def _dispatchDomainEventMetadataChangeCallback(self, dom, mtype, nsuri, cbData): + """Dispatches event to python user domain device removal failed event callbacks + """ + cb = cbData["cb"] + opaque = cbData["opaque"] + + cb(self, virDomain(self, _obj=dom), mtype, nsuri, opaque) + return 0 + def domainEventDeregisterAny(self, callbackID): """Removes a Domain Event Callback. De-registering for a domain callback will disable delivery of this event type """ diff --git a/libvirt-override.c b/libvirt-override.c index c15ab2d..2073e6e 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -6879,6 +6879,58 @@ libvirt_virConnectDomainEventDeviceRemovalFailedCallback(virConnectPtr conn ATTR } #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED */ +#ifdef VIR_DOMAIN_EVENT_ID_METADATA_CHANGE +static int +libvirt_virConnectDomainEventMetadataChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainPtr dom, + int type, + const char *nsuri, + void *opaque) +{ + PyObject *pyobj_cbData = (PyObject*)opaque; + PyObject *pyobj_dom; + PyObject *pyobj_ret = NULL; + PyObject *pyobj_conn; + PyObject *dictKey; + int ret = -1; + + LIBVIRT_ENSURE_THREAD_STATE; + + if (!(dictKey = libvirt_constcharPtrWrap("conn"))) + goto cleanup; + pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey); + Py_DECREF(dictKey); + + /* Create a python instance of this virDomainPtr */ + virDomainRef(dom); + if (!(pyobj_dom = libvirt_virDomainPtrWrap(dom))) { + virDomainFree(dom); + goto cleanup; + } + Py_INCREF(pyobj_cbData); + + /* Call the Callback Dispatcher */ + pyobj_ret = PyObject_CallMethod(pyobj_conn, + (char*)"_dispatchDomainEventMetadataChangeCallback", + (char*)"OisO", + pyobj_dom, type, nsuri, pyobj_cbData); + + Py_DECREF(pyobj_cbData); + Py_DECREF(pyobj_dom); + + cleanup: + if (!pyobj_ret) { + DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret); + PyErr_Print(); + } else { + Py_DECREF(pyobj_ret); + ret = 0; + } + + LIBVIRT_RELEASE_THREAD_STATE; + return ret; +} +#endif /* VIR_DOMAIN_EVENT_ID_METADATA_CHANGE */ static PyObject * libvirt_virConnectDomainEventRegisterAny(PyObject *self ATTRIBUTE_UNUSED, @@ -6995,6 +7047,11 @@ libvirt_virConnectDomainEventRegisterAny(PyObject *self ATTRIBUTE_UNUSED, cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceRemovalFailedCallback); break; #endif /* VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED */ +#ifdef VIR_DOMAIN_EVENT_ID_METADATA_CHANGE + case VIR_DOMAIN_EVENT_ID_METADATA_CHANGE: + cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventMetadataChangeCallback); + break; +#endif /* VIR_DOMAIN_EVENT_ID_METADATA_CHANGE */ case VIR_DOMAIN_EVENT_ID_LAST: break; } -- 2.9.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list