From 4ba796ab74deda9f46230ec97e1ad895a01eff0d Mon Sep 17 00:00:00 2001 From: Stefan Kober Date: Thu, 4 Sep 2025 14:10:32 +0200 Subject: [PATCH] ch: add virCHMonitorBuildKeyValueJson On-behalf-of: SAP stefan.kober@sap.com Signed-off-by: Stefan Kober Signed-off-by: Michal Privoznik Reviewed-by: Michal Privoznik --- src/ch/ch_monitor.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 2a37acd56f..3389e2ad0b 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -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; -- 2.47.3