acpi, mem-hotplug: add unplug cb for memory device

This patch adds unplug cb for memory device. It resets memory status
"is_enabled" in acpi_memory_unplug_cb(), removes the corresponding
memory region, unregisters vmstate, and unparents the object.

Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Tang Chen 2015-04-27 16:47:18 +08:00 committed by Michael S. Tsirkin
parent 64fec58e8a
commit f7d3e29db5
5 changed files with 64 additions and 6 deletions

View file

@ -237,6 +237,20 @@ void acpi_memory_unplug_request_cb(ACPIREGS *ar, qemu_irq irq,
acpi_update_sci(ar, irq);
}
void acpi_memory_unplug_cb(MemHotplugState *mem_st,
DeviceState *dev, Error **errp)
{
MemStatus *mdev;
mdev = acpi_memory_slot_status(mem_st, dev, errp);
if (!mdev) {
return;
}
mdev->is_enabled = false;
mdev->dimm = NULL;
}
static const VMStateDescription vmstate_memhp_sts = {
.name = "memory hotplug device state",
.version_id = 1,