From nobody Sat Jul 12 06:01:47 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1499688481810229.15475433146992; Mon, 10 Jul 2017 05:08:01 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D52407EBDA; Mon, 10 Jul 2017 12:07:57 +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 856187ED83; Mon, 10 Jul 2017 12:07:57 +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 11441157C4; Mon, 10 Jul 2017 12:07:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6AC7nM3018604 for ; Mon, 10 Jul 2017 08:07:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id DED55182E0; Mon, 10 Jul 2017 12:07:49 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C70F7DFD1; Mon, 10 Jul 2017 12:07:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D52407EBDA Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D52407EBDA From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 10 Jul 2017 14:07:38 +0200 Message-Id: <7c12ca4c82d15bdbbcef55c85b9bc430a3a31668.1499688409.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 06/10] qemu: command: Call qemuGetDriveSourceProps only if necessary 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 10 Jul 2017 12:07:58 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add logic which will call qemuGetDriveSourceProps only in cases where we need the JSON representation. This will allow qemuGetDriveSourceProps to generate the JSON representation for all possible disk sources. --- src/qemu/qemu_command.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 10c2dea93..376082320 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1436,6 +1436,28 @@ qemuDiskBusNeedsDeviceArg(int bus) } +/** + * qemuDiskSourceNeedsProps: + * @src: disk source + * + * Returns true, if the disk source needs to be generated from the JSON + * representation. Otherwise, the disk source should be represented using + * the legacy representation. + */ +static bool +qemuDiskSourceNeedsProps(virStorageSourcePtr src) +{ + int actualType =3D virStorageSourceGetActualType(src); + + if (actualType =3D=3D VIR_STORAGE_TYPE_NETWORK && + src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER && + src->nhosts > 1) + return true; + + return false; +} + + static int qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, virQEMUDriverConfigPtr cfg, @@ -1450,7 +1472,8 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, char *source =3D NULL; int ret =3D -1; - if (qemuGetDriveSourceProps(disk->src, &srcprops) < 0) + if (qemuDiskSourceNeedsProps(disk->src) && + qemuGetDriveSourceProps(disk->src, &srcprops) < 0) goto cleanup; if (!srcprops && --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list