Adds two new private methods to create metadata change events:
- virNetworkEventMetadataChangeNewFromNet()
- virNetworkEventMetadataChangeNewFromObj()
Signed-off-by: K Shiva Kiran <shiva_kr(a)riseup.net>
---
src/conf/network_event.c | 48 ++++++++++++++++++++++++++++++++++++++++
src/conf/network_event.h | 11 +++++++++
src/libvirt_private.syms | 2 ++
3 files changed, 61 insertions(+)
diff --git a/src/conf/network_event.c b/src/conf/network_event.c
index d1b3aa5721..5eb9c3d48f 100644
--- a/src/conf/network_event.c
+++ b/src/conf/network_event.c
@@ -267,3 +267,51 @@ virNetworkEventMetadataChangeDispose(void *obj)
g_free(event->nsuri);
}
+
+
+static virObjectEvent *
+virNetworkEventMetadataChangeNew(const char *name,
+ unsigned char *uuid,
+ int type,
+ const char *nsuri)
+{
+ virNetworkEventMetadataChange *event;
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+
+ if (virNetworkEventsInitialize() < 0)
+ return NULL;
+
+ virUUIDFormat(uuid, uuidstr);
+ if (!(event = virObjectEventNew(virNetworkEventMetadataChangeClass,
+ virNetworkEventDispatchDefaultFunc,
+ VIR_NETWORK_EVENT_ID_METADATA_CHANGE,
+ 0, name, uuid, uuidstr)))
+ return NULL;
+
+ event->type = type;
+ if (nsuri)
+ event->nsuri = g_strdup(nsuri);
+
+ return (virObjectEvent *)event;
+}
+
+
+virObjectEvent *
+virNetworkEventMetadataChangeNewFromObj(virNetworkObj *obj,
+ int type,
+ const char *nsuri)
+{
+ virNetworkDef *def = virNetworkObjGetDef(obj);
+ return virNetworkEventMetadataChangeNew(def->name, def->uuid,
+ type, nsuri);
+}
+
+
+virObjectEvent *
+virNetworkEventMetadataChangeNewFromNet(virNetworkPtr net,
+ int type,
+ const char *nsuri)
+{
+ return virNetworkEventMetadataChangeNew(net->name, net->uuid,
+ type, nsuri);
+}
diff --git a/src/conf/network_event.h b/src/conf/network_event.h
index 4502bfcaef..a91a238fed 100644
--- a/src/conf/network_event.h
+++ b/src/conf/network_event.h
@@ -23,6 +23,7 @@
#include "internal.h"
#include "object_event.h"
+#include "virnetworkobj.h"
int
virNetworkEventStateRegisterID(virConnectPtr conn,
@@ -53,3 +54,13 @@ virNetworkEventLifecycleNew(const char *name,
const unsigned char *uuid,
int type,
int detail);
+
+virObjectEvent *
+virNetworkEventMetadataChangeNewFromObj(virNetworkObj *obj,
+ int type,
+ const char *nsuri);
+
+virObjectEvent *
+virNetworkEventMetadataChangeNewFromNet(virNetworkPtr net,
+ int type,
+ const char *nsuri);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 1e3e407097..7a59828af0 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -861,6 +861,8 @@ virPortGroupFindByName;
# conf/network_event.h
virNetworkEventLifecycleNew;
+virNetworkEventMetadataChangeNewFromNet;
+virNetworkEventMetadataChangeNewFromObj;
virNetworkEventStateRegisterID;
--
2.42.0