From nobody Sun Feb 8 22:18:07 2026 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.zoho.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 1490961091708212.0452962860969; Fri, 31 Mar 2017 04:51:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2467581235; Fri, 31 Mar 2017 11:51:30 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D647F71D66; Fri, 31 Mar 2017 11:51:29 +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 B87F84EBDA; Fri, 31 Mar 2017 11:51:28 +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 v2VBpP0r013969 for ; Fri, 31 Mar 2017 07:51:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5F67417B8D; Fri, 31 Mar 2017 11:51:25 +0000 (UTC) Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5D371864C; Fri, 31 Mar 2017 11:51:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2467581235 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.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 2467581235 From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 31 Mar 2017 13:52:16 +0200 Message-Id: <733c23e7127222c6e087675fdd0e98cffd884b8e.1490960985.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 5/5] qemu: hotplug: Validate that vcpu-hotplug does not break config 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 31 Mar 2017 11:51:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Make sure that non-hotpluggable vcpus stay clustered at the beginning after modifying persistent definition. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1437010 --- src/qemu/qemu_hotplug.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 18a8df33a..d5aeb6bc0 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -5881,6 +5881,7 @@ qemuDomainVcpuValidateConfig(virDomainDefPtr def, bool state) { virDomainVcpuDefPtr vcpu; + size_t maxvcpus =3D virDomainDefGetVcpusMax(def); ssize_t next =3D -1; /* vcpu 0 can't be disabled */ @@ -5890,7 +5891,25 @@ qemuDomainVcpuValidateConfig(virDomainDefPtr def, return -1; } + /* non-hotpluggable vcpus need to stay clustered starting from vcpu 0 = */ + for (next =3D virBitmapNextSetBit(map, -1) + 1; next < maxvcpus; next+= +) { + if (!(vcpu =3D virDomainDefGetVcpu(def, next))) + continue; + + /* skip vcpus being modified */ + if (virBitmapIsBitSet(map, next)) + continue; + + if (vcpu->online && vcpu->hotpluggable =3D=3D VIR_TRISTATE_BOOL_NO= ) { + virReportError(VIR_ERR_INVALID_ARG, + _("vcpu '%zd' can't be modified as it is follow= ed " + "by non-hotpluggable online vcpus"), next); + return -1; + } + } + /* make sure that all selected vcpus are in the correct state */ + next =3D -1; while ((next =3D virBitmapNextSetBit(map, next)) >=3D 0) { if (!(vcpu =3D virDomainDefGetVcpu(def, next))) continue; --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list