render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame 0204-Fix-pc-migration-from-qemu-1.5.patch

0c698d
From 16f89cbf7737626a0ab24a5b0fd7ce4ab940f5a2 Mon Sep 17 00:00:00 2001
0c698d
From: Cole Robinson <crobinso@redhat.com>
0c698d
Date: Mon, 7 Oct 2013 16:32:24 -0400
0c698d
Subject: [PATCH] Fix pc migration from qemu <= 1.5
0c698d
0c698d
The following commit introduced a migration incompatibility:
0c698d
0c698d
commit 568f0690fd9aa4d39d84b04c1a5dbb53a915c3fe
0c698d
Author: David Gibson <david@gibson.dropbear.id.au>
0c698d
Date:   Thu Jun 6 18:48:49 2013 +1000
0c698d
0c698d
    pci: Replace pci_find_domain() with more general pci_root_bus_path()
0c698d
0c698d
The issue is that i440fx savevm idstr went from 0000:00:00.0/I440FX to
0c698d
0000:00.0/I440FX. Unfortunately we are stuck with the breakage for
0c698d
1.6 machine types.
0c698d
0c698d
Add a compat property to maintain the busted idstr for the 1.6 machine
0c698d
types, but revert to the old style format for 1.7+, and <= 1.5.
0c698d
0c698d
Tested with migration from qemu 1.5, qemu 1.6, and qemu.git.
0c698d
0c698d
Cc: qemu-stable@nongnu.org
0c698d
---
0c698d
 hw/i386/pc_piix.c         | 11 +++++++++++
0c698d
 hw/i386/pc_q35.c          | 11 +++++++++++
0c698d
 hw/pci-host/piix.c        |  9 ++++++++-
0c698d
 hw/pci-host/q35.c         | 10 ++++++++--
0c698d
 include/hw/i386/pc.h      | 20 ++++++++++++++++++++
0c698d
 include/hw/pci-host/q35.h |  1 +
0c698d
 6 files changed, 59 insertions(+), 3 deletions(-)
0c698d
0c698d
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
0c698d
index 2f2cb4d..10866f5 100644
0c698d
--- a/hw/i386/pc_piix.c
0c698d
+++ b/hw/i386/pc_piix.c
0c698d
@@ -341,6 +341,13 @@ static void pc_xen_hvm_init(QEMUMachineInitArgs *args)
0c698d
 }
0c698d
 #endif
0c698d
 
0c698d
+#define PC_I440FX_MACHINE_OPTIONS \
0c698d
+    PC_DEFAULT_MACHINE_OPTIONS, \
0c698d
+    .desc = "Standard PC (i440FX + PIIX, 1996)", \
0c698d
+    .hot_add_cpu = pc_hot_add_cpu
0c698d
+
0c698d
+#define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
0c698d
+
0c698d
 static QEMUMachine pc_i440fx_machine_v1_6 = {
0c698d
     .name = "pc-i440fx-1.6",
0c698d
     .alias = "pc",
0c698d
@@ -349,6 +356,10 @@ static QEMUMachine pc_i440fx_machine_v1_6 = {
0c698d
     .hot_add_cpu = pc_hot_add_cpu,
0c698d
     .max_cpus = 255,
0c698d
     .is_default = 1,
0c698d
+    .compat_props = (GlobalProperty[]) {
0c698d
+        PC_COMPAT_1_6,
0c698d
+        { /* end of list */ }
0c698d
+    },
0c698d
     DEFAULT_MACHINE_OPTIONS,
0c698d
 };
0c698d
 
0c698d
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
0c698d
index dd13130..4998ed3 100644
0c698d
--- a/hw/i386/pc_q35.c
0c698d
+++ b/hw/i386/pc_q35.c
0c698d
@@ -243,6 +243,13 @@ static void pc_q35_init_1_4(QEMUMachineInitArgs *args)
0c698d
     pc_q35_init(args);
0c698d
 }
0c698d
 
