]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix pci bus naming for PPC
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 23 Apr 2014 15:35:37 +0000 (16:35 +0100)
committerCole Robinson <crobinso@redhat.com>
Mon, 8 Sep 2014 15:37:55 +0000 (11:37 -0400)
Recent discussions around naming of 'pci' vs 'pci.0' for PPC
made me go back and look at the PPC emulator in every historical
version of QEMU since 1.0. The results were worse than I imagined.
This patch adds the logic required to make libvirt work with PPC
correctly with naming variations across all versions & machine
types.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 27b2b987bf41ba1ba3aab8c8d9b2d8bc740fd925)

src/qemu/qemu_capabilities.c
src/qemu/qemu_capabilities.h
src/qemu/qemu_command.c

index 6b8a07b1a6db86dd3bcb05817dbb4174962377bd..0e319f0fcb26b5ff1c18ead127e7919c91bcda52 100644 (file)
@@ -1886,6 +1886,56 @@ virQEMUCapsGet(virQEMUCapsPtr qemuCaps,
 }
 
 
+bool virQEMUCapsHasPCIMultiBus(virQEMUCapsPtr qemuCaps,
+                               virDomainDefPtr def)
+{
+    bool hasMultiBus = virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_MULTIBUS);
+
+    if (hasMultiBus)
+        return true;
+
+    if (def->os.arch == VIR_ARCH_PPC ||
+        def->os.arch == VIR_ARCH_PPC64) {
+        /*
+         * Usage of pci.0 naming:
+         *
+         *    ref405ep: no pci
+         *       taihu: no pci
+         *      bamboo: 1.1.0
+         *       mac99: 2.0.0
+         *     g3beige: 2.0.0
+         *        prep: 1.4.0
+         *     pseries: 2.0.0
+         *   mpc8544ds: forever
+         * virtex-m507: no pci
+         *     ppce500: 1.6.0
+         */
+
+        if (qemuCaps->version >= 2000000)
+            return true;
+
+        if (qemuCaps->version >= 1006000 &&
+            STREQ(def->os.machine, "ppce500"))
+            return true;
+
+        if (qemuCaps->version >= 1004000 &&
+            STREQ(def->os.machine, "prep"))
+            return true;
+
+        if (qemuCaps->version >= 1001000 &&
+            STREQ(def->os.machine, "bamboo"))
+            return true;
+
+        if (STREQ(def->os.machine, "mpc8544ds"))
+            return true;
+
+        return false;
+    }
+
+    return false;
+}
+
+
 const char *virQEMUCapsGetBinary(virQEMUCapsPtr qemuCaps)
 {
     return qemuCaps->binary;
@@ -2356,15 +2406,22 @@ virQEMUCapsInitHelp(virQEMUCapsPtr qemuCaps, uid_t runUid, gid_t runGid)
                                 false) < 0)
         goto cleanup;
 
-    /* Currently only x86_64 and i686 support PCI-multibus. */
+    /* x86_64 and i686 support PCI-multibus on all machine types
+     * since forever. For other architectures, it has been changing
+     * across releases, per machine type, so we can't simply detect
+     * it here. Thus the rest of the logic is provided in a separate
+     * helper virQEMUCapsHasPCIMultiBus() which keys off the machine
+     * stored in virDomainDef and QEMU version number
+     */
     if (qemuCaps->arch == VIR_ARCH_X86_64 ||
-        qemuCaps->arch == VIR_ARCH_I686) {
+        qemuCaps->arch == VIR_ARCH_I686)
         virQEMUCapsSet(qemuCaps, QEMU_CAPS_PCI_MULTIBUS);
-    } else {
-        /* -no-acpi is not supported on other archs
-         * even if qemu reports it in -help */
+
+    /* -no-acpi is not supported on non-x86
+     * even if qemu reports it in -help */
+    if (qemuCaps->arch != VIR_ARCH_X86_64 &&
+        qemuCaps->arch != VIR_ARCH_I686)
         virQEMUCapsClear(qemuCaps, QEMU_CAPS_NO_ACPI);
-    }
 
     /* virQEMUCapsExtractDeviceStr will only set additional caps if qemu
      * understands the 0.13.0+ notion of "-device driver,".  */
@@ -2481,9 +2538,14 @@ virQEMUCapsInitArchQMPBasic(virQEMUCapsPtr qemuCaps,
         goto cleanup;
     }
 
-    /*
-     * Currently only x86_64 and i686 support PCI-multibus,
-     * -no-acpi and -no-kvm-pit-reinjection.
+    /* x86_64 and i686 support PCI-multibus on all machine types
+     * since forever. For other architectures, it has been changing
+     * across releases, per machine type, so we can't simply detect
+     * it here. Thus the rest of the logic is provided in a separate
+     * helper virQEMUCapsHasPCIMultiBus() which keys off the machine
+     * stored in virDomainDef and QEMU version number
+     *
+     * ACPI/HPET/KVM PIT are also x86 specific
      */
     if (qemuCaps->arch == VIR_ARCH_X86_64 ||
         qemuCaps->arch == VIR_ARCH_I686) {
index 7c054128f0c7c35559b83fe6131166ec258e557f..ce9dcccdc23030dacd6d9cfc7e33e8825ffb70d7 100644 (file)
@@ -229,6 +229,9 @@ void virQEMUCapsClear(virQEMUCapsPtr qemuCaps,
 bool virQEMUCapsGet(virQEMUCapsPtr qemuCaps,
                     enum virQEMUCapsFlags flag);
 
+bool virQEMUCapsHasPCIMultiBus(virQEMUCapsPtr qemuCaps,
+                               virDomainDefPtr def);
+
 char *virQEMUCapsFlagsString(virQEMUCapsPtr qemuCaps);
 
 const char *virQEMUCapsGetBinary(virQEMUCapsPtr qemuCaps);
index 13777378d7107e7413145b8349d61ba24b435726..e7037585bd7c38166229e66d88b172cead26d22f 100644 (file)
@@ -3069,7 +3069,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
                 goto cleanup;
             }
         } else {
-            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_MULTIBUS)) {
+            if (virQEMUCapsHasPCIMultiBus(qemuCaps, domainDef)) {
                 virBufferAsprintf(buf, ",bus=%s", contAlias);
             } else {
                 virBufferAddLit(buf, ",bus=pci");