From nobody Wed May 14 22:47: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; 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 1517846916078597.1209270876035; Mon, 5 Feb 2018 08:08:36 -0800 (PST) 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 7F05E83F46; Mon, 5 Feb 2018 16:08:34 +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 458B45C54F; Mon, 5 Feb 2018 16:08:34 +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 CFCFF4A46D; Mon, 5 Feb 2018 16:08:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w15G8LKh014587 for ; Mon, 5 Feb 2018 11:08:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id AA11B60471; Mon, 5 Feb 2018 16:08:21 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.40.205.133]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F2CB6064F for ; Mon, 5 Feb 2018 16:08:19 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Mon, 5 Feb 2018 17:08:05 +0100 Message-Id: <20180205160805.29209-3-abologna@redhat.com> In-Reply-To: <20180205160805.29209-1-abologna@redhat.com> References: <20180205160805.29209-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH REBASE 2/2] qemu: Clean up PCI controller options 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.27]); Mon, 05 Feb 2018 16:08:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Most of the options are only applicable to one or two controller types, so they should be filtered out everywhere else. This will reduce user confusion and, in at least one corner case, prevent guests from disappearing on daemon restart. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1483816 Signed-off-by: Andrea Bolognani --- src/qemu/qemu_domain.c | 117 +++++++++++++++++= ++++ .../pseries-controllers-pciopts.xml | 1 + .../i440fx-controllers-pciopts.xml | 7 +- tests/qemuxml2xmloutdata/pcie-expander-bus.xml | 4 +- .../pseries-controllers-pciopts.xml | 8 +- .../qemuxml2xmloutdata/q35-controllers-pciopts.xml | 21 +--- 6 files changed, 128 insertions(+), 30 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index df433c2f0..867f805bd 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4717,6 +4717,121 @@ qemuDomainShmemDefPostParse(virDomainShmemDefPtr sh= m) #define QEMU_USB_XHCI_MAXPORTS 15 =20 =20 +/** + * qemuDomainPCIControllerCleanupOpts: + * @cont: controller + * + * Clean up PCI options for @cont so that only options applicable to + * the controller model will actually be set. + */ +static void +qemuDomainPCIControllerCleanupOpts(const virDomainDef *def, + virDomainControllerDefPtr cont) +{ + if (cont->type !=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI) + return; + + /* pcihole64 and targetIndex */ + switch ((virDomainControllerModelPCI) cont->model) { + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: + /* These controllers support all options; however, + * targetIndex is only supported for pSeries guests and + * pcihole64 is only supported on x86 */ + if (!qemuDomainIsPSeries(def)) + cont->opts.pciopts.targetIndex =3D -1; + if (!ARCH_IS_X86(def->os.arch)) { + cont->opts.pciopts.pcihole64 =3D false; + cont->opts.pciopts.pcihole64size =3D 0; + } + break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: + case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: + /* These controllers don't support any option */ + cont->opts.pciopts.pcihole64 =3D false; + cont->opts.pciopts.pcihole64size =3D 0; + ATTRIBUTE_FALLTHROUGH; + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: + /* These controllers support all options except targetIndex */ + cont->opts.pciopts.targetIndex =3D -1; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST: + break; + } + + /* busNr and numaNode */ + switch ((virDomainControllerModelPCI) cont->model) { + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: + /* These controllers support all options */ + break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: + case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT: + /* These controllers don't support any option */ + cont->opts.pciopts.numaNode =3D -1; + ATTRIBUTE_FALLTHROUGH; + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: + /* These controllers support all options except busNr; however, + * numaNode is only supported for pSeries guests */ + cont->opts.pciopts.busNr =3D -1; + if (!qemuDomainIsPSeries(def)) + cont->opts.pciopts.numaNode =3D -1; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST: + break; + } + + /* chassis and port */ + switch ((virDomainControllerModelPCI) cont->model) { + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT: + /* These controllers support all options */ + break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: + case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: + /* These controllers don't support any option */ + cont->opts.pciopts.chassis =3D -1; + cont->opts.pciopts.port =3D -1; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST: + break; + } + + /* chassisNr */ + switch ((virDomainControllerModelPCI) cont->model) { + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: + /* These controllers support all options */ + break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: + case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: + /* These controllers don't support any option */ + cont->opts.pciopts.chassisNr =3D -1; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST: + break; + } +} + + static int qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont, const virDomainDef *def, @@ -4799,6 +4914,8 @@ qemuDomainControllerDefPostParse(virDomainControllerD= efPtr cont, =20 case VIR_DOMAIN_CONTROLLER_TYPE_PCI: =20 + qemuDomainPCIControllerCleanupOpts(def, cont); + /* pSeries guests can have multiple pci-root controllers, * but other machine types only support a single one */ if (!qemuDomainIsPSeries(def) && diff --git a/tests/qemuxml2argvdata/pseries-controllers-pciopts.xml b/tests= /qemuxml2argvdata/pseries-controllers-pciopts.xml index 43353cba6..a3237ff2c 100644 --- a/tests/qemuxml2argvdata/pseries-controllers-pciopts.xml +++ b/tests/qemuxml2argvdata/pseries-controllers-pciopts.xml @@ -16,6 +16,7 @@ + 1024 diff --git a/tests/qemuxml2xmloutdata/i440fx-controllers-pciopts.xml b/test= s/qemuxml2xmloutdata/i440fx-controllers-pciopts.xml index d171d1370..d1868fdc2 100644 --- a/tests/qemuxml2xmloutdata/i440fx-controllers-pciopts.xml +++ b/tests/qemuxml2xmloutdata/i440fx-controllers-pciopts.xml @@ -20,19 +20,16 @@ /usr/bin/qemu-system-x86_64 - 1024 - - 0 - +
- + 0
diff --git a/tests/qemuxml2xmloutdata/pcie-expander-bus.xml b/tests/qemuxml= 2xmloutdata/pcie-expander-bus.xml index aaac423ca..b6498fd2e 100644 --- a/tests/qemuxml2xmloutdata/pcie-expander-bus.xml +++ b/tests/qemuxml2xmloutdata/pcie-expander-bus.xml @@ -36,9 +36,7 @@ - - 1 - +
diff --git a/tests/qemuxml2xmloutdata/pseries-controllers-pciopts.xml b/tes= ts/qemuxml2xmloutdata/pseries-controllers-pciopts.xml index bbe360e25..b5d646765 100644 --- a/tests/qemuxml2xmloutdata/pseries-controllers-pciopts.xml +++ b/tests/qemuxml2xmloutdata/pseries-controllers-pciopts.xml @@ -21,19 +21,17 @@ /usr/bin/qemu-system-ppc64 - + - + 0 - - 0 - +
diff --git a/tests/qemuxml2xmloutdata/q35-controllers-pciopts.xml b/tests/q= emuxml2xmloutdata/q35-controllers-pciopts.xml index 5ef7aa564..d8a014853 100644 --- a/tests/qemuxml2xmloutdata/q35-controllers-pciopts.xml +++ b/tests/qemuxml2xmloutdata/q35-controllers-pciopts.xml @@ -20,49 +20,36 @@ /usr/bin/qemu-system-x86_64 - 1024 - - 0 -
- - 0 - +
- + 0
- - 0 - +
- - 0 -
- - 0 - +
--=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list