[PATCH v3 10/13] ch: add virCHMonitorBuildKeyValueJson

Stefan Kober posted 13 patches 3 days, 11 hours ago
[PATCH v3 10/13] ch: add virCHMonitorBuildKeyValueJson
Posted by Stefan Kober 3 days, 11 hours ago
On-behalf-of: SAP stefan.kober@sap.com
Signed-off-by: Stefan Kober <stefan.kober@cyberus-technology.de>
---
 src/ch/ch_monitor.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c
index 710ba06d2d..6ed78c09c7 100644
--- a/src/ch/ch_monitor.c
+++ b/src/ch/ch_monitor.c
@@ -584,15 +584,25 @@ 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;
-- 
2.50.1