summaryrefslogtreecommitdiffstats
path: root/libvirt-override.c
diff options
context:
space:
mode:
authorOsier Yang <jyang@redhat.com>2012-03-26 12:12:00 +0800
committerDaniel Veillard <veillard@redhat.com>2012-03-26 14:07:06 +0800
commit058d05bb617cb48b21967e4c57e8a3d09ddc75e0 (patch)
tree7f562f835f0ff8a5c8186921abf883cfb627f2da /libvirt-override.c
parenta333d94eb3b2135c1cf9129b2e5a9aa5307b9882 (diff)
downloadlibvirt-python-v6-058d05bb617cb48b21967e4c57e8a3d09ddc75e0.tar.gz
libvirt-python-v6-058d05bb617cb48b21967e4c57e8a3d09ddc75e0.tar.xz
libvirt-python-v6-058d05bb617cb48b21967e4c57e8a3d09ddc75e0.zip
Add support for event tray moved of removable diskslibvirt-0.9.10-9.el6libvirt-0.9.10-8.el6libvirt-0.9.10-7.el6
https://bugzilla.redhat.com/show_bug.cgi?id=575160 This patch introduces a new event type for the QMP event DEVICE_TRAY_MOVED, which occurs when the tray of a removable disk is moved (i.e opened or closed): VIR_DOMAIN_EVENT_ID_TRAY_CHANGE The event's data includes the device alias and the reason for tray status' changing, which indicates why the tray status was changed. Thus the callback definition for the event is: enum { VIR_DOMAIN_EVENT_TRAY_CHANGE_OPEN = 0, VIR_DOMAIN_EVENT_TRAY_CHANGE_CLOSE, \#ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_EVENT_TRAY_CHANGE_LAST \#endif } virDomainEventTrayChangeReason; typedef void (*virConnectDomainEventTrayChangeCallback)(virConnectPtr conn, virDomainPtr dom, const char *devAlias, int reason, void *opaque); (cherry picked from commit a26a1969c37c865b18294c5717544c1dc90beb3c) Conflicts: src/qemu/qemu_monitor_json.c: No SPICE_* events in RHEL && no __com.redhat_SPICE_* events in upstream. src/remote/remote_protocol.x src/remote_protocol-structs: No PM_WAKEUP PROC in RHEL tree
Diffstat (limited to 'libvirt-override.c')
-rw-r--r--libvirt-override.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/libvirt-override.c b/libvirt-override.c
index 129f29c..42a441e 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -5105,6 +5105,53 @@ libvirt_virConnectDomainEventDiskChangeCallback(virConnectPtr conn ATTRIBUTE_UNU
return ret;
}
+static int
+libvirt_virConnectDomainEventTrayChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virDomainPtr dom,
+ const char *devAlias,
+ 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*)"_dispatchDomainEventTrayChangeCallback",
+ (char*)"OsiO",
+ pyobj_dom,
+ devAlias, 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)
@@ -5165,6 +5212,9 @@ libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject * self,
case VIR_DOMAIN_EVENT_ID_DISK_CHANGE:
cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDiskChangeCallback);
break;
+ case VIR_DOMAIN_EVENT_ID_TRAY_CHANGE:
+ cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventTrayChangeCallback);
+ break;
}
if (!cb) {