diff options
author | Osier Yang <jyang@redhat.com> | 2012-03-23 21:44:50 +0800 |
---|---|---|
committer | Osier Yang <jyang@redhat.com> | 2012-03-23 23:10:26 +0800 |
commit | a26a1969c37c865b18294c5717544c1dc90beb3c (patch) | |
tree | ef2b2fc5785ae3e052c128fbc1b630f8c9dda9c2 /src/remote/remote_driver.c | |
parent | Implement sysinfo on PowerPC. (diff) | |
download | libvirt-a26a1969c37c865b18294c5717544c1dc90beb3c.tar.gz libvirt-a26a1969c37c865b18294c5717544c1dc90beb3c.tar.bz2 libvirt-a26a1969c37c865b18294c5717544c1dc90beb3c.zip |
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);
Diffstat (limited to 'src/remote/remote_driver.c')
-rw-r--r-- | src/remote/remote_driver.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 72b4b8fa3..f11e957f5 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -239,6 +239,11 @@ remoteDomainBuildEventDiskChange(virNetClientProgramPtr prog, virNetClientPtr client, void *evdata, void *opaque); +static void +remoteDomainBuildEventTrayChange(virNetClientProgramPtr prog, + virNetClientPtr client, + void *evdata, void *opaque); + static virNetClientProgramEvent remoteDomainEvents[] = { { REMOTE_PROC_DOMAIN_EVENT_RTC_CHANGE, remoteDomainBuildEventRTCChange, @@ -280,6 +285,10 @@ static virNetClientProgramEvent remoteDomainEvents[] = { remoteDomainBuildEventDiskChange, sizeof(remote_domain_event_disk_change_msg), (xdrproc_t)xdr_remote_domain_event_disk_change_msg }, + { REMOTE_PROC_DOMAIN_EVENT_TRAY_CHANGE, + remoteDomainBuildEventTrayChange, + sizeof(remote_domain_event_tray_change_msg), + (xdrproc_t)xdr_remote_domain_event_tray_change_msg }, }; enum virDrvOpenRemoteFlags { @@ -3731,6 +3740,31 @@ remoteDomainBuildEventDiskChange(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, } +static void +remoteDomainBuildEventTrayChange(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, + virNetClientPtr client ATTRIBUTE_UNUSED, + void *evdata, void *opaque) +{ + virConnectPtr conn = opaque; + struct private_data *priv = conn->privateData; + remote_domain_event_tray_change_msg *msg = evdata; + virDomainPtr dom; + virDomainEventPtr event = NULL; + + dom = get_nonnull_domain(conn, msg->dom); + if (!dom) + return; + + event = virDomainEventTrayChangeNewFromDom(dom, + msg->devAlias, + msg->reason); + + virDomainFree(dom); + + remoteDomainEventQueue(priv, event); +} + + static virDrvOpenStatus ATTRIBUTE_NONNULL (1) remoteSecretOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags) |