From nobody Fri May 16 06:32:19 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.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 1497606631106687.4631835273445; Fri, 16 Jun 2017 02:50:31 -0700 (PDT) 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 6217080F7C; Fri, 16 Jun 2017 09:50:29 +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 361BE83B39; Fri, 16 Jun 2017 09:50: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 456C04A499; Fri, 16 Jun 2017 09:50:15 +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 v5G9nwuo031406 for ; Fri, 16 Jun 2017 05:49:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5BD207F358; Fri, 16 Jun 2017 09:49:58 +0000 (UTC) Received: from inaba.usersys.redhat.com (ovpn-12-86.pek2.redhat.com [10.72.12.86]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A86F7F35C for ; Fri, 16 Jun 2017 09:49:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6217080F7C 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 6217080F7C From: Andrea Bolognani To: libvir-list@redhat.com Date: Fri, 16 Jun 2017 17:49:00 +0800 Message-Id: <1497606548-18870-17-git-send-email-abologna@redhat.com> In-Reply-To: <1497606548-18870-1-git-send-email-abologna@redhat.com> References: <1497606548-18870-1-git-send-email-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 16/24] qemu: Deal with PHB naming convention 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.27]); Fri, 16 Jun 2017 09:50:30 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Usually, a controller with alias 'x' will create a bus with the same name; however, the bus created by a PHBs with alias 'x' will be named 'x.0' instead, so we need to account for that. As an exception to the exception, the implicit PHB that's added automatically to every pSeries guest creates the 'pci.0' bus. Signed-off-by: Andrea Bolognani --- src/qemu/qemu_command.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8123276..372f5ca 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -302,6 +302,9 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, int ret =3D -1; char *devStr =3D NULL; const char *contAlias =3D NULL; + virDomainControllerModelPCI contModel; + virDomainControllerPCIModelName contModelName; + int contIndex; =20 if (info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { size_t i; @@ -314,6 +317,9 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI && cont->idx =3D=3D info->addr.pci.bus) { contAlias =3D cont->info.alias; + contModel =3D cont->model; + contModelName =3D cont->opts.pciopts.modelName; + contIndex =3D cont->opts.pciopts.idx; if (!contAlias) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Device alias was not set for PCI " @@ -349,7 +355,19 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, } } =20 - virBufferAsprintf(buf, ",bus=3D%s", contAlias); + if (contModel =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT && + contModelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAP= R_PCI_HOST_BRIDGE && + contIndex > 0) { + /* The PCI bus created by a spapr-pci-host-bridge device with + * alias 'x' will be called 'x.0' rather than 'x'; however, + * this does not apply to the implicit PHB in a pSeries guest, + * which always has the hardcoded name 'pci.0' */ + virBufferAsprintf(buf, ",bus=3D%s.0", contAlias); + } else { + /* For all other controllers, the bus name matches the alias + * of the corresponding controller */ + virBufferAsprintf(buf, ",bus=3D%s", contAlias); + } =20 if (info->addr.pci.multi =3D=3D VIR_TRISTATE_SWITCH_ON) virBufferAddLit(buf, ",multifunction=3Don"); --=20 2.7.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list