From nobody Thu May 15 09:25:38 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 1513269007552584.2748492892474; Thu, 14 Dec 2017 08:30:07 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 72CC98618; Thu, 14 Dec 2017 16:30:06 +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 31C2017CDB; Thu, 14 Dec 2017 16:30:06 +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 A7EE91801215; Thu, 14 Dec 2017 16:30:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vBEGU3fR017416 for ; Thu, 14 Dec 2017 11:30:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id 44A5371923; Thu, 14 Dec 2017 16:30:03 +0000 (UTC) Received: from inaba.usersys.redhat.com (ovpn-204-182.brq.redhat.com [10.40.204.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 53CE87191F for ; Thu, 14 Dec 2017 16:30:01 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 14 Dec 2017 17:29:50 +0100 Message-Id: <20171214162951.2856-2-abologna@redhat.com> In-Reply-To: <20171214162951.2856-1-abologna@redhat.com> References: <20171214162951.2856-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] qemu: Invert condition nesting in qemuDomainDefValidate() 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 14 Dec 2017 16:30:06 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" While at the moment we're only performing a single check that is connected to vCPU hotplugging, we're going to introduce a second one soon. Move the topology check underneath the capability check to make that easier; as a bonus, doing so allows us to reduce the scope of the 'topologycpus' variable. Signed-off-by: Andrea Bolognani --- src/qemu/qemu_domain.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 74b82450b..e93333669 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3299,7 +3299,6 @@ qemuDomainDefValidate(const virDomainDef *def, { virQEMUDriverPtr driver =3D opaque; virQEMUCapsPtr qemuCaps =3D NULL; - unsigned int topologycpus; int ret =3D -1; =20 if (!(qemuCaps =3D virQEMUCapsCacheLookup(driver->qemuCapsCache, @@ -3359,11 +3358,15 @@ qemuDomainDefValidate(const virDomainDef *def, } } =20 - /* qemu as of 2.5.0 rejects SMP topologies that don't match the cpu co= unt */ - if (virDomainDefGetVcpusTopology(def, &topologycpus) =3D=3D 0 && - topologycpus !=3D virDomainDefGetVcpusMax(def)) { - /* presence of query-hotpluggable-cpus should be a good enough wit= ness */ - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS)) { + /* QEMU 2.7 (detected via the availability of query-hotpluggable-cpus) + * enforces stricter rules than previous versions when it comes to gue= st + * CPU topology. Verify known constraints are respected */ + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS)) { + unsigned int topologycpus; + + /* Max vCPU count and overall vCPU topology must agree */ + if (virDomainDefGetVcpusTopology(def, &topologycpus) =3D=3D 0 && + topologycpus !=3D virDomainDefGetVcpusMax(def)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("CPU topology doesn't match maximum vcpu coun= t")); goto cleanup; --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list