render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c1c534
From 57dd2427239f4de91c9735b1fa299d08d11a8dac Mon Sep 17 00:00:00 2001
c1c534
Message-Id: <57dd2427239f4de91c9735b1fa299d08d11a8dac@dist-git>
c1c534
From: Michal Privoznik <mprivozn@redhat.com>
c1c534
Date: Mon, 20 Nov 2017 11:08:54 +0100
c1c534
Subject: [PATCH] qemuBuildDeviceAddressStr: Prefer default alias for PCI bus
c1c534
c1c534
https://bugzilla.redhat.com/show_bug.cgi?id=1434451
c1c534
c1c534
Just like in 9324f67a572f9b32 we need to put default pci-root
c1c534
alias onto the command line instead of the one provided by user.
c1c534
c1c534
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c1c534
(cherry picked from commit 937f319536723fec57ad472b002a159d0f67a77c)
c1c534
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c1c534
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c1c534
---
c1c534
 src/qemu/qemu_command.c                            | 30 ++++++++++++++++------
c1c534
 .../qemuxml2argvdata/qemuxml2argv-user-aliases.xml |  4 ++-
c1c534
 2 files changed, 25 insertions(+), 9 deletions(-)
c1c534
c1c534
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
c1c534
index 7dc7387a15..dfacff4b12 100644
c1c534
--- a/src/qemu/qemu_command.c
c1c534
+++ b/src/qemu/qemu_command.c
c1c534
@@ -318,16 +318,30 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
c1c534
 
c1c534
             if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
c1c534
                 cont->idx == info->addr.pci.bus) {
c1c534
-                contAlias = cont->info.alias;
c1c534
                 contIsPHB = virDomainControllerIsPSeriesPHB(cont);
c1c534
                 contTargetIndex = cont->opts.pciopts.targetIndex;
c1c534
-                if (!contAlias) {
c1c534
-                    virReportError(VIR_ERR_INTERNAL_ERROR,
c1c534
-                                   _("Device alias was not set for PCI "
c1c534
-                                     "controller with index %u required "
c1c534
-                                     "for device at address %s"),
c1c534
-                                   info->addr.pci.bus, devStr);
c1c534
-                    goto cleanup;
c1c534
+
c1c534
+                /* When domain has builtin pci-root controller we don't put it
c1c534
+                 * onto cmd line. Therefore we can't set its alias. In that
c1c534
+                 * case, use the default one. */
c1c534
+                if (!qemuDomainIsPSeries(domainDef) &&
c1c534
+                    cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) {
c1c534
+                    if (virQEMUCapsHasPCIMultiBus(qemuCaps, domainDef))
c1c534
+                        contAlias = "pci.0";
c1c534
+                    else
c1c534
+                        contAlias = "pci";
c1c534
+                } else if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) {
c1c534
+                    contAlias = "pcie.0";
c1c534
+                } else {
c1c534
+                    contAlias = cont->info.alias;
c1c534
+                    if (!contAlias) {
c1c534
+                        virReportError(VIR_ERR_INTERNAL_ERROR,
c1c534
+                                       _("Device alias was not set for PCI "
c1c534
+                                         "controller with index %u required "
c1c534
+                                         "for device at address %s"),
c1c534
+                                       info->addr.pci.bus, devStr);
c1c534
+                        goto cleanup;
c1c534
+                    }
c1c534
                 }
c1c534
                 break;
c1c534
             }
c1c534
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml
c1c534
index d1cb8fea6f..c760098fe0 100644
c1c534
--- a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml
c1c534
+++ b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.xml
c1c534
@@ -74,7 +74,9 @@
c1c534
       <alias name='ua-SomeWeirdController'/>
c1c534
       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
c1c534
     </controller>
c1c534
-    <controller type='pci' index='0' model='pci-root'/>
c1c534
+    <controller type='pci' index='0' model='pci-root'>
c1c534
+      <alias name='ua-MyPCIRootController'/>
c1c534
+    </controller>
c1c534
     <controller type='ide' index='0'>
c1c534
       <alias name='ua-DoesAnybodyStillUseIDE'/>
c1c534
       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
c1c534
-- 
c1c534
2.15.0
c1c534