qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 19/27] acpi: piix4/ich9: add optional vmstate field


From: Igor Mammedov
Subject: [Qemu-devel] [PATCH 19/27] acpi: piix4/ich9: add optional vmstate field for MemHotplugState migration
Date: Thu, 21 Nov 2013 03:38:40 +0100

it should not be present for machine versions that do not support
memory hotplug.

Signed-off-by: Igor Mammedov <address@hidden>
---
 hw/acpi/core.c         |   27 +++++++++++++++++++++++++++
 hw/acpi/ich9.c         |    7 +++++++
 hw/acpi/piix4.c        |    7 +++++++
 include/hw/acpi/acpi.h |    8 ++++++++
 4 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/hw/acpi/core.c b/hw/acpi/core.c
index 18e169c..664aec0 100644
--- a/hw/acpi/core.c
+++ b/hw/acpi/core.c
@@ -824,3 +824,30 @@ int acpi_memory_hotplug_cb(ACPIREGS *regs, MemHotplugState 
*mem_st,
     regs->gpe.sts[0] |= ACPI_MEMORY_HOTPLUG_STATUS;
     return 0;
 }
+
+static const VMStateDescription vmstate_memhp_sts = {
+    .name = "memory hotplug device state",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields      = (VMStateField[]) {
+        VMSTATE_BOOL(is_enabled, MemStatus),
+        VMSTATE_BOOL(is_inserting, MemStatus),
+        VMSTATE_UINT32(ost_event, MemStatus),
+        VMSTATE_UINT32(ost_status, MemStatus),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+const VMStateDescription vmstate_memory_hotplug = {
+    .name = "memory hotplug state",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields      = (VMStateField[]) {
+        VMSTATE_UINT32(selector, MemHotplugState),
+        VMSTATE_STRUCT_VARRAY_POINTER_UINT32(devs, MemHotplugState, dev_count,
+                                             vmstate_memhp_sts, MemStatus),
+        VMSTATE_END_OF_LIST()
+    }
+};
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index ab76cc6..ae0c198 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -139,6 +139,12 @@ static int ich9_pm_post_load(void *opaque, int version_id)
      .offset     = vmstate_offset_pointer(_state, _field, uint8_t),  \
  }
 
+static bool vmstate_test_use_memhp(void *opaque, int version_id)
+{
+    ICH9LPCPMRegs *s = opaque;
+    return s->gpe_mem.dev_count != 0;
+}
+
 const VMStateDescription vmstate_ich9_pm = {
     .name = "ich9_pm",
     .version_id = 1,
@@ -155,6 +161,7 @@ const VMStateDescription vmstate_ich9_pm = {
         VMSTATE_GPE_ARRAY(acpi_regs.gpe.en, ICH9LPCPMRegs),
         VMSTATE_UINT32(smi_en, ICH9LPCPMRegs),
         VMSTATE_UINT32(smi_sts, ICH9LPCPMRegs),
+        VMSTATE_MEMORY_HOTPLUG(gpe_mem, ICH9LPCPMRegs, vmstate_test_use_memhp),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index a835981..3121738 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -285,6 +285,12 @@ static bool vmstate_test_no_use_acpi_pci_hotplug(void 
*opaque, int version_id)
     return !s->use_acpi_pci_hotplug;
 }
 
+static bool vmstate_test_use_memhp(void *opaque, int version_id)
+{
+    PIIX4PMState *s = opaque;
+    return s->gpe_mem.dev_count != 0;
+}
+
 /* qemu-kvm 1.2 uses version 3 but advertised as 2
  * To support incoming qemu-kvm 1.2 migration, change version_id
  * and minimum_version_id to 2 below (which breaks migration from
@@ -313,6 +319,7 @@ static const VMStateDescription vmstate_acpi = {
                             struct pci_status),
         VMSTATE_PCI_HOTPLUG(acpi_pci_hotplug, PIIX4PMState,
                             vmstate_test_use_acpi_pci_hotplug),
+        VMSTATE_MEMORY_HOTPLUG(gpe_mem, PIIX4PMState, vmstate_test_use_memhp),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h
index 95c608f..93637a5 100644
--- a/include/hw/acpi/acpi.h
+++ b/include/hw/acpi/acpi.h
@@ -194,6 +194,14 @@ void acpi_memory_hotplug_init(Object *owner, MemoryRegion 
*io,
 
 int acpi_memory_hotplug_cb(ACPIREGS *regs, MemHotplugState *mem_st,
                            DeviceState *dev, HotplugState state);
+
+extern const VMStateDescription vmstate_memory_hotplug;
+
+#define VMSTATE_MEMORY_HOTPLUG(memhp, state, test_memhp_fn) \
+        VMSTATE_STRUCT_TEST(memhp, state, test_memhp_fn, 1, \
+                            vmstate_memory_hotplug, MemHotplugState)
+
+
 /* acpi.c */
 extern int acpi_enabled;
 extern char unsigned *acpi_tables;
-- 
1.7.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]