--- src/conf/domain_event.c | 60 ++++++++++++++++++++++++++++++++++--------------- src/conf/domain_event.h | 4 ++-- 2 files changed, 44 insertions(+), 20 deletions(-) diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c index 24291b9..ac7828e 100644 --- a/src/conf/domain_event.c +++ b/src/conf/domain_event.c @@ -88,6 +88,7 @@ static virClassPtr virDomainEventGraphicsClass; static virClassPtr virDomainEventBlockJobClass; static virClassPtr virDomainEventDiskChangeClass; static virClassPtr virDomainEventTrayChangeClass; +static virClassPtr virDomainEventBalloonChangeClass; static void virObjectEventDispose(void *obj); static void virDomainEventDispose(void *obj); @@ -99,6 +100,7 @@ static void virDomainEventGraphicsDispose(void *obj); static void virDomainEventBlockJobDispose(void *obj); static void virDomainEventDiskChangeDispose(void *obj); static void virDomainEventTrayChangeDispose(void *obj); +static void virDomainEventBalloonChangeDispose(void *obj); struct _virObjectEvent { virObject parent; @@ -112,10 +114,6 @@ struct _virDomainEvent { union { struct { - /* In unit of 1024 bytes */ - unsigned long long actual; - } balloonChange; - struct { char *devAlias; } deviceRemoved; } data; @@ -199,6 +197,15 @@ struct _virDomainEventTrayChange { typedef struct _virDomainEventTrayChange virDomainEventTrayChange; typedef virDomainEventTrayChange *virDomainEventTrayChangePtr; +struct _virDomainEventBalloonChange { + virDomainEvent parent; + + /* In unit of 1024 bytes */ + unsigned long long actual; +}; +typedef struct _virDomainEventBalloonChange virDomainEventBalloonChange; +typedef virDomainEventBalloonChange *virDomainEventBalloonChangePtr; + static int virObjectEventOnceInit(void) { @@ -260,6 +267,12 @@ static int virObjectEventOnceInit(void) sizeof(virDomainEventTrayChange), virDomainEventTrayChangeDispose))) return -1; + if (!(virDomainEventBalloonChangeClass = virClassNew( + virDomainEventClass, + "virDomainEventBalloonChange", + sizeof(virDomainEventBalloonChange), + virDomainEventBalloonChangeDispose))) + return -1; return 0; } @@ -383,6 +396,12 @@ static void virDomainEventTrayChangeDispose(void *obj) VIR_FREE(event->devAlias); } +static void virDomainEventBalloonChangeDispose(void *obj) +{ + virDomainEventBalloonChangePtr event = obj; + VIR_DEBUG("obj=%p", event); +} + /** * virObjectEventCallbackListFree: * @list: event callback list head @@ -1475,37 +1494,37 @@ virDomainEventPMSuspendDiskNewFromDom(virDomainPtr dom) return virDomainEventPMSuspendDiskNew(dom->id, dom->name, dom->uuid); } -virDomainEventPtr virDomainEventBalloonChangeNewFromDom(virDomainPtr dom, - unsigned long long actual) +void *virDomainEventBalloonChangeNewFromDom(virDomainPtr dom, + unsigned long long actual) { - virDomainEventPtr ev; + virDomainEventBalloonChangePtr ev; if (virObjectEventInitialize() < 0) return NULL; - if (!(ev = virDomainEventNew(virDomainEventClass, + if (!(ev = virDomainEventNew(virDomainEventBalloonChangeClass, VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE, dom->id, dom->name, dom->uuid))) return NULL; - ev->data.balloonChange.actual = actual; + ev->actual = actual; return ev; } -virDomainEventPtr virDomainEventBalloonChangeNewFromObj(virDomainObjPtr obj, - unsigned long long actual) +void *virDomainEventBalloonChangeNewFromObj(virDomainObjPtr obj, + unsigned long long actual) { - virDomainEventPtr ev; + virDomainEventBalloonChangePtr ev; if (virObjectEventInitialize() < 0) return NULL; - if (!(ev = virDomainEventNew(virDomainEventClass, + if (!(ev = virDomainEventNew(virDomainEventBalloonChangeClass, VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE, obj->def->id, obj->def->name, obj->def->uuid))) return NULL; - ev->data.balloonChange.actual = actual; + ev->actual = actual; return ev; } @@ -1735,10 +1754,15 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn, goto cleanup; case VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE: - ((virConnectDomainEventBalloonChangeCallback)cb)(conn, dom, - event->data.balloonChange.actual, - cbopaque); - goto cleanup; + { + virDomainEventBalloonChangePtr balloonChangeEvent; + + balloonChangeEvent = (virDomainEventBalloonChangePtr)event; + ((virConnectDomainEventBalloonChangeCallback)cb)(conn, dom, + balloonChangeEvent->actual, + cbopaque); + goto cleanup; + } case VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK: ((virConnectDomainEventPMSuspendDiskCallback)cb)(conn, dom, 0, cbopaque); diff --git a/src/conf/domain_event.h b/src/conf/domain_event.h index 5a684eb..f4a344c 100644 --- a/src/conf/domain_event.h +++ b/src/conf/domain_event.h @@ -139,8 +139,8 @@ virDomainEventPtr virDomainEventPMWakeupNewFromDom(virDomainPtr dom); virDomainEventPtr virDomainEventPMSuspendNewFromObj(virDomainObjPtr obj); virDomainEventPtr virDomainEventPMSuspendNewFromDom(virDomainPtr dom); -virDomainEventPtr virDomainEventBalloonChangeNewFromDom(virDomainPtr dom, unsigned long long actual); -virDomainEventPtr virDomainEventBalloonChangeNewFromObj(virDomainObjPtr obj, unsigned long long actual); +void *virDomainEventBalloonChangeNewFromDom(virDomainPtr dom, unsigned long long actual); +void *virDomainEventBalloonChangeNewFromObj(virDomainObjPtr obj, unsigned long long actual); virDomainEventPtr virDomainEventPMSuspendDiskNewFromObj(virDomainObjPtr obj); virDomainEventPtr virDomainEventPMSuspendDiskNewFromDom(virDomainPtr dom); -- 1.8.4.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list