--- src/conf/domain_event.c | 84 +++++++++++++++++++++++++++++++------------------ src/conf/domain_event.h | 16 +++++----- 2 files changed, 61 insertions(+), 39 deletions(-) diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c index dea8729..5d56fe5 100644 --- a/src/conf/domain_event.c +++ b/src/conf/domain_event.c @@ -85,6 +85,7 @@ static virClassPtr virDomainEventRTCChangeClass; static virClassPtr virDomainEventWatchdogClass; static virClassPtr virDomainEventIOErrorClass; static virClassPtr virDomainEventGraphicsClass; +static virClassPtr virDomainEventBlockJobClass; static void virObjectEventDispose(void *obj); static void virDomainEventDispose(void *obj); static void virDomainEventLifecycleDispose(void *obj); @@ -92,6 +93,7 @@ static void virDomainEventRTCChangeDispose(void *obj); static void virDomainEventWatchdogDispose(void *obj); static void virDomainEventIOErrorDispose(void *obj); static void virDomainEventGraphicsDispose(void *obj); +static void virDomainEventBlockJobDispose(void *obj); struct _virObjectEvent { virObject parent; @@ -105,11 +107,6 @@ struct _virDomainEvent { union { struct { - char *path; - int type; - int status; - } blockJob; - struct { char *oldSrcPath; char *newSrcPath; char *devAlias; @@ -165,6 +162,16 @@ struct _virDomainEventIOError { typedef struct _virDomainEventIOError virDomainEventIOError; typedef virDomainEventIOError *virDomainEventIOErrorPtr; +struct _virDomainEventBlockJob { + virDomainEvent parent; + + char *path; + int type; + int status; +}; +typedef struct _virDomainEventBlockJob virDomainEventBlockJob; +typedef virDomainEventBlockJob *virDomainEventBlockJobPtr; + struct _virDomainEventGraphics { virDomainEvent parent; @@ -219,6 +226,12 @@ static int virObjectEventOnceInit(void) sizeof(virDomainEventGraphics), virDomainEventGraphicsDispose))) return -1; + if (!(virDomainEventBlockJobClass = virClassNew( + virDomainEventClass, + "virDomainEventBlockJob", + sizeof(virDomainEventBlockJob), + virDomainEventBlockJobDispose))) + return -1; return 0; } @@ -254,10 +267,6 @@ static void virDomainEventDispose(void *obj) switch (virObjectEventGetEventID(event)) { - case VIR_DOMAIN_EVENT_ID_BLOCK_JOB: - VIR_FREE(event->data.blockJob.path); - break; - case VIR_DOMAIN_EVENT_ID_DISK_CHANGE: VIR_FREE(event->data.diskChange.oldSrcPath); VIR_FREE(event->data.diskChange.newSrcPath); @@ -328,6 +337,14 @@ static void virDomainEventGraphicsDispose(void *obj) } } +static void virDomainEventBlockJobDispose(void *obj) +{ + virDomainEventBlockJobPtr event = obj; + VIR_DEBUG("obj=%p", event); + + VIR_FREE(event->path); +} + /** * virObjectEventCallbackListFree: * @list: event callback list head @@ -1152,43 +1169,43 @@ void *virDomainEventGraphicsNewFromObj(virDomainObjPtr obj, return ev; } -static virDomainEventPtr -virDomainEventBlockJobNew(int id, const char *name, unsigned char *uuid, - const char *path, int type, int status) +static +void * virDomainEventBlockJobNew(int id, const char *name, unsigned char *uuid, + const char *path, int type, int status) { - virDomainEventPtr ev; + virDomainEventBlockJobPtr ev; if (virObjectEventInitialize() < 0) return NULL; - if (!(ev = virDomainEventNew(virDomainEventClass, + if (!(ev = virDomainEventNew(virDomainEventBlockJobClass, VIR_DOMAIN_EVENT_ID_BLOCK_JOB, id, name, uuid))) return NULL; - if (VIR_STRDUP(ev->data.blockJob.path, path) < 0) { + if (VIR_STRDUP(ev->path, path) < 0) { virObjectUnref(ev); return NULL; } - ev->data.blockJob.type = type; - ev->data.blockJob.status = status; + ev->type = type; + ev->status = status; return ev; } -virDomainEventPtr virDomainEventBlockJobNewFromObj(virDomainObjPtr obj, - const char *path, - int type, - int status) +void *virDomainEventBlockJobNewFromObj(virDomainObjPtr obj, + const char *path, + int type, + int status) { return virDomainEventBlockJobNew(obj->def->id, obj->def->name, obj->def->uuid, path, type, status); } -virDomainEventPtr virDomainEventBlockJobNewFromDom(virDomainPtr dom, - const char *path, - int type, - int status) +void *virDomainEventBlockJobNewFromDom(virDomainPtr dom, + const char *path, + int type, + int status) { return virDomainEventBlockJobNew(dom->id, dom->name, dom->uuid, path, type, status); @@ -1633,12 +1650,17 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn, goto cleanup; case VIR_DOMAIN_EVENT_ID_BLOCK_JOB: - ((virConnectDomainEventBlockJobCallback)cb)(conn, dom, - event->data.blockJob.path, - event->data.blockJob.type, - event->data.blockJob.status, - cbopaque); - goto cleanup; + { + virDomainEventBlockJobPtr blockJobEvent; + + blockJobEvent = (virDomainEventBlockJobPtr)event; + ((virConnectDomainEventBlockJobCallback)cb)(conn, dom, + blockJobEvent->path, + blockJobEvent->type, + blockJobEvent->status, + cbopaque); + goto cleanup; + } case VIR_DOMAIN_EVENT_ID_DISK_CHANGE: ((virConnectDomainEventDiskChangeCallback)cb)(conn, dom, diff --git a/src/conf/domain_event.h b/src/conf/domain_event.h index c7b0347..1aa1455 100644 --- a/src/conf/domain_event.h +++ b/src/conf/domain_event.h @@ -109,14 +109,14 @@ void *virDomainEventGraphicsNewFromObj(virDomainObjPtr obj, virDomainEventPtr virDomainEventControlErrorNewFromDom(virDomainPtr dom); virDomainEventPtr virDomainEventControlErrorNewFromObj(virDomainObjPtr obj); -virDomainEventPtr virDomainEventBlockJobNewFromObj(virDomainObjPtr obj, - const char *path, - int type, - int status); -virDomainEventPtr virDomainEventBlockJobNewFromDom(virDomainPtr dom, - const char *path, - int type, - int status); +void *virDomainEventBlockJobNewFromObj(virDomainObjPtr obj, + const char *path, + int type, + int status); +void *virDomainEventBlockJobNewFromDom(virDomainPtr dom, + const char *path, + int type, + int status); virDomainEventPtr virDomainEventDiskChangeNewFromObj(virDomainObjPtr obj, const char *oldSrcPath, -- 1.8.4.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list