Each unique event ID will thus be composed by 1 byte for the namespace and 1 byte for a namespace-specific ID. The namespace for domain event needs to be 0 for compatibility reasons. --- include/libvirt/libvirt.h.in | 8 ++++++++ src/conf/domain_event.c | 10 ++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 5aad75c..25ab777 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -4961,6 +4961,14 @@ typedef enum { } virDomainEventID; +/** Event IDs are computed in the following way: + virEventNamespaceID << 8 + vir*EventId + */ +typedef enum { + VIR_EVENT_NAMESPACE_DOMAIN = 0, /* 0 to keep value of virDomainEventId unchanged */ +} virEventNamespaceID; + + /* Use VIR_DOMAIN_EVENT_CALLBACK() to cast the 'cb' parameter */ int virConnectDomainEventRegisterAny(virConnectPtr conn, virDomainPtr dom, /* Optional, to filter */ diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c index d4ecc23..d78f3ea 100644 --- a/src/conf/domain_event.c +++ b/src/conf/domain_event.c @@ -1844,11 +1844,17 @@ virObjectEventStateDispatchFunc(virConnectPtr conn, void *opaque) { virObjectEventStatePtr state = opaque; + virEventNamespaceID namespace = (event->eventID & 0xFF00) >> 8; /* Drop the lock whle dispatching, for sake of re-entrancy */ virObjectEventStateUnlock(state); - virDomainEventDispatchDefaultFunc(conn, event, - VIR_DOMAIN_EVENT_CALLBACK(cb), cbopaque, NULL); + switch (namespace) + { + case VIR_EVENT_NAMESPACE_DOMAIN: + virDomainEventDispatchDefaultFunc(conn, event, + VIR_DOMAIN_EVENT_CALLBACK(cb), cbopaque, NULL); + break; + } virObjectEventStateLock(state); } -- 1.8.4.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list