提交 8a29ffcf 编写于 作者: C Cédric Bosdonnat 提交者: Daniel P. Berrange

Create virDomainEventRTCChange to get rid of the huge union

上级 2c0008cc
......@@ -86,9 +86,11 @@ struct _virObjectEventCallback {
static virClassPtr virObjectEventClass;
static virClassPtr virDomainEventClass;
static virClassPtr virDomainEventLifecycleClass;
static virClassPtr virDomainEventRTCChangeClass;
static void virObjectEventDispose(void *obj);
static void virDomainEventDispose(void *obj);
static void virDomainEventLifecycleDispose(void *obj);
static void virDomainEventRTCChangeDispose(void *obj);
struct _virObjectEvent {
virObject parent;
......@@ -101,9 +103,6 @@ struct _virDomainEvent {
virObjectMeta meta;
union {
struct {
long long offset;
} rtcChange;
struct {
int action;
} watchdog;
......@@ -154,6 +153,13 @@ struct _virDomainEventLifecycle {
typedef struct _virDomainEventLifecycle virDomainEventLifecycle;
typedef virDomainEventLifecycle *virDomainEventLifecyclePtr;
struct _virDomainEventRTCChange {
virDomainEvent parent;
long long offset;
};
typedef struct _virDomainEventRTCChange virDomainEventRTCChange;
typedef virDomainEventRTCChange *virDomainEventRTCChangePtr;
static int virObjectEventOnceInit(void)
{
......@@ -175,6 +181,12 @@ static int virObjectEventOnceInit(void)
sizeof(virDomainEventLifecycle),
virDomainEventLifecycleDispose)))
return -1;
if (!(virDomainEventRTCChangeClass =
virClassNew(virDomainEventClass,
"virDomainEventRTCChange",
sizeof(virDomainEventRTCChange),
virDomainEventRTCChangeDispose)))
return -1;
return 0;
}
......@@ -261,6 +273,12 @@ static void virDomainEventLifecycleDispose(void *obj)
VIR_DEBUG("obj=%p", event);
}
static void virDomainEventRTCChangeDispose(void *obj)
{
virDomainEventRTCChangePtr event = obj;
VIR_DEBUG("obj=%p", event);
}
/**
* virObjectEventCallbackListFree:
* @list: event callback list head
......@@ -861,37 +879,37 @@ virDomainEventPtr virDomainEventRebootNewFromObj(virDomainObjPtr obj)
virDomainEventPtr virDomainEventRTCChangeNewFromDom(virDomainPtr dom,
long long offset)
{
virDomainEventPtr ev;
virDomainEventRTCChangePtr ev;
if (virObjectEventInitialize() < 0)
return NULL;
if (!(ev = virDomainEventNew(virDomainEventClass,
if (!(ev = virDomainEventNew(virDomainEventRTCChangeClass,
VIR_DOMAIN_EVENT_ID_RTC_CHANGE,
dom->id, dom->name, dom->uuid)))
return NULL;
ev->data.rtcChange.offset = offset;
ev->offset = offset;
return ev;
return (virDomainEventPtr)ev;
}
virDomainEventPtr virDomainEventRTCChangeNewFromObj(virDomainObjPtr obj,
long long offset)
{
virDomainEventPtr ev;
virDomainEventRTCChangePtr ev;
if (virObjectEventInitialize() < 0)
return NULL;
if (!(ev = virDomainEventNew(virDomainEventClass,
if (!(ev = virDomainEventNew(virDomainEventRTCChangeClass,
VIR_DOMAIN_EVENT_ID_RTC_CHANGE,
obj->def->id, obj->def->name,
obj->def->uuid)))
return NULL;
ev->data.rtcChange.offset = offset;
ev->offset = offset;
return ev;
return (virDomainEventPtr)ev;
}
virDomainEventPtr virDomainEventWatchdogNewFromDom(virDomainPtr dom,
......@@ -1499,10 +1517,15 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn,
goto cleanup;
case VIR_DOMAIN_EVENT_ID_RTC_CHANGE:
{
virDomainEventRTCChangePtr rtcChangeEvent;
rtcChangeEvent = (virDomainEventRTCChangePtr)event;
((virConnectDomainEventRTCChangeCallback)cb)(conn, dom,
event->data.rtcChange.offset,
rtcChangeEvent->offset,
cbopaque);
goto cleanup;
}
case VIR_DOMAIN_EVENT_ID_WATCHDOG:
((virConnectDomainEventWatchdogCallback)cb)(conn, dom,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册