1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-12-13 00:23:49 +03:00

Add support for event tray moved of removable disks

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
This commit is contained in:
Osier Yang
2012-03-26 12:12:00 +08:00
committed by Daniel Veillard
parent a333d94eb3
commit 058d05bb61
2 changed files with 60 additions and 0 deletions

View File

@@ -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 """