All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
To: qemu-devel@nongnu.org, imammedo@redhat.com, mst@redhat.com,
	pbonzini@redhat.com
Cc: guz.fnst@cn.fujitsu.com, izumi.taku@jp.fujitsu.com,
	Zhu Guihua <zhugh.fnst@cn.fujitsu.com>,
	tangchen@cn.fujitsu.com
Subject: [Qemu-devel] [PATCH v6 2/8] acpi, mem-hotplug: add acpi_memory_slot_status() to get MemStatus
Date: Thu, 2 Apr 2015 17:50:18 +0800	[thread overview]
Message-ID: <30518f8087ae12576686b8fe24cad7b29a649052.1427954659.git.zhugh.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <cover.1427954659.git.zhugh.fnst@cn.fujitsu.com>

From: Tang Chen <tangchen@cn.fujitsu.com>

Add a new API named acpi_memory_slot_status() to obtain a single memory
slot status. Doing this is because this procedure will be used by other
functions in the next coming patches.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
---
 hw/acpi/memory_hotplug.c | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index c6580da..6af9303 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -163,29 +163,51 @@ void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
     memory_region_add_subregion(as, ACPI_MEMORY_HOTPLUG_BASE, &state->io);
 }
 
-void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,
-                         DeviceState *dev, Error **errp)
+/**
+ * acpi_memory_slot_status:
+ * @mem_st: memory hotplug state
+ * @dev: device
+ * @errp: set in case of an error
+ *
+ * Obtain a single memory slot status.
+ *
+ * This function will be called by memory unplug request cb and unplug cb.
+ */
+static MemStatus *
+acpi_memory_slot_status(MemHotplugState *mem_st,
+                        DeviceState *dev, Error **errp)
 {
-    MemStatus *mdev;
     Error *local_err = NULL;
     int slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP,
                                        &local_err);
 
     if (local_err) {
         error_propagate(errp, local_err);
-        return;
+        return NULL;
     }
 
     if (slot >= mem_st->dev_count) {
         char *dev_path = object_get_canonical_path(OBJECT(dev));
-        error_setg(errp, "acpi_memory_plug_cb: "
+        error_setg(errp, "acpi_memory_slot_status: "
                    "device [%s] returned invalid memory slot[%d]",
                     dev_path, slot);
         g_free(dev_path);
+        return NULL;
+    }
+
+    return &mem_st->devs[slot];
+}
+
+void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,
+                         DeviceState *dev, Error **errp)
+{
+    MemStatus *mdev;
+
+    mdev = acpi_memory_slot_status(mem_st, dev, errp);
+    if (!mdev) {
         return;
     }
 
-    mdev = &mem_st->devs[slot];
     mdev->dimm = dev;
     mdev->is_enabled = true;
     mdev->is_inserting = true;
-- 
1.9.3

  reply	other threads:[~2015-04-02  9:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-02  9:50 [Qemu-devel] [PATCH v6 0/8] QEMU memory hot unplug support Zhu Guihua
2015-04-02  9:50 ` Zhu Guihua [this message]
2015-04-02  9:50 ` [Qemu-devel] [PATCH v6 3/8] acpi, mem-hotplug: add unplug request cb for memory device Zhu Guihua
2015-04-02  9:50 ` [Qemu-devel] [PATCH v6 4/8] acpi, mem-hotplug: add unplug " Zhu Guihua
2015-04-02  9:50 ` [Qemu-devel] [PATCH v6 5/8] acpi: extend aml_field() to support UpdateRule Zhu Guihua
2015-04-02  9:50 ` [Qemu-devel] [PATCH v6 6/8] acpi: fix "Memory device control fields" register Zhu Guihua
2015-04-02  9:50 ` [Qemu-devel] [PATCH v6 7/8] acpi: add hardware implementation for memory hot unplug Zhu Guihua
2015-04-02  9:50 ` [Qemu-devel] [PATCH v6 8/8] qmp-event: add event notification for memory hot unplug error Zhu Guihua
2015-04-10 15:37   ` Eric Blake
2015-04-13  1:56     ` Zhu Guihua
2015-04-13 14:40       ` Eric Blake
2015-04-13 14:43         ` Paolo Bonzini
2015-04-08  9:49 ` [Qemu-devel] [PATCH v6 0/8] QEMU memory hot unplug support Zhu Guihua
2015-04-08  9:52   ` Michael S. Tsirkin
2015-04-08 10:47     ` Paulo Ricardo Paz Vital
2015-04-09  1:16       ` Zhu Guihua
2015-04-09  8:28         ` Igor Mammedov
2015-04-09 10:01           ` Zhu Guihua
2015-04-10 15:17 ` Igor Mammedov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=30518f8087ae12576686b8fe24cad7b29a649052.1427954659.git.zhugh.fnst@cn.fujitsu.com \
    --to=zhugh.fnst@cn.fujitsu.com \
    --cc=guz.fnst@cn.fujitsu.com \
    --cc=imammedo@redhat.com \
    --cc=izumi.taku@jp.fujitsu.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=tangchen@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.