]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
ch: add virCHMonitorBuildKeyValueJson
authorStefan Kober <stefan.kober@cyberus-technology.de>
Thu, 4 Sep 2025 12:10:32 +0000 (14:10 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 8 Sep 2025 14:40:08 +0000 (16:40 +0200)
On-behalf-of: SAP stefan.kober@sap.com
Signed-off-by: Stefan Kober <stefan.kober@cyberus-technology.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/ch/ch_monitor.c

index 2a37acd56f77d8c39ff29b9cc5fdf40657d18090..3389e2ad0b7b86ca07f53c7aef00e01d107c9dd4 100644 (file)
@@ -587,15 +587,24 @@ virCHMonitorBuildVMJson(virCHDriver *driver, virDomainDef *vmdef,
     return 0;
 }
 
+static virJSONValue*
+virCHMonitorBuildKeyValueJson(const char *key,
+                              const char *value)
+{
+    g_autoptr(virJSONValue) content = virJSONValueNewObject();
+
+    if (virJSONValueObjectAppendString(content, key, value) < 0)
+        return NULL;
+
+    return g_steal_pointer(&content);
+}
+
 static int
 virCHMonitorBuildKeyValueStringJson(char **jsonstr,
                                     const char *key,
                                     const char *value)
 {
-    g_autoptr(virJSONValue) content = virJSONValueNewObject();
-
-    if (virJSONValueObjectAppendString(content, key, value) < 0)
-        return -1;
+    g_autoptr(virJSONValue) content = virCHMonitorBuildKeyValueJson(key, value);
 
     if (!(*jsonstr = virJSONValueToString(content, false)))
         return -1;