---
src/conf/domain_event.c | 77 ++++++++++++++++++++++++++++++++-----------------
src/conf/domain_event.h | 4 +--
2 files changed, 52 insertions(+), 29 deletions(-)
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index 8497b9a..24291b9 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -87,6 +87,7 @@ static virClassPtr virDomainEventIOErrorClass;
static virClassPtr virDomainEventGraphicsClass;
static virClassPtr virDomainEventBlockJobClass;
static virClassPtr virDomainEventDiskChangeClass;
+static virClassPtr virDomainEventTrayChangeClass;
static void virObjectEventDispose(void *obj);
static void virDomainEventDispose(void *obj);
@@ -97,6 +98,7 @@ static void virDomainEventIOErrorDispose(void *obj);
static void virDomainEventGraphicsDispose(void *obj);
static void virDomainEventBlockJobDispose(void *obj);
static void virDomainEventDiskChangeDispose(void *obj);
+static void virDomainEventTrayChangeDispose(void *obj);
struct _virObjectEvent {
virObject parent;
@@ -110,10 +112,6 @@ struct _virDomainEvent {
union {
struct {
- char *devAlias;
- int reason;
- } trayChange;
- struct {
/* In unit of 1024 bytes */
unsigned long long actual;
} balloonChange;
@@ -192,6 +190,15 @@ struct _virDomainEventDiskChange {
typedef struct _virDomainEventDiskChange virDomainEventDiskChange;
typedef virDomainEventDiskChange *virDomainEventDiskChangePtr;
+struct _virDomainEventTrayChange {
+ virDomainEvent parent;
+
+ char *devAlias;
+ int reason;
+};
+typedef struct _virDomainEventTrayChange virDomainEventTrayChange;
+typedef virDomainEventTrayChange *virDomainEventTrayChangePtr;
+
static int virObjectEventOnceInit(void)
{
@@ -247,6 +254,12 @@ static int virObjectEventOnceInit(void)
sizeof(virDomainEventDiskChange),
virDomainEventDiskChangeDispose)))
return -1;
+ if (!(virDomainEventTrayChangeClass = virClassNew(
+ virDomainEventClass,
+ "virDomainEventTrayChange",
+ sizeof(virDomainEventTrayChange),
+ virDomainEventTrayChangeDispose)))
+ return -1;
return 0;
}
@@ -282,9 +295,6 @@ static void virDomainEventDispose(void *obj)
switch (virObjectEventGetEventID(event)) {
- case VIR_DOMAIN_EVENT_ID_TRAY_CHANGE:
- VIR_FREE(event->data.trayChange.devAlias);
- break;
case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED:
VIR_FREE(event->data.deviceRemoved.devAlias);
break;
@@ -365,6 +375,14 @@ static void virDomainEventDiskChangeDispose(void *obj)
VIR_FREE(event->devAlias);
}
+static void virDomainEventTrayChangeDispose(void *obj)
+{
+ virDomainEventTrayChangePtr event = obj;
+ VIR_DEBUG("obj=%p", event);
+
+ VIR_FREE(event->devAlias);
+}
+
/**
* virObjectEventCallbackListFree:
* @list: event callback list head
@@ -1318,26 +1336,26 @@ void *virDomainEventDiskChangeNewFromDom(virDomainPtr dom,
devAlias, reason);
}
-static virDomainEventPtr
-virDomainEventTrayChangeNew(int id, const char *name,
- unsigned char *uuid,
- const char *devAlias,
- int reason)
+static
+void *virDomainEventTrayChangeNew(int id, const char *name,
+ unsigned char *uuid,
+ const char *devAlias,
+ int reason)
{
- virDomainEventPtr ev;
+ virDomainEventTrayChangePtr ev;
if (virObjectEventInitialize() < 0)
return NULL;
- if (!(ev = virDomainEventNew(virDomainEventClass,
+ if (!(ev = virDomainEventNew(virDomainEventTrayChangeClass,
VIR_DOMAIN_EVENT_ID_TRAY_CHANGE,
id, name, uuid)))
return NULL;
- if (VIR_STRDUP(ev->data.trayChange.devAlias, devAlias) < 0)
+ if (VIR_STRDUP(ev->devAlias, devAlias) < 0)
goto error;
- ev->data.trayChange.reason = reason;
+ ev->reason = reason;
return ev;
@@ -1346,9 +1364,9 @@ error:
return NULL;
}
-virDomainEventPtr virDomainEventTrayChangeNewFromObj(virDomainObjPtr obj,
- const char *devAlias,
- int reason)
+void *virDomainEventTrayChangeNewFromObj(virDomainObjPtr obj,
+ const char *devAlias,
+ int reason)
{
return virDomainEventTrayChangeNew(obj->def->id,
obj->def->name,
@@ -1357,9 +1375,9 @@ virDomainEventPtr virDomainEventTrayChangeNewFromObj(virDomainObjPtr
obj,
reason);
}
-virDomainEventPtr virDomainEventTrayChangeNewFromDom(virDomainPtr dom,
- const char *devAlias,
- int reason)
+void *virDomainEventTrayChangeNewFromDom(virDomainPtr dom,
+ const char *devAlias,
+ int reason)
{
return virDomainEventTrayChangeNew(dom->id, dom->name, dom->uuid,
devAlias, reason);
@@ -1697,11 +1715,16 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn,
}
case VIR_DOMAIN_EVENT_ID_TRAY_CHANGE:
- ((virConnectDomainEventTrayChangeCallback)cb)(conn, dom,
-
event->data.trayChange.devAlias,
- event->data.trayChange.reason,
- cbopaque);
- goto cleanup;
+ {
+ virDomainEventTrayChangePtr trayChangeEvent;
+
+ trayChangeEvent = (virDomainEventTrayChangePtr)event;
+ ((virConnectDomainEventTrayChangeCallback)cb)(conn, dom,
+ trayChangeEvent->devAlias,
+ trayChangeEvent->reason,
+ cbopaque);
+ goto cleanup;
+ }
case VIR_DOMAIN_EVENT_ID_PMWAKEUP:
((virConnectDomainEventPMWakeupCallback)cb)(conn, dom, 0, cbopaque);
diff --git a/src/conf/domain_event.h b/src/conf/domain_event.h
index 965af57..5a684eb 100644
--- a/src/conf/domain_event.h
+++ b/src/conf/domain_event.h
@@ -128,10 +128,10 @@ void *virDomainEventDiskChangeNewFromDom(virDomainPtr dom,
const char *newSrcPath,
const char *devAlias,
int reason);
-virDomainEventPtr virDomainEventTrayChangeNewFromObj(virDomainObjPtr obj,
+void *virDomainEventTrayChangeNewFromObj(virDomainObjPtr obj,
const char *devAlias,
int reason);
-virDomainEventPtr virDomainEventTrayChangeNewFromDom(virDomainPtr dom,
+void *virDomainEventTrayChangeNewFromDom(virDomainPtr dom,
const char *devAlias,
int reason);
virDomainEventPtr virDomainEventPMWakeupNewFromObj(virDomainObjPtr obj);
--
1.8.4.2