---
src/conf/domain_event.c | 148 +++++++++++++++++++++++++++---------------------
src/conf/domain_event.h | 24 ++++----
2 files changed, 97 insertions(+), 75 deletions(-)
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index 21494e5..dea8729 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -84,12 +84,14 @@ static virClassPtr virDomainEventLifecycleClass;
static virClassPtr virDomainEventRTCChangeClass;
static virClassPtr virDomainEventWatchdogClass;
static virClassPtr virDomainEventIOErrorClass;
+static virClassPtr virDomainEventGraphicsClass;
static void virObjectEventDispose(void *obj);
static void virDomainEventDispose(void *obj);
static void virDomainEventLifecycleDispose(void *obj);
static void virDomainEventRTCChangeDispose(void *obj);
static void virDomainEventWatchdogDispose(void *obj);
static void virDomainEventIOErrorDispose(void *obj);
+static void virDomainEventGraphicsDispose(void *obj);
struct _virObjectEvent {
virObject parent;
@@ -103,13 +105,6 @@ struct _virDomainEvent {
union {
struct {
- int phase;
- virDomainEventGraphicsAddressPtr local;
- virDomainEventGraphicsAddressPtr remote;
- char *authScheme;
- virDomainEventGraphicsSubjectPtr subject;
- } graphics;
- struct {
char *path;
int type;
int status;
@@ -170,6 +165,18 @@ struct _virDomainEventIOError {
typedef struct _virDomainEventIOError virDomainEventIOError;
typedef virDomainEventIOError *virDomainEventIOErrorPtr;
+struct _virDomainEventGraphics {
+ virDomainEvent parent;
+
+ int phase;
+ virDomainEventGraphicsAddressPtr local;
+ virDomainEventGraphicsAddressPtr remote;
+ char *authScheme;
+ virDomainEventGraphicsSubjectPtr subject;
+};
+typedef struct _virDomainEventGraphics virDomainEventGraphics;
+typedef virDomainEventGraphics *virDomainEventGraphicsPtr;
+
static int virObjectEventOnceInit(void)
{
if (!(virObjectEventClass = virClassNew(virClassForObject(),
@@ -206,6 +213,12 @@ static int virObjectEventOnceInit(void)
sizeof(virDomainEventIOError),
virDomainEventIOErrorDispose)))
return -1;
+ if (!(virDomainEventGraphicsClass = virClassNew(
+ virDomainEventClass,
+ "virDomainEventGraphics",
+ sizeof(virDomainEventGraphics),
+ virDomainEventGraphicsDispose)))
+ return -1;
return 0;
}
@@ -241,28 +254,6 @@ static void virDomainEventDispose(void *obj)
switch (virObjectEventGetEventID(event)) {
- case VIR_DOMAIN_EVENT_ID_GRAPHICS:
- if (event->data.graphics.local) {
- VIR_FREE(event->data.graphics.local->node);
- VIR_FREE(event->data.graphics.local->service);
- VIR_FREE(event->data.graphics.local);
- }
- if (event->data.graphics.remote) {
- VIR_FREE(event->data.graphics.remote->node);
- VIR_FREE(event->data.graphics.remote->service);
- VIR_FREE(event->data.graphics.remote);
- }
- VIR_FREE(event->data.graphics.authScheme);
- if (event->data.graphics.subject) {
- size_t i;
- for (i = 0; i < event->data.graphics.subject->nidentity; i++) {
- VIR_FREE(event->data.graphics.subject->identities[i].type);
- VIR_FREE(event->data.graphics.subject->identities[i].name);
- }
- VIR_FREE(event->data.graphics.subject);
- }
- break;
-
case VIR_DOMAIN_EVENT_ID_BLOCK_JOB:
VIR_FREE(event->data.blockJob.path);
break;
@@ -311,6 +302,32 @@ static void virDomainEventIOErrorDispose(void *obj)
VIR_FREE(event->reason);
}
+static void virDomainEventGraphicsDispose(void *obj)
+{
+ virDomainEventGraphicsPtr event = obj;
+ VIR_DEBUG("obj=%p", event);
+
+ if (event->local) {
+ VIR_FREE(event->local->node);
+ VIR_FREE(event->local->service);
+ VIR_FREE(event->local);
+ }
+ if (event->remote) {
+ VIR_FREE(event->remote->node);
+ VIR_FREE(event->remote->service);
+ VIR_FREE(event->remote);
+ }
+ VIR_FREE(event->authScheme);
+ if (event->subject) {
+ size_t i;
+ for (i = 0; i < event->subject->nidentity; i++) {
+ VIR_FREE(event->subject->identities[i].type);
+ VIR_FREE(event->subject->identities[i].name);
+ }
+ VIR_FREE(event->subject);
+ }
+}
+
/**
* virObjectEventCallbackListFree:
* @list: event callback list head
@@ -1076,61 +1093,61 @@ void *virDomainEventIOErrorReasonNewFromObj(virDomainObjPtr obj,
}
-virDomainEventPtr virDomainEventGraphicsNewFromDom(virDomainPtr dom,
- int phase,
- virDomainEventGraphicsAddressPtr
local,
- virDomainEventGraphicsAddressPtr
remote,
- const char *authScheme,
- virDomainEventGraphicsSubjectPtr
subject)
+void *virDomainEventGraphicsNewFromDom(virDomainPtr dom,
+ int phase,
+ virDomainEventGraphicsAddressPtr local,
+ virDomainEventGraphicsAddressPtr remote,
+ const char *authScheme,
+ virDomainEventGraphicsSubjectPtr subject)
{
- virDomainEventPtr ev;
+ virDomainEventGraphicsPtr ev;
if (virObjectEventInitialize() < 0)
return NULL;
- if (!(ev = virDomainEventNew(virDomainEventClass,
+ if (!(ev = virDomainEventNew(virDomainEventGraphicsClass,
VIR_DOMAIN_EVENT_ID_GRAPHICS,
dom->id, dom->name, dom->uuid)))
return NULL;
- ev->data.graphics.phase = phase;
- if (VIR_STRDUP(ev->data.graphics.authScheme, authScheme) < 0) {
+ ev->phase = phase;
+ if (VIR_STRDUP(ev->authScheme, authScheme) < 0) {
virObjectUnref(ev);
return NULL;
}
- ev->data.graphics.local = local;
- ev->data.graphics.remote = remote;
- ev->data.graphics.subject = subject;
+ ev->local = local;
+ ev->remote = remote;
+ ev->subject = subject;
return ev;
}
-virDomainEventPtr virDomainEventGraphicsNewFromObj(virDomainObjPtr obj,
- int phase,
- virDomainEventGraphicsAddressPtr
local,
- virDomainEventGraphicsAddressPtr
remote,
- const char *authScheme,
- virDomainEventGraphicsSubjectPtr
subject)
+void *virDomainEventGraphicsNewFromObj(virDomainObjPtr obj,
+ int phase,
+ virDomainEventGraphicsAddressPtr local,
+ virDomainEventGraphicsAddressPtr remote,
+ const char *authScheme,
+ virDomainEventGraphicsSubjectPtr subject)
{
- virDomainEventPtr ev;
+ virDomainEventGraphicsPtr ev;
if (virObjectEventInitialize() < 0)
return NULL;
- if (!(ev = virDomainEventNew(virDomainEventClass,
+ if (!(ev = virDomainEventNew(virDomainEventGraphicsClass,
VIR_DOMAIN_EVENT_ID_GRAPHICS,
obj->def->id, obj->def->name,
obj->def->uuid)))
return NULL;
- ev->data.graphics.phase = phase;
- if (VIR_STRDUP(ev->data.graphics.authScheme, authScheme) < 0) {
+ ev->phase = phase;
+ if (VIR_STRDUP(ev->authScheme, authScheme) < 0) {
virObjectUnref(ev);
return NULL;
}
- ev->data.graphics.local = local;
- ev->data.graphics.remote = remote;
- ev->data.graphics.subject = subject;
+ ev->local = local;
+ ev->remote = remote;
+ ev->subject = subject;
return ev;
}
@@ -1596,14 +1613,19 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn,
}
case VIR_DOMAIN_EVENT_ID_GRAPHICS:
- ((virConnectDomainEventGraphicsCallback)cb)(conn, dom,
- event->data.graphics.phase,
- event->data.graphics.local,
- event->data.graphics.remote,
- event->data.graphics.authScheme,
- event->data.graphics.subject,
- cbopaque);
- goto cleanup;
+ {
+ virDomainEventGraphicsPtr graphicsEvent;
+
+ graphicsEvent = (virDomainEventGraphicsPtr)event;
+ ((virConnectDomainEventGraphicsCallback)cb)(conn, dom,
+ graphicsEvent->phase,
+ graphicsEvent->local,
+ graphicsEvent->remote,
+ graphicsEvent->authScheme,
+ graphicsEvent->subject,
+ cbopaque);
+ goto cleanup;
+ }
case VIR_DOMAIN_EVENT_ID_CONTROL_ERROR:
(cb)(conn, dom,
diff --git a/src/conf/domain_event.h b/src/conf/domain_event.h
index 45819dc..c7b0347 100644
--- a/src/conf/domain_event.h
+++ b/src/conf/domain_event.h
@@ -94,18 +94,18 @@ void *virDomainEventIOErrorReasonNewFromObj(virDomainObjPtr obj,
int action,
const char *reason);
-virDomainEventPtr virDomainEventGraphicsNewFromDom(virDomainPtr dom,
- int phase,
- virDomainEventGraphicsAddressPtr
local,
- virDomainEventGraphicsAddressPtr
remote,
- const char *authScheme,
- virDomainEventGraphicsSubjectPtr
subject);
-virDomainEventPtr virDomainEventGraphicsNewFromObj(virDomainObjPtr obj,
- int phase,
- virDomainEventGraphicsAddressPtr
local,
- virDomainEventGraphicsAddressPtr
remote,
- const char *authScheme,
- virDomainEventGraphicsSubjectPtr
subject);
+void *virDomainEventGraphicsNewFromDom(virDomainPtr dom,
+ int phase,
+ virDomainEventGraphicsAddressPtr local,
+ virDomainEventGraphicsAddressPtr remote,
+ const char *authScheme,
+ virDomainEventGraphicsSubjectPtr subject);
+void *virDomainEventGraphicsNewFromObj(virDomainObjPtr obj,
+ int phase,
+ virDomainEventGraphicsAddressPtr local,
+ virDomainEventGraphicsAddressPtr remote,
+ const char *authScheme,
+ virDomainEventGraphicsSubjectPtr subject);
virDomainEventPtr virDomainEventControlErrorNewFromDom(virDomainPtr dom);
virDomainEventPtr virDomainEventControlErrorNewFromObj(virDomainObjPtr obj);
--
1.8.4.2