From 4b6a7b3fce2e30e600db5bee484badfe25f8e3f2 Mon Sep 17 00:00:00 2001 From: Osier Yang Date: Fri, 23 Mar 2012 21:44:50 +0800 Subject: Add support for event tray moved of removable disks 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); --- libvirt-override-virConnect.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libvirt-override-virConnect.py') diff --git a/libvirt-override-virConnect.py b/libvirt-override-virConnect.py index b908b32..82c2437 100644 --- a/libvirt-override-virConnect.py +++ b/libvirt-override-virConnect.py @@ -134,6 +134,16 @@ cb(self, virDomain(self, _obj=dom), oldSrcPath, newSrcPath, devAlias, reason, opaque) return 0; + def _dispatchDomainEventTrayChangeCallback(self, dom, devAlias, reason, cbData): + """Dispatches event to python user domain trayChange event callbacks + """ + cb = cbData["cb"] + opaque = cbData["opaque"] + + cb(self, virDomain(self, _obj=dom), devAlias, reason, 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 """ -- cgit