From nobody Thu May 15 09:52:04 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15277000208464.2584176127003275; Wed, 30 May 2018 10:07:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8CCF7A4D4B; Wed, 30 May 2018 17:06:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2F21A9FA43; Wed, 30 May 2018 17:06:58 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B026F4BB78; Wed, 30 May 2018 17:06:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4UH6rFm007299 for ; Wed, 30 May 2018 13:06:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7A439202660C; Wed, 30 May 2018 17:06:53 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F7582026609 for ; Wed, 30 May 2018 17:06:52 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 30 May 2018 19:06:29 +0200 Message-Id: <96d43762d5c02c419638a2086bea389622faeecf.1527699462.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/13] util: qemu: Introduce helper for formatting command line from new object props X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 30 May 2018 17:06:59 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- 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=3D%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 =3D VIR_BUFFER_INITIALIZER; char *ret =3D NULL; - virBufferAsprintf(&buf, "%s,id=3D%s,", type, alias); - - if (virQEMUBuildCommandLineJSON(props, &buf, - virQEMUBuildCommandLineJSONArrayBitmap= ) < 0) + if (virQEMUBuildObjectCommandlineFromJSONInternal(&buf, type, alias, p= rops) < 0) goto cleanup; if (virBufferCheckError(&buf) < 0) @@ -266,6 +286,18 @@ virQEMUBuildObjectCommandlineFromJSONType(const char *= type, } +int +virQEMUBuildObjectCommandlineFromJSON(virBufferPtr buf, + virJSONValuePtr objprops) +{ + const char *type =3D virJSONValueObjectGetString(objprops, "qom-type"); + const char *alias =3D virJSONValueObjectGetString(objprops, "id"); + virJSONValuePtr props =3D 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 cha= r *type, const char *alias, virJSONValuePtr props); +int virQEMUBuildObjectCommandlineFromJSON(virBufferPtr buf, + virJSONValuePtr objprops); + char *virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr src); void virQEMUBuildBufferEscapeComma(virBufferPtr buf, const char *str); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list