peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

Blame 0101-Fix-migration-from-qemu-kvm.patch

298366
From 2196426a9b081cb99f4bdefb854aaa206bdd0392 Mon Sep 17 00:00:00 2001
76dcac
From: Cole Robinson <crobinso@redhat.com>
76dcac
Date: Fri, 16 Aug 2013 12:14:51 -0400
76dcac
Subject: [PATCH] Fix migration from qemu-kvm
76dcac
76dcac
Details are in the code comments for each change. Just lumped this together
76dcac
to ease patch maintenance.
76dcac
76dcac
Everything except the video memory bits can likely be dropped by Fedora 21
76dcac
time frame. Need to figure out if there's anything to upstream for the
76dcac
video memory bits.
76dcac
---
76dcac
 hw/acpi/piix4.c         |  8 ++++++-
76dcac
 hw/display/qxl.c        |  9 ++++----
76dcac
 hw/i386/pc_piix.c       | 61 +++++++++++++++++++++++++++++++++++++++++++++----
76dcac
 hw/timer/i8254_common.c |  7 +++++-
76dcac
 4 files changed, 74 insertions(+), 11 deletions(-)
76dcac
76dcac
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
298366
index 3aaf18c..6fbe57c 100644
76dcac
--- a/hw/acpi/piix4.c
76dcac
+++ b/hw/acpi/piix4.c
76dcac
@@ -289,7 +289,13 @@ static int acpi_load_old(QEMUFile *f, void *opaque, int version_id)
76dcac
 static const VMStateDescription vmstate_acpi = {
76dcac
     .name = "piix4_pm",
76dcac
     .version_id = 3,
76dcac
-    .minimum_version_id = 3,
76dcac
+    /*
76dcac
+     * qemu-kvm 1.2 uses qemu.git version 3 format, but advertised as 2.
76dcac
+     * This allows incoming migration from qemu-kvm, but breaks incoming
76dcac
+     * migration from qemu < 1.3.
76dcac
+     */
76dcac
+    //minimum_version_id = 3,
76dcac
+    .minimum_version_id = 2,
76dcac
     .minimum_version_id_old = 1,
76dcac
     .load_state_old = acpi_load_old,
76dcac
     .post_load = vmstate_acpi_post_load,
76dcac
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
76dcac
index c537057..7ef3eff 100644
76dcac
--- a/hw/display/qxl.c
76dcac
+++ b/hw/display/qxl.c
76dcac
@@ -307,16 +307,14 @@ static inline uint32_t msb_mask(uint32_t val)
76dcac
     return mask;
76dcac
 }
76dcac
 
76dcac
-static ram_addr_t qxl_rom_size(void)
76dcac
+static void check_qxl_rom_size(PCIQXLDevice *d)
76dcac
 {
76dcac
     uint32_t required_rom_size = sizeof(QXLRom) + sizeof(QXLModes) +
76dcac
                                  sizeof(qxl_modes);
76dcac
-    uint32_t rom_size = 8192; /* two pages */
76dcac
 
76dcac
     required_rom_size = MAX(required_rom_size, TARGET_PAGE_SIZE);
76dcac
     required_rom_size = msb_mask(required_rom_size * 2 - 1);
76dcac
-    assert(required_rom_size <= rom_size);
76dcac
-    return rom_size;
76dcac
+    assert(required_rom_size <= d->rom_size);
76dcac
 }
76dcac
 
76dcac
 static void init_qxl_rom(PCIQXLDevice *d)
76dcac
@@ -1981,7 +1979,7 @@ static int qxl_init_common(PCIQXLDevice *qxl)
76dcac
     pci_set_byte(&config[PCI_REVISION_ID], pci_device_rev);
76dcac
     pci_set_byte(&config[PCI_INTERRUPT_PIN], 1);
76dcac
 
76dcac
-    qxl->rom_size = qxl_rom_size();
76dcac
+    check_qxl_rom_size(qxl);
76dcac
     memory_region_init_ram(&qxl->rom_bar, OBJECT(qxl), "qxl.vrom",
76dcac
                            qxl->rom_size);
