On 11.12.2013 16:28, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The event namespace concept is redundant since the same
information is available by looking at the class hierarchy
of the events.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/conf/domain_event.c | 18 ++++++++++++++++--
src/conf/domain_event.h | 2 ++
src/conf/network_event.c | 22 ++++++++++++++++------
src/conf/network_event.h | 3 +++
src/conf/object_event.c | 28 +++++++++++++++-------------
src/conf/object_event.h | 11 +++--------
src/conf/object_event_private.h | 2 ++
7 files changed, 57 insertions(+), 29 deletions(-)
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index 64035f7..03164dc 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -437,6 +437,7 @@ virDomainEventCallbackListAdd(virConnectPtr conn,
virFreeCallback freecb)
{
return virObjectEventCallbackListAddID(conn, cbList, NULL, NULL, 0,
+ virDomainEventClass,
VIR_DOMAIN_EVENT_ID_LIFECYCLE,
VIR_OBJECT_EVENT_CALLBACK(callback),
opaque, freecb, NULL);
@@ -1366,6 +1367,9 @@ virDomainEventStateRegister(virConnectPtr conn,
{
int ret = -1;
+ if (virDomainEventsInitialize() < 0)
+ return -1;
+
virObjectEventStateLock(state);
if ((state->callbacks->count == 0) &&
@@ -1420,14 +1424,17 @@ virDomainEventStateRegisterID(virConnectPtr conn,
virFreeCallback freecb,
int *callbackID)
{
+ if (virDomainEventsInitialize() < 0)
+ return -1;
+
if (dom)
return virObjectEventStateRegisterID(conn, state, dom->uuid, dom->name,
- dom->id, eventID,
+ dom->id, virDomainEventClass, eventID,
VIR_OBJECT_EVENT_CALLBACK(cb),
opaque, freecb, callbackID);
else
return virObjectEventStateRegisterID(conn, state, NULL, NULL, 0,
- eventID,
+ virDomainEventClass, eventID,
VIR_OBJECT_EVENT_CALLBACK(cb),
opaque, freecb, callbackID);
}
@@ -1468,3 +1475,10 @@ virDomainEventStateDeregister(virConnectPtr conn,
virObjectEventStateUnlock(state);
return ret;
}
+
+
+virClassPtr
+virDomainEventGetBaseClass(void)
+{
+ return virDomainEventClass;
+}
diff --git a/src/conf/domain_event.h b/src/conf/domain_event.h
index 30156ed..5433950 100644
--- a/src/conf/domain_event.h
+++ b/src/conf/domain_event.h
@@ -30,6 +30,8 @@
# include "object_event.h"
# include "domain_conf.h"
+virClassPtr
+virDomainEventGetBaseClass(void);
virObjectEventPtr
virDomainEventLifecycleNew(int id,
diff --git a/src/conf/network_event.c b/src/conf/network_event.c
index b1312b7..3108fea 100644
--- a/src/conf/network_event.c
+++ b/src/conf/network_event.c
@@ -98,7 +98,7 @@ virNetworkEventDispatchDefaultFunc(virConnectPtr conn,
if (!net)
return;
- switch ((virNetworkEventID) (event->eventID &0xFF)) {
+ switch ((virNetworkEventID)event->eventID) {
Honestly, I was never big fan of misusing eventID to carry the namespace
too.
ACK if you fix the crash Cederic pointed out.
Michal