Blame SOURCES/kvm-acpi-mem-hotplug-add-acpi_memory_slot_status-to-get-.patch

8be556
From b9e7babd1879dea3b2703f94e5a628bbe4b96889 Mon Sep 17 00:00:00 2001
8be556
From: Igor Mammedov <imammedo@redhat.com>
8be556
Date: Mon, 8 Jun 2015 00:52:00 +0200
8be556
Subject: [PATCH 044/217] acpi, mem-hotplug: add acpi_memory_slot_status() to
8be556
 get MemStatus
8be556
8be556
Message-id: <1433724727-46928-3-git-send-email-imammedo@redhat.com>
8be556
Patchwork-id: 65389
8be556
O-Subject: [RHEL-7.2 qemu-kvm-rhev PATCH 2/9] acpi, mem-hotplug: add acpi_memory_slot_status() to get MemStatus
8be556
Bugzilla: 1120706
8be556
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
8be556
RH-Acked-by: Andrew Jones <drjones@redhat.com>
8be556
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
8be556
8be556
From: Tang Chen <tangchen@cn.fujitsu.com>
8be556
8be556
Add a new API named acpi_memory_slot_status() to obtain a single memory
8be556
slot status. Doing this is because this procedure will be used by other
8be556
functions in the next coming patches.
8be556
8be556
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
8be556
Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
8be556
Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
8be556
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
8be556
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8be556
(cherry picked from commit 4aae99b63333e71b2097b106bb15a6fde7f9b55b)
8be556
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
8be556
---
8be556
 hw/acpi/memory_hotplug.c | 34 ++++++++++++++++++++++++++++------
8be556
 1 file changed, 28 insertions(+), 6 deletions(-)
8be556
8be556
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
8be556
index c6580da..6af9303 100644
8be556
--- a/hw/acpi/memory_hotplug.c
8be556
+++ b/hw/acpi/memory_hotplug.c
8be556
@@ -163,29 +163,51 @@ void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
8be556
     memory_region_add_subregion(as, ACPI_MEMORY_HOTPLUG_BASE, &state->io);
8be556
 }
8be556
 
8be556
-void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,
8be556
-                         DeviceState *dev, Error **errp)
8be556
+/**
8be556
+ * acpi_memory_slot_status:
8be556
+ * @mem_st: memory hotplug state
8be556
+ * @dev: device
8be556
+ * @errp: set in case of an error
8be556
+ *
8be556
+ * Obtain a single memory slot status.
8be556
+ *
8be556
+ * This function will be called by memory unplug request cb and unplug cb.
8be556
+ */
8be556
+static MemStatus *
8be556
+acpi_memory_slot_status(MemHotplugState *mem_st,
8be556
+                        DeviceState *dev, Error **errp)
8be556
 {
8be556
-    MemStatus *mdev;
8be556
     Error *local_err = NULL;
8be556
     int slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP,
8be556
                                        &local_err);
8be556
 
8be556
     if (local_err) {
8be556
         error_propagate(errp, local_err);
8be556
-        return;
8be556
+        return NULL;
8be556
     }
8be556
 
8be556
     if (slot >= mem_st->dev_count) {
8be556
         char *dev_path = object_get_canonical_path(OBJECT(dev));
8be556
-        error_setg(errp, "acpi_memory_plug_cb: "
8be556
+        error_setg(errp, "acpi_memory_slot_status: "
8be556
                    "device [%s] returned invalid memory slot[%d]",
8be556
                     dev_path, slot);
8be556
         g_free(dev_path);
8be556
+        return NULL;
8be556
+    }
8be556
+
8be556
+    return &mem_st->devs[slot];
8be556
+}
8be556
+
8be556
+void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,
8be556
+                         DeviceState *dev, Error **errp)
8be556
+{
8be556
+    MemStatus *mdev;
8be556
+
8be556
+    mdev = acpi_memory_slot_status(mem_st, dev, errp);
8be556
+    if (!mdev) {
8be556
         return;
8be556
     }
8be556
 
8be556
-    mdev = &mem_st->devs[slot];
8be556
     mdev->dimm = dev;
8be556
     mdev->is_enabled = true;
8be556
     mdev->is_inserting = true;
8be556
-- 
8be556
1.8.3.1
8be556