const unsigned char *uuid)
{
virDomainEventPtr event;
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
if (virDomainEventsInitialize() < 0)
return NULL;
return NULL;
}
+ /* We use uuid for matching key. We ignore 'name' because
+ * Xen sometimes renames guests during migration, thus
+ * 'uuid' is the only truly reliable key we can use. */
+ virUUIDFormat(uuid, uuidstr);
if (!(event = virObjectEventNew(klass,
virDomainEventDispatchDefaultFunc,
eventID,
- id, name, uuid)))
+ id, name, uuid, uuidstr)))
return NULL;
return (virObjectEventPtr)event;
const char *details)
{
virDomainQemuMonitorEventPtr ev;
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
if (virDomainEventsInitialize() < 0)
return NULL;
+ virUUIDFormat(uuid, uuidstr);
if (!(ev = virObjectEventNew(virDomainQemuMonitorEventClass,
virDomainQemuMonitorEventDispatchFunc,
- 0, id, name, uuid)))
+ 0, id, name, uuid, uuidstr)))
return NULL;
/* event is mandatory, details are optional */
int detail)
{
virNetworkEventLifecyclePtr event;
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
if (virNetworkEventsInitialize() < 0)
return NULL;
+ virUUIDFormat(uuid, uuidstr);
if (!(event = virObjectEventNew(virNetworkEventLifecycleClass,
virNetworkEventDispatchDefaultFunc,
VIR_NETWORK_EVENT_ID_LIFECYCLE,
- 0, name, uuid)))
+ 0, name, uuid, uuidstr)))
return NULL;
event->type = type;
VIR_DEBUG("obj=%p", event);
VIR_FREE(event->meta.name);
+ VIR_FREE(event->meta.key);
}
/**
* @id: id of the object the event describes, or 0
* @name: name of the object the event describes
* @uuid: uuid of the object the event describes
+ * @key: key for per-object filtering
*
* Create a new event, with the information common to all events.
*/
int eventID,
int id,
const char *name,
- const unsigned char *uuid)
+ const unsigned char *uuid,
+ const char *key)
{
virObjectEventPtr event;
VIR_FREE(event);
return NULL;
}
+ if (VIR_STRDUP(event->meta.key, key) < 0) {
+ VIR_FREE(event->meta.name);
+ VIR_FREE(event);
+ return NULL;
+ }
event->meta.id = id;
memcpy(event->meta.uuid, uuid, VIR_UUID_BUFLEN);
if (cb->filter && !(cb->filter)(cb->conn, event, cb->filter_opaque))
return false;
- if (cb->uuid_filter) {
- /* Deliberately ignoring 'id' for matching, since that
- * will cause problems when a domain switches between
- * running & shutoff states & ignoring 'name' since
- * Xen sometimes renames guests during migration, thus
- * leaving 'uuid' as the only truly reliable ID we can use. */
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virUUIDFormat(event->meta.uuid, uuidstr);
-
- return STREQ(uuidstr, cb->uuid);
- }
+ if (cb->uuid_filter)
+ return STREQ(event->meta.key, cb->uuid);
return true;
}
int id;
char *name;
unsigned char uuid[VIR_UUID_BUFLEN];
+ char *key;
};
typedef struct _virObjectMeta virObjectMeta;
typedef virObjectMeta *virObjectMetaPtr;
int eventID,
int id,
const char *name,
- const unsigned char *uuid)
+ const unsigned char *uuid,
+ const char *key)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5)
- ATTRIBUTE_NONNULL(6);
+ ATTRIBUTE_NONNULL(6) ATTRIBUTE_NONNULL(7);
#endif
int detail)
{
virStoragePoolEventLifecyclePtr event;
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
if (virStoragePoolEventsInitialize() < 0)
return NULL;
+ virUUIDFormat(uuid, uuidstr);
if (!(event = virObjectEventNew(virStoragePoolEventLifecycleClass,
virStoragePoolEventDispatchDefaultFunc,
VIR_STORAGE_POOL_EVENT_ID_LIFECYCLE,
- 0, name, uuid)))
+ 0, name, uuid, uuidstr)))
return NULL;
event->type = type;
const unsigned char *uuid)
{
virStoragePoolEventRefreshPtr event;
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
if (virStoragePoolEventsInitialize() < 0)
return NULL;
+ virUUIDFormat(uuid, uuidstr);
if (!(event = virObjectEventNew(virStoragePoolEventRefreshClass,
virStoragePoolEventDispatchDefaultFunc,
VIR_STORAGE_POOL_EVENT_ID_REFRESH,
- 0, name, uuid)))
+ 0, name, uuid, uuidstr)))
return NULL;
return (virObjectEventPtr)event;