qemuMonitorJSONSetMigrationParams: Take double pointer for @params qemuMonitorJSONAddObject: Take double pointer for @props :qemuMonitorJSONMakeCommandInternal: Clear @arguments when stolen qemuMonitorAddObject: Fix semantics of @alias qemuMonitorAddObject: Refactor cleanup util: json: Replace virJSONValueObjectSteal by virJSONValueObjectRemoveKey qemu: command: Generate commandline of 'masterKey0' secret via JSON qemu: command: Generate commandline of 'sev0' sev-guest object via JSON qemu: command: Generate commandline of iothread objects JSON qemu: capabilities: Introduce QEMU_CAPS_OBJECT_QAPIFIED qemu: monitor: Make wrapping of 'props' of 'object-add' optional qemuMonitorCreateObjectPropsWrap: Open-code in qemuBuildMemoryBackendProps qemu: monitor: Don't add 'props' wrapper if qemu has QEMU_CAPS_OBJECT_QAPIFIED qemu: command: Use JSON for QAPIfied -object directly tests: qemuxml2argv: Validate generation of JSON props for object-add qemu: capabilities: Enable detection of QEMU_CAPS_OBJECT_QAPIFIED Signed-off-by: yezengruan <yezengruan@huawei.com> (cherry picked from commit da25da87c49d1b576b48fd58614ff43833a04f37)
66 lines
2.0 KiB
Diff
66 lines
2.0 KiB
Diff
From bca866e875d4f1a4f02f792201cf5e46cdafe4f5 Mon Sep 17 00:00:00 2001
|
|
From: Peter Krempa <pkrempa@redhat.com>
|
|
Date: Mon, 30 Nov 2020 14:59:38 +0100
|
|
Subject: [PATCH 06/16] util: json: Replace virJSONValueObjectSteal by
|
|
virJSONValueObjectRemoveKey
|
|
|
|
virJSONValueObjectRemoveKey can be used as direct replacement. Fix the
|
|
one caller and remove the duplicate function.
|
|
|
|
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
---
|
|
src/util/virjson.c | 29 ++++-------------------------
|
|
1 file changed, 4 insertions(+), 25 deletions(-)
|
|
|
|
diff --git a/src/util/virjson.c b/src/util/virjson.c
|
|
index 6921eccb60..6626e78255 100644
|
|
--- a/src/util/virjson.c
|
|
+++ b/src/util/virjson.c
|
|
@@ -888,30 +888,6 @@ virJSONValueObjectGet(virJSONValuePtr object,
|
|
}
|
|
|
|
|
|
-static virJSONValuePtr
|
|
-virJSONValueObjectSteal(virJSONValuePtr object,
|
|
- const char *key)
|
|
-{
|
|
- size_t i;
|
|
- virJSONValuePtr obj = NULL;
|
|
-
|
|
- if (object->type != VIR_JSON_TYPE_OBJECT)
|
|
- return NULL;
|
|
-
|
|
- for (i = 0; i < object->data.object.npairs; i++) {
|
|
- if (STREQ(object->data.object.pairs[i].key, key)) {
|
|
- obj = g_steal_pointer(&object->data.object.pairs[i].value);
|
|
- VIR_FREE(object->data.object.pairs[i].key);
|
|
- VIR_DELETE_ELEMENT(object->data.object.pairs, i,
|
|
- object->data.object.npairs);
|
|
- break;
|
|
- }
|
|
- }
|
|
-
|
|
- return obj;
|
|
-}
|
|
-
|
|
-
|
|
/* Return the value associated with KEY within OBJECT, but return NULL
|
|
* if the key is missing or if value is not the correct TYPE. */
|
|
virJSONValuePtr
|
|
@@ -934,7 +910,10 @@ virJSONValueObjectStealByType(virJSONValuePtr object,
|
|
const char *key,
|
|
virJSONType type)
|
|
{
|
|
- virJSONValuePtr value = virJSONValueObjectSteal(object, key);
|
|
+ virJSONValuePtr value;
|
|
+
|
|
+ if (virJSONValueObjectRemoveKey(object, key, &value) <= 0)
|
|
+ return NULL;
|
|
|
|
if (value && value->type == type)
|
|
return value;
|
|
--
|
|
2.27.0
|
|
|