Signed-off-by: Peter Krempa <pkre...@redhat.com> --- src/libvirt_private.syms | 1 + src/util/virqemu.c | 40 ++++++++++++++++++++++++++++++++++++---- src/util/virqemu.h | 3 +++ 3 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index e2a9916326..37922f8c84 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2599,6 +2599,7 @@ virQEMUBuildCommandLineJSON; virQEMUBuildCommandLineJSONArrayBitmap; virQEMUBuildCommandLineJSONArrayNumbered; virQEMUBuildDriveCommandlineFromJSON; +virQEMUBuildObjectCommandlineFromJSON; virQEMUBuildObjectCommandlineFromJSONType; virQEMUBuildQemuImgKeySecretOpts; diff --git a/src/util/virqemu.c b/src/util/virqemu.c index fc4727e126..1390b68b86 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -241,6 +241,29 @@ virQEMUBuildCommandLineJSON(virJSONValuePtr value, } +static int +virQEMUBuildObjectCommandlineFromJSONInternal(virBufferPtr buf, + const char *type, + const char *alias, + virJSONValuePtr props) +{ + if (!type || !alias) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing 'type' or 'alias' field of QOM 'object'")); + return -1; + } + + virBufferAsprintf(buf, "%s,id=%s,", type, alias); + + if (props && + virQEMUBuildCommandLineJSON(props, buf, + virQEMUBuildCommandLineJSONArrayBitmap) < 0) + return -1; + + return 0; +} + + char * virQEMUBuildObjectCommandlineFromJSONType(const char *type, const char *alias, @@ -249,10 +272,7 @@ virQEMUBuildObjectCommandlineFromJSONType(const char *type, virBuffer buf = VIR_BUFFER_INITIALIZER; char *ret = NULL; - virBufferAsprintf(&buf, "%s,id=%s,", type, alias); - - if (virQEMUBuildCommandLineJSON(props, &buf, - virQEMUBuildCommandLineJSONArrayBitmap) < 0) + if (virQEMUBuildObjectCommandlineFromJSONInternal(&buf, type, alias, props) < 0) goto cleanup; if (virBufferCheckError(&buf) < 0) @@ -266,6 +286,18 @@ virQEMUBuildObjectCommandlineFromJSONType(const char *type, } +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) { diff --git a/src/util/virqemu.h b/src/util/virqemu.h index 0ef8e8d31d..0a4f4468f2 100644 --- a/src/util/virqemu.h +++ b/src/util/virqemu.h @@ -47,6 +47,9 @@ char *virQEMUBuildObjectCommandlineFromJSONType(const char *type, const char *alias, virJSONValuePtr props); +int virQEMUBuildObjectCommandlineFromJSON(virBufferPtr buf, + virJSONValuePtr objprops); + char *virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr src); void virQEMUBuildBufferEscapeComma(virBufferPtr buf, const char *str); -- 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list