0c698d
+#define PC_Q35_MACHINE_OPTIONS \
0c698d
+    PC_DEFAULT_MACHINE_OPTIONS, \
0c698d
+    .desc = "Standard PC (Q35 + ICH9, 2009)", \
0c698d
+    .hot_add_cpu = pc_hot_add_cpu
0c698d
+
0c698d
+#define PC_Q35_1_6_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
0c698d
+
0c698d
 static QEMUMachine pc_q35_machine_v1_6 = {
0c698d
     .name = "pc-q35-1.6",
0c698d
     .alias = "q35",
0c698d
@@ -250,6 +257,10 @@ static QEMUMachine pc_q35_machine_v1_6 = {
0c698d
     .init = pc_q35_init_1_6,
0c698d
     .hot_add_cpu = pc_hot_add_cpu,
0c698d
     .max_cpus = 255,
0c698d
+    .compat_props = (GlobalProperty[]) {
0c698d
+        PC_COMPAT_1_6,
0c698d
+        { /* end of list */ }
0c698d
+    },
0c698d
     DEFAULT_MACHINE_OPTIONS,
0c698d
 };
0c698d
 
0c698d
diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
0c698d
index 221d82b..967f949 100644
0c698d
--- a/hw/pci-host/piix.c
0c698d
+++ b/hw/pci-host/piix.c
0c698d
@@ -48,6 +48,7 @@ typedef struct I440FXState {
0c698d
     PCIHostState parent_obj;
0c698d
     PcPciInfo pci_info;
0c698d
     uint64_t pci_hole64_size;
0c698d
+    uint32_t short_root_bus;
0c698d
 } I440FXState;
0c698d
 
0c698d
 #define PIIX_NUM_PIC_IRQS       16      /* i8259 * 2 */
0c698d
@@ -706,13 +707,19 @@ static const TypeInfo i440fx_info = {
0c698d
 static const char *i440fx_pcihost_root_bus_path(PCIHostState *host_bridge,
0c698d
                                                 PCIBus *rootbus)
0c698d
 {
0c698d
+    I440FXState *s = I440FX_PCI_HOST_BRIDGE(host_bridge);
0c698d
+
0c698d
     /* For backwards compat with old device paths */
0c698d
-    return "0000";
0c698d
+    if (s->short_root_bus) {
0c698d
+        return "0000";
0c698d
+    }
0c698d
+    return "0000:00";
0c698d
 }
0c698d
 
0c698d
 static Property i440fx_props[] = {
0c698d
     DEFINE_PROP_SIZE(PCI_HOST_PROP_PCI_HOLE64_SIZE, I440FXState,
0c698d
                      pci_hole64_size, DEFAULT_PCI_HOLE64_SIZE),
0c698d
+    DEFINE_PROP_UINT32("short_root_bus", I440FXState, short_root_bus, 0),
0c698d
     DEFINE_PROP_END_OF_LIST(),
0c698d
 };
0c698d
 
0c698d
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
0c698d
index 4febd24..f762053 100644
0c698d
--- a/hw/pci-host/q35.c
0c698d
+++ b/hw/pci-host/q35.c
0c698d
@@ -61,8 +61,13 @@ static void q35_host_realize(DeviceState *dev, Error **errp)
0c698d
 static const char *q35_host_root_bus_path(PCIHostState *host_bridge,
0c698d
                                           PCIBus *rootbus)
0c698d
 {
0c698d
-    /* For backwards compat with old device paths */
0c698d
-    return "0000";
0c698d
+    Q35PCIHost *s = Q35_HOST_DEVICE(host_bridge);
0c698d
+
0c698d
+     /* For backwards compat with old device paths */
0c698d
+    if (s->mch.short_root_bus) {
0c698d
+        return "0000";
0c698d
+    }
0c698d
+    return "0000:00";
0c698d
 }
0c698d
 
0c698d
 static void q35_host_get_pci_hole_start(Object *obj, Visitor *v,
0c698d
@@ -108,6 +113,7 @@ static Property mch_props[] = {
0c698d
                         MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT),
0c698d
     DEFINE_PROP_SIZE(PCI_HOST_PROP_PCI_HOLE64_SIZE, Q35PCIHost,
0c698d
                      mch.pci_hole64_size, DEFAULT_PCI_HOLE64_SIZE),
0c698d
+    DEFINE_PROP_UINT32("short_root_bus", Q35PCIHost, mch.short_root_bus, 0),
0c698d
     DEFINE_PROP_END_OF_LIST(),
0c698d
 };
0c698d
 
0c698d
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
0c698d
index 475ba9e..a0bbdd9 100644
0c698d
--- a/include/hw/i386/pc.h
0c698d
+++ b/include/hw/i386/pc.h
0c698d
@@ -225,7 +225,19 @@ void pvpanic_init(ISABus *bus);
0c698d
 
0c698d
 int e820_add_entry(uint64_t, uint64_t, uint32_t);
0c698d
 
0c698d
+#define PC_COMPAT_1_6 \
0c698d
+        {\
0c698d
+            .driver   = "i440FX-pcihost",\
0c698d
+            .property = "short_root_bus",\
0c698d
+            .value    = stringify(1),\
0c698d
+        },{\
0c698d
+            .driver   = "mch",\
0c698d
+            .property = "short_root_bus",\
0c698d
+            .value    = stringify(1),\
0c698d
+        }
0c698d
+
0c698d
 #define PC_COMPAT_1_5 \
0c698d
+        PC_COMPAT_1_6, \
0c698d
         {\
0c698d
             .driver   = "Conroe-" TYPE_X86_CPU,\
0c698d
             .property = "model",\
0c698d
@@ -258,6 +270,14 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
0c698d
             .driver = TYPE_X86_CPU,\
0c698d
             .property = "pmu",\
0c698d
             .value = "on",\
0c698d
+        },{\
0c698d
+            .driver   = "i440FX-pcihost",\
0c698d
+            .property = "short_root_bus",\
0c698d
+            .value    = stringify(0),\
0c698d
+        },{\
0c698d
+            .driver   = "mch",\
0c698d
+            .property = "short_root_bus",\
0c698d
+            .value    = stringify(0),\
0c698d
         }
0c698d
 
0c698d
 #define PC_COMPAT_1_4 \
0c698d
diff --git a/include/hw/pci-host/q35.h b/include/hw/pci-host/q35.h
0c698d
index 6eb7ab6..95a3cc2 100644
0c698d
--- a/include/hw/pci-host/q35.h
0c698d
+++ b/include/hw/pci-host/q35.h
0c698d
@@ -61,6 +61,7 @@ typedef struct MCHPCIState {
0c698d
     ram_addr_t above_4g_mem_size;
0c698d
     uint64_t pci_hole64_size;
0c698d
     PcGuestInfo *guest_info;
0c698d
+    uint32_t short_root_bus;
0c698d
 } MCHPCIState;
0c698d
 
0c698d
 typedef struct Q35PCIHost {