76dcac
     vmstate_register_ram(&qxl->rom_bar, &qxl->pci.qdev);
76dcac
@@ -2309,6 +2307,7 @@ static Property qxl_properties[] = {
76dcac
         DEFINE_PROP_UINT32("vram64_size_mb", PCIQXLDevice, vram_size_mb, -1),
76dcac
         DEFINE_PROP_UINT32("vgamem_mb", PCIQXLDevice, vgamem_size_mb, 16),
76dcac
         DEFINE_PROP_INT32("surfaces", PCIQXLDevice, ssd.num_surfaces, 1024),
76dcac
+        DEFINE_PROP_UINT32("rom_size", PCIQXLDevice, rom_size, 8192),
76dcac
         DEFINE_PROP_END_OF_LIST(),
76dcac
 };
76dcac
 
76dcac
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
298366
index 3df2ff9..28216ee 100644
76dcac
--- a/hw/i386/pc_piix.c
76dcac
+++ b/hw/i386/pc_piix.c
76dcac
@@ -377,6 +377,24 @@ static QEMUMachine pc_i440fx_machine_v1_4 = {
76dcac
     DEFAULT_MACHINE_OPTIONS,
76dcac
 };
76dcac
 
76dcac
+/*
76dcac
+ * Commit 038c1879a00153b14bce113315b693e8c2944fa9 changed the qxl rom
76dcac
+ * size to 8192, which fixes incoming migration from qemu 1.0. However
76dcac
+ * from qemu 1.2 and 1.3 had rom size 16384, so incoming migration
76dcac
+ * from those versions is now broken.
76dcac
+ *
76dcac
+ * Add a rom_size compat property. 1.2 and 1.3 get 16384, everything
76dcac
+ * else is 8192.
76dcac
+ *
76dcac
+ * This isn't actually fool proof, since rom_size can be dependent on
76dcac
+ * the version of spice qemu is built against:
76dcac
+ *
76dcac
+ * https://lists.gnu.org/archive/html/qemu-devel/2013-02/msg03154.html
76dcac
+ *
76dcac
+ * However these sizes match what native Fedora packages get, so it's
76dcac
+ * good enough for now.
76dcac
+ */
76dcac
+
76dcac
 #define PC_COMPAT_1_3 \
76dcac
 	PC_COMPAT_1_4, \
