---
src/conf/domain_event.c | 86 ++++++++++++++++++++++++++++++++-----------------
src/conf/domain_event.h | 12 +++----
2 files changed, 62 insertions(+), 36 deletions(-)
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index e145157..91bdbae 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -90,6 +90,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);
@@ -97,6 +98,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;
@@ -110,11 +112,6 @@ struct _virDomainEvent {
union {
struct {
- char *path;
- int type;
- int status;
- } blockJob;
- struct {
char *oldSrcPath;
char *newSrcPath;
char *devAlias;
@@ -170,6 +167,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;
@@ -224,6 +231,12 @@ static int virObjectEventOnceInit(void)
sizeof(virDomainEventGraphics),
virDomainEventGraphicsDispose)))
return -1;
+ if (!(virDomainEventBlockJobClass = virClassNew(
+ virDomainEventClass,
+ "virDomainEventBlockJob",
+ sizeof(virDomainEventBlockJob),
+ virDomainEventBlockJobDispose)))
+ return -1;
return 0;
}
@@ -256,10 +269,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);
@@ -330,6 +339,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
@@ -1154,43 +1171,47 @@ virDomainEventPtr virDomainEventGraphicsNewFromObj(virDomainObjPtr
obj,
return (virDomainEventPtr)ev;
}
-static virDomainEventPtr
-virDomainEventBlockJobNew(int id, const char *name, unsigned char *uuid,
- const char *path, int type, int status)
+static
+virDomainEventPtr 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;
+ return (virDomainEventPtr)ev;
}
virDomainEventPtr virDomainEventBlockJobNewFromObj(virDomainObjPtr obj,
- const char *path,
- int type,
- int status)
+ 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)
+ const char *path,
+ int type,
+ int status)
{
return virDomainEventBlockJobNew(dom->id, dom->name, dom->uuid,
path, type, status);
@@ -1635,12 +1656,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 63b8c9f..bf701f9 100644
--- a/src/conf/domain_event.h
+++ b/src/conf/domain_event.h
@@ -104,13 +104,13 @@ virDomainEventPtr virDomainEventControlErrorNewFromDom(virDomainPtr
dom);
virDomainEventPtr virDomainEventControlErrorNewFromObj(virDomainObjPtr obj);
virDomainEventPtr virDomainEventBlockJobNewFromObj(virDomainObjPtr obj,
- const char *path,
- int type,
- int status);
+ const char *path,
+ int type,
+ int status);
virDomainEventPtr virDomainEventBlockJobNewFromDom(virDomainPtr dom,
- const char *path,
- int type,
- int status);
+ const char *path,
+ int type,
+ int status);
virDomainEventPtr virDomainEventDiskChangeNewFromObj(virDomainObjPtr obj,
const char *oldSrcPath,
--
1.8.4.4