Blame SOURCES/libvirt-virQEMUCapsHasPCIMultiBus-assume-true-if-we-have-no-version-information.patch

404507
From 7bac1e059259bee2f00d6e363dad32ca2c2decb6 Mon Sep 17 00:00:00 2001
404507
Message-Id: <7bac1e059259bee2f00d6e363dad32ca2c2decb6@dist-git>
404507
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
404507
Date: Thu, 30 Nov 2017 17:46:00 +0100
404507
Subject: [PATCH] virQEMUCapsHasPCIMultiBus: assume true if we have no version
404507
 information
404507
MIME-Version: 1.0
404507
Content-Type: text/plain; charset=UTF-8
404507
Content-Transfer-Encoding: 8bit
404507
404507
In status XML, we do not store the QEMU version information, we only
404507
format all the capabilities. We dropped QEMU_CAPS_PCI_MULTIBUS
404507
in commit 5b783379 which was released in libvirt 3.2.0.
404507
404507
Therefore the only way of telling if the already running domain
404507
at the time of daemon restart has been started with a QEMU that does
404507
use 'pci.0' or not on PPC is to look at the pci-root controller's
404507
alias. This is not an option if the domain has a user-specified alias
404507
for the pci-root.
404507
404507
Instead of reintroducing the capability, assume 'pci.0' when we have
404507
no version information. That way the only left broken use case would
404507
be the combination of user aliases and very old QEMU.
404507
404507
Partially reverts commit 3a37af1e4.
404507
404507
https://bugzilla.redhat.com/show_bug.cgi?id=1518148
404507
(cherry picked from commit 65108d94d093de082dc5a2d4a73844dd569506db)
404507
Signed-off-by: Ján Tomko <jtomko@redhat.com>
404507
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
404507
---
404507
 src/qemu/qemu_capabilities.c | 16 ++++++++--------
404507
 src/qemu/qemu_capspriv.h     |  4 ----
404507
 tests/qemuxml2argvtest.c     |  5 -----
404507
 3 files changed, 8 insertions(+), 17 deletions(-)
404507
404507
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
404507
index 81f7e4e440..13ff1286c4 100644
404507
--- a/src/qemu/qemu_capabilities.c
404507
+++ b/src/qemu/qemu_capabilities.c
404507
@@ -2435,6 +2435,14 @@ bool virQEMUCapsHasPCIMultiBus(virQEMUCapsPtr qemuCaps,
404507
          *     ppce500: 1.6.0
404507
          */
404507
 
404507
+        /* We do not store the qemu version in domain status XML.
404507
+         * Hope the user is using a QEMU new enough to use 'pci.0',
404507
+         * otherwise the results of this function will be wrong
404507
+         * for domains already running at the time of daemon
404507
+         * restart */
404507
+        if (qemuCaps->version == 0)
404507
+            return true;
404507
+
404507
         if (qemuCaps->version >= 2000000)
404507
             return true;
404507
 
404507
@@ -2486,14 +2494,6 @@ virArch virQEMUCapsGetArch(virQEMUCapsPtr qemuCaps)
404507
 }
404507
 
404507
 
404507
-void
404507
-virQEMUCapsSetVersion(virQEMUCapsPtr qemuCaps,
404507
-                      unsigned int version)
404507
-{
404507
-    qemuCaps->version = version;
404507
-}
404507
-
404507
-
404507
 unsigned int virQEMUCapsGetVersion(virQEMUCapsPtr qemuCaps)
404507
 {
404507
     return qemuCaps->version;
404507
diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h
404507
index f23995ec6e..219daa3629 100644
404507
--- a/src/qemu/qemu_capspriv.h
404507
+++ b/src/qemu/qemu_capspriv.h
404507
@@ -55,10 +55,6 @@ void
404507
 virQEMUCapsSetArch(virQEMUCapsPtr qemuCaps,
404507
                    virArch arch);
404507
 
404507
-void
404507
-virQEMUCapsSetVersion(virQEMUCapsPtr qemuCaps,
404507
-                      unsigned int version);
404507
-
404507
 void
404507
 virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
404507
                             virArch hostArch,
404507
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
404507
index 72cefe4906..686a63855c 100644
404507
--- a/tests/qemuxml2argvtest.c
404507
+++ b/tests/qemuxml2argvtest.c
404507
@@ -384,11 +384,6 @@ testUpdateQEMUCaps(const struct testInfo *info,
404507
 
404507
     virQEMUCapsInitQMPBasicArch(info->qemuCaps);
404507
 
404507
-    /* We need to pretend QEMU 2.0.0 is in use so that pSeries guests
404507
-     * will get the correct alias assigned to their buses.
404507
-     * See virQEMUCapsHasPCIMultiBus() */
404507
-    virQEMUCapsSetVersion(info->qemuCaps, 2000000);
404507
-
404507
     if (testAddCPUModels(info->qemuCaps, info->skipLegacyCPUs) < 0)
404507
         goto cleanup;
404507
 
404507
-- 
404507
2.15.1
404507