aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorOsier Yang <jyang@redhat.com>2012-03-23 22:43:14 +0800
committerOsier Yang <jyang@redhat.com>2012-03-23 23:12:14 +0800
commit57ddcc235ac7f80d87f46c8b8cc5ce17e86b8b9b (patch)
tree66deb20b7e63f83ff0073b13e134a7c2c64dacf3 /python
parentqemu: Update tray status while tray moved event is emitted (diff)
downloadlibvirt-57ddcc235ac7f80d87f46c8b8cc5ce17e86b8b9b.tar.gz
libvirt-57ddcc235ac7f80d87f46c8b8cc5ce17e86b8b9b.tar.bz2
libvirt-57ddcc235ac7f80d87f46c8b8cc5ce17e86b8b9b.zip
Add support for the wakeup event
This patch introduces a new event type for the QMP event WAKEUP: VIR_DOMAIN_EVENT_ID_PMWAKEUP The event doesn't take any data, but considering there might be reason for wakeup in future, the callback definition is: typedef void (*virConnectDomainEventWakeupCallback)(virConnectPtr conn, virDomainPtr dom, int reason, void *opaque); "reason" is unused currently, always passes "0".
Diffstat (limited to 'python')
-rw-r--r--python/libvirt-override-virConnect.py8
-rw-r--r--python/libvirt-override.c50
2 files changed, 58 insertions, 0 deletions
diff --git a/python/libvirt-override-virConnect.py b/python/libvirt-override-virConnect.py
index 82c243719..2d48828f0 100644
--- a/python/libvirt-override-virConnect.py
+++ b/python/libvirt-override-virConnect.py
@@ -143,6 +143,14 @@
cb(self, virDomain(self, _obj=dom), devAlias, reason, opaque)
return 0;
+ def _dispatchDomainEventPMWakeupCallback(self, dom, reason, cbData):
+ """Dispatches event to python user domain pmwakeup event callbacks
+ """
+ cb = cbData["cb"]
+ opaque = cbData["opaque"]
+
+ cb(self, virDomain(self, _obj=dom), reason, opaque)
+ return 0;
def domainEventDeregisterAny(self, callbackID):
"""Removes a Domain Event Callback. De-registering for a
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 42a441e39..51ae1cd64 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -5152,6 +5152,53 @@ libvirt_virConnectDomainEventTrayChangeCallback(virConnectPtr conn ATTRIBUTE_UNU
return ret;
}
+static int
+libvirt_virConnectDomainEventPMWakeupCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virDomainPtr dom,
+ int reason,
+ 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*)"_dispatchDomainEventPMWakeupCallback",
+ (char*)"OO",
+ pyobj_dom,
+ reason,
+ 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)
@@ -5215,6 +5262,9 @@ libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject * self,
case VIR_DOMAIN_EVENT_ID_TRAY_CHANGE:
cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventTrayChangeCallback);
break;
+ case VIR_DOMAIN_EVENT_ID_PMWAKEUP:
+ cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMWakeupCallback);
+ break;
}
if (!cb) {