summaryrefslogtreecommitdiff
path: root/src/util/virqemu.c
diff options
context:
space:
mode:
authorPeter Krempa <pkrempa@redhat.com>2020-11-30 16:03:57 +0100
committerPeter Krempa <pkrempa@redhat.com>2021-03-23 14:06:31 +0100
commite0eeb2cc67d960a48937f99c659fb63dbd4049dc (patch)
tree7adf9a4dce50ea98235513598d9a749fd27763c8 /src/util/virqemu.c
parent3d50ecc9bb2be88a56f00cd60335215b0d1132c2 (diff)
downloadlibvirt-e0eeb2cc67d960a48937f99c659fb63dbd4049dc.tar.gz
qemu: monitor: Make wrapping of 'props' of 'object-add' optional
Construct the JSON object which is used for object-add without the 'props' wrapper and add the wrapper only in the monitor code. This simplifies the JSON->commandline generator in the first place and also prepares for upcoming qemu where 'props' will be removed. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Diffstat (limited to 'src/util/virqemu.c')
-rw-r--r--src/util/virqemu.c34
1 files changed, 10 insertions, 24 deletions
diff --git a/src/util/virqemu.c b/src/util/virqemu.c
index 57ee42dd16..a206da1852 100644
--- a/src/util/virqemu.c
+++ b/src/util/virqemu.c
@@ -303,12 +303,13 @@ virQEMUBuildNetdevCommandlineFromJSON(virJSONValuePtr props,
}
-static int
-virQEMUBuildObjectCommandlineFromJSONInternal(virBufferPtr buf,
- const char *type,
- const char *alias,
- virJSONValuePtr props)
+int
+virQEMUBuildObjectCommandlineFromJSON(virBufferPtr buf,
+ virJSONValuePtr objprops)
{
+ const char *type = virJSONValueObjectGetString(objprops, "qom-type");
+ const char *alias = virJSONValueObjectGetString(objprops, "id");
+
if (!type || !alias) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("missing 'type'(%s) or 'alias'(%s) field of QOM 'object'"),
@@ -316,31 +317,16 @@ virQEMUBuildObjectCommandlineFromJSONInternal(virBufferPtr buf,
return -1;
}
- virBufferAsprintf(buf, "%s,id=%s", type, alias);
+ virBufferAsprintf(buf, "%s,", type);
- if (props) {
- virBufferAddLit(buf, ",");
- if (virQEMUBuildCommandLineJSON(props, buf, NULL,
- virQEMUBuildCommandLineJSONArrayBitmap) < 0)
- return -1;
- }
+ if (virQEMUBuildCommandLineJSON(objprops, buf, "qom-type",
+ virQEMUBuildCommandLineJSONArrayBitmap) < 0)
+ return -1;
return 0;
}
-int
-virQEMUBuildObjectCommandlineFromJSON(virBufferPtr buf,
- virJSONValuePtr objprops)
-{
- const char *type = virJSONValueObjectGetString(objprops, "qom-type");
- const char *alias = virJSONValueObjectGetString(objprops, "id");
- virJSONValuePtr props = virJSONValueObjectGetObject(objprops, "props");
-
- return virQEMUBuildObjectCommandlineFromJSONInternal(buf, type, alias, props);
-}
-
-
char *
virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr srcdef)
{