summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Denemark <jdenemar@redhat.com>2013-06-19 15:27:29 +0200
committerJiri Denemark <jdenemar@redhat.com>2013-07-18 15:28:45 +0200
commit8566ca3ad19c3db2e58ca5dc5fb629679328d1d5 (patch)
treeb9c3de9db46c66240dbc57048f65e9c9fc30b8b9
parent03e7cacfa2891b62737886692bd68b648cc74706 (diff)
downloadlibvirt-python-split-8566ca3ad19c3db2e58ca5dc5fb629679328d1d5.zip
libvirt-python-split-8566ca3ad19c3db2e58ca5dc5fb629679328d1d5.tar.gz
libvirt-python-split-8566ca3ad19c3db2e58ca5dc5fb629679328d1d5.tar.xz
Add VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED event
-rw-r--r--libvirt-override-virConnect.py9
-rw-r--r--libvirt-override.c52
2 files changed, 60 insertions, 1 deletions
diff --git a/libvirt-override-virConnect.py b/libvirt-override-virConnect.py
index a0f579d..044faa0 100644
--- a/libvirt-override-virConnect.py
+++ b/libvirt-override-virConnect.py
@@ -179,6 +179,15 @@
cb(self, virDomain(self, _obj=dom), reason, opaque)
return 0
+ def _dispatchDomainEventDeviceRemovedCallback(self, dom, devAlias, cbData):
+ """Dispatches event to python user domain device removed 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 0a10887..d16b9a2 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -6225,6 +6225,51 @@ libvirt_virConnectDomainEventPMSuspendDiskCallback(virConnectPtr conn ATTRIBUTE_
return ret;
}
+static int
+libvirt_virConnectDomainEventDeviceRemovedCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virDomainPtr dom,
+ const char *devAlias,
+ void *opaque)
+{
+ PyObject *pyobj_cbData = (PyObject*)opaque;
+ PyObject *pyobj_dom;
+ PyObject *pyobj_ret;
+ PyObject *pyobj_conn;
+ PyObject *dictKey;
+ int ret = -1;
+
+ LIBVIRT_ENSURE_THREAD_STATE;
+ /* Create a python instance of this virDomainPtr */
+ virDomainRef(dom);
+
+ pyobj_dom = libvirt_virDomainPtrWrap(dom);
+ Py_INCREF(pyobj_cbData);
+
+ dictKey = libvirt_constcharPtrWrap("conn");
+ pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
+ Py_DECREF(dictKey);
+
+ /* Call the Callback Dispatcher */
+ pyobj_ret = PyObject_CallMethod(pyobj_conn,
+ (char*)"_dispatchDomainEventDeviceRemovedCallback",
+ (char*)"OsO",
+ pyobj_dom, devAlias, pyobj_cbData);
+
+ Py_DECREF(pyobj_cbData);
+ Py_DECREF(pyobj_dom);
+
+ 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;
+}
+
static PyObject *
libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject * self,
PyObject * args)
@@ -6254,7 +6299,7 @@ libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject * self,
else
dom = PyvirDomain_Get(pyobj_dom);
- switch (eventID) {
+ switch ((virDomainEventID) eventID) {
case VIR_DOMAIN_EVENT_ID_LIFECYCLE:
cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventLifecycleCallback);
break;
@@ -6300,6 +6345,11 @@ libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject * self,
case VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK:
cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendDiskCallback);
break;
+ case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED:
+ cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceRemovedCallback);
+
+ case VIR_DOMAIN_EVENT_ID_LAST:
+ break;
}
if (!cb) {