---
examples/event-test.py | 4 +++
libvirt-override-virConnect.py | 9 +++++++
libvirt-override.c | 60 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 73 insertions(+)
diff --git a/examples/event-test.py b/examples/event-test.py
index 5be4978..f96c917 100755
--- a/examples/event-test.py
+++ b/examples/event-test.py
@@ -535,6 +535,9 @@ def myDomainEventMigrationIteration(conn, dom, iteration, opaque):
dom.name(), dom.ID(), iteration))
def myDomainEventJobCompletedCallback(conn, dom, params, opaque):
print("myDomainEventJobCompletedCallback: Domain %s(%s) %s" % (dom.name(),
dom.ID(), params))
+def myDomainEventDeviceRemovalFailedCallback(conn, dom, dev, opaque):
+ print("myDomainEventDeviceRemovalFailedCallback: Domain %s(%s) failed to remove
device: %s" % (
+ dom.name(), dom.ID(), dev))
##########################################################################
# Network events
@@ -649,6 +652,7 @@ def main():
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_DEVICE_ADDED,
myDomainEventDeviceAddedCallback, None)
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION,
myDomainEventMigrationIteration, None)
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_JOB_COMPLETED,
myDomainEventJobCompletedCallback, None)
+ vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED,
myDomainEventDeviceRemovalFailedCallback, None)
vc.networkEventRegisterAny(None, libvirt.VIR_NETWORK_EVENT_ID_LIFECYCLE,
myNetworkEventLifecycleCallback, None)
diff --git a/libvirt-override-virConnect.py b/libvirt-override-virConnect.py
index 396a6ed..0f76c59 100644
--- a/libvirt-override-virConnect.py
+++ b/libvirt-override-virConnect.py
@@ -234,6 +234,15 @@
cb(self, virDomain(self, _obj=dom), params, opaque)
return 0
+ def _dispatchDomainEventDeviceRemovalFailedCallback(self, dom, devAlias, cbData):
+ """Dispatches event to python user domain device removal failed
event callbacks
+ """
+ cb = cbData["cb"]
+ opaque = cbData["opaque"]
+
+ cb(self, virDomain(self, _obj=dom), devAlias, 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 ee355da..4640ed5 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -6894,6 +6894,61 @@ libvirt_virConnectDomainEventJobCompletedCallback(virConnectPtr
conn ATTRIBUTE_U
}
#endif /* VIR_DOMAIN_EVENT_ID_JOB_COMPLETED */
+
+#ifdef VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED
+static int
+libvirt_virConnectDomainEventDeviceRemovalFailedCallback(virConnectPtr conn
ATTRIBUTE_UNUSED,
+ virDomainPtr dom,
+ const char *devAlias,
+ 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*)"_dispatchDomainEventDeviceRemovalFailedCallback",
+ (char*)"OsO",
+ pyobj_dom, devAlias, 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_DEVICE_REMOVAL_FAILED */
+
+
static PyObject *
libvirt_virConnectDomainEventRegisterAny(PyObject *self ATTRIBUTE_UNUSED,
PyObject *args)
@@ -7004,6 +7059,11 @@ libvirt_virConnectDomainEventRegisterAny(PyObject *self
ATTRIBUTE_UNUSED,
cb =
VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventJobCompletedCallback);
break;
#endif /* VIR_DOMAIN_EVENT_ID_JOB_COMPLETED */
+#ifdef VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED
+ case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED:
+ cb =
VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceRemovalFailedCallback);
+ break;
+#endif /* VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED */
case VIR_DOMAIN_EVENT_ID_LAST:
break;
}
--
2.8.0