mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
Create virDomainEventWatchdog to get rid of the huge union
This commit is contained in:
parent
8a29ffcf9a
commit
b044091540
@ -87,10 +87,12 @@ static virClassPtr virObjectEventClass;
|
|||||||
static virClassPtr virDomainEventClass;
|
static virClassPtr virDomainEventClass;
|
||||||
static virClassPtr virDomainEventLifecycleClass;
|
static virClassPtr virDomainEventLifecycleClass;
|
||||||
static virClassPtr virDomainEventRTCChangeClass;
|
static virClassPtr virDomainEventRTCChangeClass;
|
||||||
|
static virClassPtr virDomainEventWatchdogClass;
|
||||||
static void virObjectEventDispose(void *obj);
|
static void virObjectEventDispose(void *obj);
|
||||||
static void virDomainEventDispose(void *obj);
|
static void virDomainEventDispose(void *obj);
|
||||||
static void virDomainEventLifecycleDispose(void *obj);
|
static void virDomainEventLifecycleDispose(void *obj);
|
||||||
static void virDomainEventRTCChangeDispose(void *obj);
|
static void virDomainEventRTCChangeDispose(void *obj);
|
||||||
|
static void virDomainEventWatchdogDispose(void *obj);
|
||||||
|
|
||||||
struct _virObjectEvent {
|
struct _virObjectEvent {
|
||||||
virObject parent;
|
virObject parent;
|
||||||
@ -103,9 +105,6 @@ struct _virDomainEvent {
|
|||||||
virObjectMeta meta;
|
virObjectMeta meta;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
struct {
|
|
||||||
int action;
|
|
||||||
} watchdog;
|
|
||||||
struct {
|
struct {
|
||||||
char *srcPath;
|
char *srcPath;
|
||||||
char *devAlias;
|
char *devAlias;
|
||||||
@ -161,6 +160,14 @@ struct _virDomainEventRTCChange {
|
|||||||
typedef struct _virDomainEventRTCChange virDomainEventRTCChange;
|
typedef struct _virDomainEventRTCChange virDomainEventRTCChange;
|
||||||
typedef virDomainEventRTCChange *virDomainEventRTCChangePtr;
|
typedef virDomainEventRTCChange *virDomainEventRTCChangePtr;
|
||||||
|
|
||||||
|
struct _virDomainEventWatchdog {
|
||||||
|
virDomainEvent parent;
|
||||||
|
|
||||||
|
int action;
|
||||||
|
};
|
||||||
|
typedef struct _virDomainEventWatchdog virDomainEventWatchdog;
|
||||||
|
typedef virDomainEventWatchdog *virDomainEventWatchdogPtr;
|
||||||
|
|
||||||
static int virObjectEventOnceInit(void)
|
static int virObjectEventOnceInit(void)
|
||||||
{
|
{
|
||||||
if (!(virObjectEventClass =
|
if (!(virObjectEventClass =
|
||||||
@ -187,6 +194,12 @@ static int virObjectEventOnceInit(void)
|
|||||||
sizeof(virDomainEventRTCChange),
|
sizeof(virDomainEventRTCChange),
|
||||||
virDomainEventRTCChangeDispose)))
|
virDomainEventRTCChangeDispose)))
|
||||||
return -1;
|
return -1;
|
||||||
|
if (!(virDomainEventWatchdogClass =
|
||||||
|
virClassNew(virDomainEventClass,
|
||||||
|
"virDomainEventWatchdog",
|
||||||
|
sizeof(virDomainEventWatchdog),
|
||||||
|
virDomainEventWatchdogDispose)))
|
||||||
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,6 +292,12 @@ static void virDomainEventRTCChangeDispose(void *obj)
|
|||||||
VIR_DEBUG("obj=%p", event);
|
VIR_DEBUG("obj=%p", event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void virDomainEventWatchdogDispose(void *obj)
|
||||||
|
{
|
||||||
|
virDomainEventWatchdogPtr event = obj;
|
||||||
|
VIR_DEBUG("obj=%p", event);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virObjectEventCallbackListFree:
|
* virObjectEventCallbackListFree:
|
||||||
* @list: event callback list head
|
* @list: event callback list head
|
||||||
@ -912,40 +931,38 @@ virDomainEventPtr virDomainEventRTCChangeNewFromObj(virDomainObjPtr obj,
|
|||||||
return (virDomainEventPtr)ev;
|
return (virDomainEventPtr)ev;
|
||||||
}
|
}
|
||||||
|
|
||||||
virDomainEventPtr virDomainEventWatchdogNewFromDom(virDomainPtr dom,
|
virDomainEventPtr virDomainEventWatchdogNewFromDom(virDomainPtr dom, int action)
|
||||||
int action)
|
|
||||||
{
|
{
|
||||||
virDomainEventPtr ev;
|
virDomainEventWatchdogPtr ev;
|
||||||
|
|
||||||
if (virObjectEventInitialize() < 0)
|
if (virObjectEventInitialize() < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!(ev = virDomainEventNew(virDomainEventClass,
|
if (!(ev = virDomainEventNew(virDomainEventWatchdogClass,
|
||||||
VIR_DOMAIN_EVENT_ID_WATCHDOG,
|
VIR_DOMAIN_EVENT_ID_WATCHDOG,
|
||||||
dom->id, dom->name, dom->uuid)))
|
dom->id, dom->name, dom->uuid)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ev->data.watchdog.action = action;
|
ev->action = action;
|
||||||
|
|
||||||
return ev;
|
return (virDomainEventPtr)ev;
|
||||||
}
|
}
|
||||||
virDomainEventPtr virDomainEventWatchdogNewFromObj(virDomainObjPtr obj,
|
virDomainEventPtr virDomainEventWatchdogNewFromObj(virDomainObjPtr obj, int action)
|
||||||
int action)
|
|
||||||
{
|
{
|
||||||
virDomainEventPtr ev;
|
virDomainEventWatchdogPtr ev;
|
||||||
|
|
||||||
if (virObjectEventInitialize() < 0)
|
if (virObjectEventInitialize() < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!(ev = virDomainEventNew(virDomainEventClass,
|
if (!(ev = virDomainEventNew(virDomainEventWatchdogClass,
|
||||||
VIR_DOMAIN_EVENT_ID_WATCHDOG,
|
VIR_DOMAIN_EVENT_ID_WATCHDOG,
|
||||||
obj->def->id, obj->def->name,
|
obj->def->id, obj->def->name,
|
||||||
obj->def->uuid)))
|
obj->def->uuid)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ev->data.watchdog.action = action;
|
ev->action = action;
|
||||||
|
|
||||||
return ev;
|
return (virDomainEventPtr)ev;
|
||||||
}
|
}
|
||||||
|
|
||||||
static virDomainEventPtr virDomainEventIOErrorNewFromDomImpl(int event,
|
static virDomainEventPtr virDomainEventIOErrorNewFromDomImpl(int event,
|
||||||
@ -1528,10 +1545,15 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
case VIR_DOMAIN_EVENT_ID_WATCHDOG:
|
case VIR_DOMAIN_EVENT_ID_WATCHDOG:
|
||||||
((virConnectDomainEventWatchdogCallback)cb)(conn, dom,
|
{
|
||||||
event->data.watchdog.action,
|
virDomainEventWatchdogPtr watchdogEvent;
|
||||||
cbopaque);
|
|
||||||
goto cleanup;
|
watchdogEvent = (virDomainEventWatchdogPtr)event;
|
||||||
|
((virConnectDomainEventWatchdogCallback)cb)(conn, dom,
|
||||||
|
watchdogEvent->action,
|
||||||
|
cbopaque);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
case VIR_DOMAIN_EVENT_ID_IO_ERROR:
|
case VIR_DOMAIN_EVENT_ID_IO_ERROR:
|
||||||
((virConnectDomainEventIOErrorCallback)cb)(conn, dom,
|
((virConnectDomainEventIOErrorCallback)cb)(conn, dom,
|
||||||
|
Loading…
Reference in New Issue
Block a user