render / rpms / libvirt

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