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

Renamed virDomainMeta to virObjectMeta

The metadata struct will hold the unique identifiers for
any type of object, though not all fields will be used
for all types.
上级 f95b1921
...@@ -32,13 +32,13 @@ ...@@ -32,13 +32,13 @@
#define VIR_FROM_THIS VIR_FROM_NONE #define VIR_FROM_THIS VIR_FROM_NONE
struct _virDomainMeta { struct _virObjectMeta {
int id; int id;
char *name; char *name;
unsigned char uuid[VIR_UUID_BUFLEN]; unsigned char uuid[VIR_UUID_BUFLEN];
}; };
typedef struct _virDomainMeta virDomainMeta; typedef struct _virObjectMeta virObjectMeta;
typedef virDomainMeta *virDomainMetaPtr; typedef virObjectMeta *virObjectMetaPtr;
struct _virDomainEventCallbackList { struct _virDomainEventCallbackList {
unsigned int nextID; unsigned int nextID;
...@@ -67,7 +67,7 @@ struct _virObjectEventCallback { ...@@ -67,7 +67,7 @@ struct _virObjectEventCallback {
int callbackID; int callbackID;
int eventID; int eventID;
virConnectPtr conn; virConnectPtr conn;
virDomainMetaPtr dom; virObjectMetaPtr meta;
virConnectDomainEventGenericCallback cb; virConnectDomainEventGenericCallback cb;
void *opaque; void *opaque;
virFreeCallback freecb; virFreeCallback freecb;
...@@ -77,7 +77,7 @@ struct _virObjectEventCallback { ...@@ -77,7 +77,7 @@ struct _virObjectEventCallback {
struct _virDomainEvent { struct _virDomainEvent {
int eventID; int eventID;
virDomainMeta dom; virObjectMeta meta;
union { union {
struct { struct {
...@@ -369,10 +369,10 @@ virDomainEventCallbackListAddID(virConnectPtr conn, ...@@ -369,10 +369,10 @@ virDomainEventCallbackListAddID(virConnectPtr conn,
if (cbList->callbacks[i]->cb == VIR_DOMAIN_EVENT_CALLBACK(callback) && if (cbList->callbacks[i]->cb == VIR_DOMAIN_EVENT_CALLBACK(callback) &&
cbList->callbacks[i]->eventID == eventID && cbList->callbacks[i]->eventID == eventID &&
cbList->callbacks[i]->conn == conn && cbList->callbacks[i]->conn == conn &&
((dom && cbList->callbacks[i]->dom && ((dom && cbList->callbacks[i]->meta &&
memcmp(cbList->callbacks[i]->dom->uuid, memcmp(cbList->callbacks[i]->meta->uuid,
dom->uuid, VIR_UUID_BUFLEN) == 0) || dom->uuid, VIR_UUID_BUFLEN) == 0) ||
(!dom && !cbList->callbacks[i]->dom))) { (!dom && !cbList->callbacks[i]->meta))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("event callback already tracked")); _("event callback already tracked"));
return -1; return -1;
...@@ -388,12 +388,12 @@ virDomainEventCallbackListAddID(virConnectPtr conn, ...@@ -388,12 +388,12 @@ virDomainEventCallbackListAddID(virConnectPtr conn,
event->freecb = freecb; event->freecb = freecb;
if (dom) { if (dom) {
if (VIR_ALLOC(event->dom) < 0) if (VIR_ALLOC(event->meta) < 0)
goto error; goto error;
if (VIR_STRDUP(event->dom->name, dom->name) < 0) if (VIR_STRDUP(event->meta->name, dom->name) < 0)
goto error; goto error;
memcpy(event->dom->uuid, dom->uuid, VIR_UUID_BUFLEN); memcpy(event->meta->uuid, dom->uuid, VIR_UUID_BUFLEN);
event->dom->id = dom->id; event->meta->id = dom->id;
} }
/* Make space on list */ /* Make space on list */
...@@ -421,9 +421,9 @@ virDomainEventCallbackListAddID(virConnectPtr conn, ...@@ -421,9 +421,9 @@ virDomainEventCallbackListAddID(virConnectPtr conn,
error: error:
if (event) { if (event) {
if (event->dom) if (event->meta)
VIR_FREE(event->dom->name); VIR_FREE(event->meta->name);
VIR_FREE(event->dom); VIR_FREE(event->meta);
} }
VIR_FREE(event); VIR_FREE(event);
return -1; return -1;
...@@ -526,7 +526,7 @@ void virDomainEventFree(virDomainEventPtr event) ...@@ -526,7 +526,7 @@ void virDomainEventFree(virDomainEventPtr event)
break; break;
} }
VIR_FREE(event->dom.name); VIR_FREE(event->meta.name);
VIR_FREE(event); VIR_FREE(event);
} }
...@@ -664,12 +664,12 @@ static virDomainEventPtr virDomainEventNewInternal(int eventID, ...@@ -664,12 +664,12 @@ static virDomainEventPtr virDomainEventNewInternal(int eventID,
return NULL; return NULL;
event->eventID = eventID; event->eventID = eventID;
if (VIR_STRDUP(event->dom.name, name) < 0) { if (VIR_STRDUP(event->meta.name, name) < 0) {
VIR_FREE(event); VIR_FREE(event);
return NULL; return NULL;
} }
event->dom.id = id; event->meta.id = id;
memcpy(event->dom.uuid, uuid, VIR_UUID_BUFLEN); memcpy(event->meta.uuid, uuid, VIR_UUID_BUFLEN);
return event; return event;
} }
...@@ -1244,10 +1244,10 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn, ...@@ -1244,10 +1244,10 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn,
void *cbopaque, void *cbopaque,
void *opaque ATTRIBUTE_UNUSED) void *opaque ATTRIBUTE_UNUSED)
{ {
virDomainPtr dom = virGetDomain(conn, event->dom.name, event->dom.uuid); virDomainPtr dom = virGetDomain(conn, event->meta.name, event->meta.uuid);
if (!dom) if (!dom)
return; return;
dom->id = event->dom.id; dom->id = event->meta.id;
switch ((virDomainEventID) event->eventID) { switch ((virDomainEventID) event->eventID) {
case VIR_DOMAIN_EVENT_ID_LIFECYCLE: case VIR_DOMAIN_EVENT_ID_LIFECYCLE:
...@@ -1375,14 +1375,14 @@ static int virDomainEventDispatchMatchCallback(virDomainEventPtr event, ...@@ -1375,14 +1375,14 @@ static int virDomainEventDispatchMatchCallback(virDomainEventPtr event,
if (cb->eventID != event->eventID) if (cb->eventID != event->eventID)
return 0; return 0;
if (cb->dom) { if (cb->meta) {
/* Deliberately ignoring 'id' for matching, since that /* Deliberately ignoring 'id' for matching, since that
* will cause problems when a domain switches between * will cause problems when a domain switches between
* running & shutoff states & ignoring 'name' since * running & shutoff states & ignoring 'name' since
* Xen sometimes renames guests during migration, thus * Xen sometimes renames guests during migration, thus
* leaving 'uuid' as the only truly reliable ID we can use*/ * leaving 'uuid' as the only truly reliable ID we can use*/
if (memcmp(event->dom.uuid, cb->dom->uuid, VIR_UUID_BUFLEN) == 0) if (memcmp(event->meta.uuid, cb->meta->uuid, VIR_UUID_BUFLEN) == 0)
return 1; return 1;
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册