76dcac
         {\
76dcac
@@ -395,8 +413,17 @@ static QEMUMachine pc_i440fx_machine_v1_4 = {
76dcac
             .driver   = "e1000",\
76dcac
             .property = "autonegotiation",\
76dcac
             .value    = "off",\
76dcac
+        },{ \
76dcac
+            .driver   = "qxl", \
76dcac
+            .property = "rom_size", \
76dcac
+            .value    = stringify(16384), \
76dcac
+        },{\
76dcac
+            .driver   = "qxl-vga", \
76dcac
+            .property = "rom_size", \
76dcac
+            .value    = stringify(16384), \
76dcac
         }
76dcac
 
76dcac
+
76dcac
 static QEMUMachine pc_machine_v1_3 = {
76dcac
     .name = "pc-1.3",
76dcac
     .desc = "Standard PC",
76dcac
@@ -409,6 +436,19 @@ static QEMUMachine pc_machine_v1_3 = {
76dcac
     DEFAULT_MACHINE_OPTIONS,
76dcac
 };
76dcac
 
76dcac
+
76dcac
+/*
76dcac
+ * https://lists.gnu.org/archive/html/qemu-devel/2013-01/msg02540.html
76dcac
+ *
76dcac
+ * qemu-kvm defaulted to vgamem=16MB since at least 0.15, while qemu used
76dcac
+ * 8MB. For qemu 1.2, the default was changed to 16MB for all devices
76dcac
+ * except cirrus.
76dcac
+ *
76dcac
+ * Make sure cirrus uses 16MB for <= pc-1.2 (the qemu-kvm merge),
76dcac
+ * and 16MB always for all others. This will break incoming qemu
76dcac
+ * migration for qemu < 1.3.
76dcac
+ */
76dcac
+
76dcac
 #define PC_COMPAT_1_2 \
76dcac
         PC_COMPAT_1_3,\
76dcac
         {\
76dcac
@@ -432,6 +472,10 @@ static QEMUMachine pc_machine_v1_3 = {
76dcac
             .property = "revision",\
76dcac
             .value    = stringify(3),\
76dcac
         },{\
76dcac
+            .driver   = "cirrus-vga",\
76dcac
+            .property = "vgamem_mb",\
76dcac
+            .value    = stringify(16),\
76dcac
+        },{\
76dcac
             .driver   = "VGA",\
76dcac
             .property = "mmio",\
76dcac
             .value    = "off",\
76dcac
@@ -462,25 +506,34 @@ static QEMUMachine pc_machine_v1_2 = {
76dcac
         },{\
76dcac
             .driver   = "VGA",\
76dcac
             .property = "vgamem_mb",\
76dcac
-            .value    = stringify(8),\
76dcac
+            .value    = stringify(16),\
76dcac
         },{\
76dcac
             .driver   = "vmware-svga",\
76dcac
             .property = "vgamem_mb",\
76dcac
-            .value    = stringify(8),\
76dcac
+            .value    = stringify(16),\
76dcac
         },{\
76dcac
             .driver   = "qxl-vga",\
76dcac
             .property = "vgamem_mb",\
76dcac
-            .value    = stringify(8),\
76dcac
+            .value    = stringify(16),\
76dcac
         },{\
76dcac
             .driver   = "qxl",\
76dcac
             .property = "vgamem_mb",\
76dcac
-            .value    = stringify(8),\
76dcac
+            .value    = stringify(16),\
76dcac
         },{\
76dcac
             .driver   = "virtio-blk-pci",\
76dcac
             .property = "config-wce",\
76dcac
             .value    = "off",\
76dcac
+        },{ \
76dcac
+            .driver   = "qxl", \
76dcac
+            .property = "rom_size", \
76dcac
+            .value    = stringify(8192), \
76dcac
+        },{\
76dcac
+            .driver   = "qxl-vga", \
76dcac
+            .property = "rom_size", \
76dcac
+            .value    = stringify(8192), \
76dcac
         }
76dcac
 
76dcac
+
76dcac
 static QEMUMachine pc_machine_v1_1 = {
76dcac
     .name = "pc-1.1",
76dcac
     .desc = "Standard PC",
76dcac
diff --git a/hw/timer/i8254_common.c b/hw/timer/i8254_common.c
76dcac
index 4e5bf0b..cbc00a0 100644
76dcac
--- a/hw/timer/i8254_common.c
76dcac
+++ b/hw/timer/i8254_common.c
76dcac
@@ -267,7 +267,12 @@ static const VMStateDescription vmstate_pit_common = {
76dcac
     .pre_save = pit_dispatch_pre_save,
76dcac
     .post_load = pit_dispatch_post_load,
76dcac
     .fields = (VMStateField[]) {
76dcac
-        VMSTATE_UINT32_V(channels[0].irq_disabled, PITCommonState, 3),
76dcac
+        /* qemu-kvm version_id=2 had 'flags' here which is equivalent
76dcac
+         * This fixes incoming migration from qemu-kvm 1.0, but breaks
76dcac
+         * incoming migration from qemu < 1.1
76dcac
+         */
76dcac
+        //VMSTATE_UINT32_V(channels[0].irq_disabled, PITCommonState, 3),
76dcac
+        VMSTATE_UINT32(channels[0].irq_disabled, PITCommonState),
76dcac
         VMSTATE_STRUCT_ARRAY(channels, PITCommonState, 3, 2,
76dcac
                              vmstate_pit_channel, PITChannelState),
76dcac
         VMSTATE_INT64(channels[0].next_transition_time,