On 9/3/23 16:58, K Shiva Kiran wrote:
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);
This check if effectively a dead code. The first thing g_strdup() does
is check for NULL. There are a few places in our code where this pattern
occurs, I'll be sending a patch that fixes them.
+
+ return (virObjectEvent *)event;
+}
+
Michal