mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
Create virDomainEventDeviceRemoved and remove the huge union
RIP virDomainEvent union. All data are now stored in each virObjectEvent subclass.
This commit is contained in:
parent
d9c6ba31a5
commit
d4d02b206a
@ -94,6 +94,7 @@ static virClassPtr virDomainEventBlockJobClass;
|
|||||||
static virClassPtr virDomainEventDiskChangeClass;
|
static virClassPtr virDomainEventDiskChangeClass;
|
||||||
static virClassPtr virDomainEventTrayChangeClass;
|
static virClassPtr virDomainEventTrayChangeClass;
|
||||||
static virClassPtr virDomainEventBalloonChangeClass;
|
static virClassPtr virDomainEventBalloonChangeClass;
|
||||||
|
static virClassPtr virDomainEventDeviceRemovedClass;
|
||||||
|
|
||||||
static void virObjectEventDispose(void *obj);
|
static void virObjectEventDispose(void *obj);
|
||||||
static void virDomainEventDispose(void *obj);
|
static void virDomainEventDispose(void *obj);
|
||||||
@ -106,6 +107,7 @@ static void virDomainEventBlockJobDispose(void *obj);
|
|||||||
static void virDomainEventDiskChangeDispose(void *obj);
|
static void virDomainEventDiskChangeDispose(void *obj);
|
||||||
static void virDomainEventTrayChangeDispose(void *obj);
|
static void virDomainEventTrayChangeDispose(void *obj);
|
||||||
static void virDomainEventBalloonChangeDispose(void *obj);
|
static void virDomainEventBalloonChangeDispose(void *obj);
|
||||||
|
static void virDomainEventDeviceRemovedDispose(void *obj);
|
||||||
|
|
||||||
struct _virObjectEvent {
|
struct _virObjectEvent {
|
||||||
virObject parent;
|
virObject parent;
|
||||||
@ -116,12 +118,6 @@ struct _virDomainEvent {
|
|||||||
virObjectEvent parent;
|
virObjectEvent parent;
|
||||||
|
|
||||||
virObjectMeta meta;
|
virObjectMeta meta;
|
||||||
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
char *devAlias;
|
|
||||||
} deviceRemoved;
|
|
||||||
} data;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _virDomainEventLifecycle {
|
struct _virDomainEventLifecycle {
|
||||||
@ -211,6 +207,14 @@ struct _virDomainEventBalloonChange {
|
|||||||
typedef struct _virDomainEventBalloonChange virDomainEventBalloonChange;
|
typedef struct _virDomainEventBalloonChange virDomainEventBalloonChange;
|
||||||
typedef virDomainEventBalloonChange *virDomainEventBalloonChangePtr;
|
typedef virDomainEventBalloonChange *virDomainEventBalloonChangePtr;
|
||||||
|
|
||||||
|
struct _virDomainEventDeviceRemoved {
|
||||||
|
virDomainEvent parent;
|
||||||
|
|
||||||
|
char *devAlias;
|
||||||
|
};
|
||||||
|
typedef struct _virDomainEventDeviceRemoved virDomainEventDeviceRemoved;
|
||||||
|
typedef virDomainEventDeviceRemoved *virDomainEventDeviceRemovedPtr;
|
||||||
|
|
||||||
|
|
||||||
static int virObjectEventOnceInit(void)
|
static int virObjectEventOnceInit(void)
|
||||||
{
|
{
|
||||||
@ -280,6 +284,12 @@ static int virObjectEventOnceInit(void)
|
|||||||
sizeof(virDomainEventBalloonChange),
|
sizeof(virDomainEventBalloonChange),
|
||||||
virDomainEventBalloonChangeDispose)))
|
virDomainEventBalloonChangeDispose)))
|
||||||
return -1;
|
return -1;
|
||||||
|
if (!(virDomainEventDeviceRemovedClass =
|
||||||
|
virClassNew(virDomainEventClass,
|
||||||
|
"virDomainEventDeviceRemoved",
|
||||||
|
sizeof(virDomainEventDeviceRemoved),
|
||||||
|
virDomainEventDeviceRemovedDispose)))
|
||||||
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,13 +320,6 @@ static void virDomainEventDispose(void *obj)
|
|||||||
|
|
||||||
VIR_DEBUG("obj=%p", event);
|
VIR_DEBUG("obj=%p", event);
|
||||||
|
|
||||||
switch (virObjectEventGetEventID(event)) {
|
|
||||||
|
|
||||||
case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED:
|
|
||||||
VIR_FREE(event->data.deviceRemoved.devAlias);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
VIR_FREE(event->meta.name);
|
VIR_FREE(event->meta.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,6 +409,14 @@ static void virDomainEventBalloonChangeDispose(void *obj)
|
|||||||
VIR_DEBUG("obj=%p", event);
|
VIR_DEBUG("obj=%p", event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void virDomainEventDeviceRemovedDispose(void *obj)
|
||||||
|
{
|
||||||
|
virDomainEventDeviceRemovedPtr event = obj;
|
||||||
|
VIR_DEBUG("obj=%p", event);
|
||||||
|
|
||||||
|
VIR_FREE(event->devAlias);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virObjectEventCallbackListFree:
|
* virObjectEventCallbackListFree:
|
||||||
* @list: event callback list head
|
* @list: event callback list head
|
||||||
@ -1537,43 +1548,40 @@ virDomainEventPtr virDomainEventBalloonChangeNewFromObj(virDomainObjPtr obj,
|
|||||||
return (virDomainEventPtr)ev;
|
return (virDomainEventPtr)ev;
|
||||||
}
|
}
|
||||||
|
|
||||||
static virDomainEventPtr
|
static virDomainEventPtr virDomainEventDeviceRemovedNew(int id,
|
||||||
virDomainEventDeviceRemovedNew(int id,
|
const char *name,
|
||||||
const char *name,
|
unsigned char *uuid,
|
||||||
unsigned char *uuid,
|
const char *devAlias)
|
||||||
const char *devAlias)
|
|
||||||
{
|
{
|
||||||
virDomainEventPtr ev;
|
virDomainEventDeviceRemovedPtr ev;
|
||||||
|
|
||||||
if (virObjectEventInitialize() < 0)
|
if (virObjectEventInitialize() < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!(ev = virDomainEventNew(virDomainEventClass,
|
if (!(ev = virDomainEventNew(virDomainEventDeviceRemovedClass,
|
||||||
VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED,
|
VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED,
|
||||||
id, name, uuid)))
|
id, name, uuid)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (VIR_STRDUP(ev->data.deviceRemoved.devAlias, devAlias) < 0)
|
if (VIR_STRDUP(ev->devAlias, devAlias) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
return ev;
|
return (virDomainEventPtr)ev;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
virObjectUnref(ev);
|
virObjectUnref(ev);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
virDomainEventPtr
|
virDomainEventPtr virDomainEventDeviceRemovedNewFromObj(virDomainObjPtr obj,
|
||||||
virDomainEventDeviceRemovedNewFromObj(virDomainObjPtr obj,
|
const char *devAlias)
|
||||||
const char *devAlias)
|
|
||||||
{
|
{
|
||||||
return virDomainEventDeviceRemovedNew(obj->def->id, obj->def->name,
|
return virDomainEventDeviceRemovedNew(obj->def->id, obj->def->name,
|
||||||
obj->def->uuid, devAlias);
|
obj->def->uuid, devAlias);
|
||||||
}
|
}
|
||||||
|
|
||||||
virDomainEventPtr
|
virDomainEventPtr virDomainEventDeviceRemovedNewFromDom(virDomainPtr dom,
|
||||||
virDomainEventDeviceRemovedNewFromDom(virDomainPtr dom,
|
const char *devAlias)
|
||||||
const char *devAlias)
|
|
||||||
{
|
{
|
||||||
return virDomainEventDeviceRemovedNew(dom->id, dom->name, dom->uuid,
|
return virDomainEventDeviceRemovedNew(dom->id, dom->name, dom->uuid,
|
||||||
devAlias);
|
devAlias);
|
||||||
@ -1777,10 +1785,15 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED:
|
case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED:
|
||||||
((virConnectDomainEventDeviceRemovedCallback)cb)(conn, dom,
|
{
|
||||||
event->data.deviceRemoved.devAlias,
|
virDomainEventDeviceRemovedPtr deviceRemovedEvent;
|
||||||
cbopaque);
|
|
||||||
goto cleanup;
|
deviceRemovedEvent = (virDomainEventDeviceRemovedPtr)event;
|
||||||
|
((virConnectDomainEventDeviceRemovedCallback)cb)(conn, dom,
|
||||||
|
deviceRemovedEvent->devAlias,
|
||||||
|
cbopaque);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
case VIR_DOMAIN_EVENT_ID_LAST:
|
case VIR_DOMAIN_EVENT_ID_LAST:
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user