diff mbox

[RESEND,v1,08/13] acpi, mem-hotplug: Add unplug cb for memory device.

Message ID 1420679180-14883-9-git-send-email-tangchen@cn.fujitsu.com
State New
Headers show

Commit Message

Tang Chen Jan. 8, 2015, 1:06 a.m. UTC
Reset all memory status, and unparent the memory device.
---
 hw/acpi/memory_hotplug.c         | 16 ++++++++++++++++
 include/hw/acpi/memory_hotplug.h |  2 ++
 2 files changed, 18 insertions(+)

Comments

Igor Mammedov Jan. 29, 2015, 1:19 p.m. UTC | #1
On Thu, 8 Jan 2015 09:06:15 +0800
Tang Chen <tangchen@cn.fujitsu.com> wrote:

> Reset all memory status, and unparent the memory device.
> ---
>  hw/acpi/memory_hotplug.c         | 16 ++++++++++++++++
>  include/hw/acpi/memory_hotplug.h |  2 ++
>  2 files changed, 18 insertions(+)
> 
> diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> index 3d8e398..2b0c8ca 100644
> --- a/hw/acpi/memory_hotplug.c
> +++ b/hw/acpi/memory_hotplug.c
> @@ -227,6 +227,22 @@ void acpi_memory_unplug_request_cb(ACPIREGS *ar, qemu_irq irq,
>      acpi_memory_hotplug_sci(ar, irq);
>  }
>  
> +void acpi_memory_unplug_cb(ACPIREGS *ar, qemu_irq irq,
> +                           MemHotplugState *mem_st,
> +                           DeviceState *dev, Error **errp)
> +{
> +    MemStatus *mdev;
> +
> +    mdev = acpi_memory_get_slot_status_descriptor(mem_st, dev, errp);
> +    if (!mdev)
> +        return;
> +
> +    mdev->is_removing = false;
should be done in acpi_memory_hotplug_write() in the same manner
as it's done for is_inserting field


> +    mdev->is_enabled = false;
> +    object_unparent(OBJECT(mdev->dimm));
it seem wrong, does acpi_memory_plug_cb() do parenting?

Unparenting probably should be done as the last step by PC_MACHINE
when it's cleaned up all connections to dimm.

> +    mdev->dimm = NULL;
> +}
> +
>  static const VMStateDescription vmstate_memhp_sts = {
>      .name = "memory hotplug device state",
>      .version_id = 1,
> diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
> index c437a85..6b8d9f7 100644
> --- a/include/hw/acpi/memory_hotplug.h
> +++ b/include/hw/acpi/memory_hotplug.h
> @@ -32,6 +32,8 @@ void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,
>  void acpi_memory_unplug_request_cb(ACPIREGS *ar, qemu_irq irq,
>                                     MemHotplugState *mem_st,
>                                     DeviceState *dev, Error **errp);
> +void acpi_memory_unplug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,
> +                           DeviceState *dev, Error **errp);
>  
>  extern const VMStateDescription vmstate_memory_hotplug;
>  #define VMSTATE_MEMORY_HOTPLUG(memhp, state) \
diff mbox

Patch

diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index 3d8e398..2b0c8ca 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -227,6 +227,22 @@  void acpi_memory_unplug_request_cb(ACPIREGS *ar, qemu_irq irq,
     acpi_memory_hotplug_sci(ar, irq);
 }
 
+void acpi_memory_unplug_cb(ACPIREGS *ar, qemu_irq irq,
+                           MemHotplugState *mem_st,
+                           DeviceState *dev, Error **errp)
+{
+    MemStatus *mdev;
+
+    mdev = acpi_memory_get_slot_status_descriptor(mem_st, dev, errp);
+    if (!mdev)
+        return;
+
+    mdev->is_removing = false;
+    mdev->is_enabled = false;
+    object_unparent(OBJECT(mdev->dimm));
+    mdev->dimm = NULL;
+}
+
 static const VMStateDescription vmstate_memhp_sts = {
     .name = "memory hotplug device state",
     .version_id = 1,
diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
index c437a85..6b8d9f7 100644
--- a/include/hw/acpi/memory_hotplug.h
+++ b/include/hw/acpi/memory_hotplug.h
@@ -32,6 +32,8 @@  void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,
 void acpi_memory_unplug_request_cb(ACPIREGS *ar, qemu_irq irq,
                                    MemHotplugState *mem_st,
                                    DeviceState *dev, Error **errp);
+void acpi_memory_unplug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,
+                           DeviceState *dev, Error **errp);
 
 extern const VMStateDescription vmstate_memory_hotplug;
 #define VMSTATE_MEMORY_HOTPLUG(memhp, state) \