From nobody Thu May 15 07:07:39 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 1527700044250429.8907287240247; Wed, 30 May 2018 10:07:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CD9EF3082A35; Wed, 30 May 2018 17:07:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 994BE60172; Wed, 30 May 2018 17:07:22 +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 35B28180BA81; Wed, 30 May 2018 17:07:22 +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 w4UH6uMh007333 for ; Wed, 30 May 2018 13:06:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id E9C0F2026DEF; Wed, 30 May 2018 17:06:55 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F2422026DFD for ; Wed, 30 May 2018 17:06:55 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 30 May 2018 19:06:33 +0200 Message-Id: <1b60e5f6482c890725447d153c7a947d8616dea2.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 09/13] qemu: hotplug: Refactor shmem props formatting to qemuMonitorCreateObjectProps 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.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 30 May 2018 17:07:23 +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/qemu/qemu_command.c | 53 ++++++++++++++++++++-------------------------= ---- src/qemu/qemu_hotplug.c | 8 +------- 2 files changed, 23 insertions(+), 38 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f728b59659..f604a9e8aa 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8792,43 +8792,25 @@ qemuBuildShmemDevStr(virDomainDefPtr def, virJSONValuePtr qemuBuildShmemBackendMemProps(virDomainShmemDefPtr shmem) { + char *mem_alias =3D NULL; char *mem_path =3D NULL; virJSONValuePtr ret =3D NULL; if (virAsprintf(&mem_path, "/dev/shm/%s", shmem->name) < 0) return NULL; - virJSONValueObjectCreate(&ret, - "s:mem-path", mem_path, - "U:size", shmem->size, - "b:share", true, - NULL); - - VIR_FREE(mem_path); - return ret; -} - - -static char * -qemuBuildShmemBackendMemStr(virDomainShmemDefPtr shmem) -{ - char *ret =3D NULL; - char *alias =3D NULL; - virJSONValuePtr props =3D qemuBuildShmemBackendMemProps(shmem); - - if (!props) - return NULL; - - if (virAsprintf(&alias, "shmmem-%s", shmem->info.alias) < 0) + if (virAsprintf(&mem_alias, "shmmem-%s", shmem->info.alias) < 0) goto cleanup; - ret =3D virQEMUBuildObjectCommandlineFromJSONType("memory-backend-file= ", - alias, - props); - cleanup: - VIR_FREE(alias); - virJSONValueFree(props); + qemuMonitorCreateObjectProps(&ret, "memory-backend-file", mem_alias, + "s:mem-path", mem_path, + "U:size", shmem->size, + "b:share", true, + NULL); + cleanup: + VIR_FREE(mem_alias); + VIR_FREE(mem_path); return ret; } @@ -8842,7 +8824,10 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManage= r, virQEMUCapsPtr qemuCaps, bool chardevStdioLogd) { + virJSONValuePtr memProps =3D NULL; + virBuffer buf =3D VIR_BUFFER_INITIALIZER; char *devstr =3D NULL; + int rc; if (shmem->size) { /* @@ -8876,11 +8861,17 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManag= er, break; case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN: - if (!(devstr =3D qemuBuildShmemBackendMemStr(shmem))) + if (!(memProps =3D qemuBuildShmemBackendMemProps(shmem))) return -1; - virCommandAddArgList(cmd, "-object", devstr, NULL); - VIR_FREE(devstr); + rc =3D virQEMUBuildObjectCommandlineFromJSON(&buf, memProps); + virJSONValueFree(memProps); + + if (rc < 0) + return -1; + + virCommandAddArg(cmd, "-object"); + virCommandAddArgBuffer(cmd, &buf); ATTRIBUTE_FALLTHROUGH; case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL: diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index f8358a8b0b..02bc88f863 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2751,8 +2751,6 @@ qemuDomainAttachShmemDevice(virQEMUDriverPtr driver, if (!(props =3D qemuBuildShmemBackendMemProps(shmem))) goto cleanup; - if (virAsprintf(&memAlias, "shmmem-%s", shmem->info.alias) < 0) - goto cleanup; } qemuDomainObjEnterMonitor(driver, vm); @@ -2762,12 +2760,8 @@ qemuDomainAttachShmemDevice(virQEMUDriverPtr driver, &shmem->server.chr) < 0) goto exit_monitor; } else { - if (qemuMonitorAddObjectType(priv->mon, "memory-backend-file", - memAlias, props) < 0) { - props =3D NULL; + if (qemuMonitorAddObject(priv->mon, &props, &memAlias) < 0) goto exit_monitor; - } - props =3D NULL; } release_backing =3D true; --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list