From: Stefan Kober Date: Thu, 4 Sep 2025 12:10:32 +0000 (+0200) Subject: ch: add virCHMonitorBuildKeyValueJson X-Git-Tag: v11.8.0-rc1~75 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4ba796ab74deda9f46230ec97e1ad895a01eff0d;p=thirdparty%2Flibvirt.git 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 --- 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;