From 5c585fbc5615b92675d83015f2d3009235f903af Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Mon, 8 Jun 2015 00:52:00 +0200 Subject: [PATCH 02/44] acpi, mem-hotplug: add acpi_memory_slot_status() to get MemStatus Message-id: <1433724727-46928-3-git-send-email-imammedo@redhat.com> Patchwork-id: 65389 O-Subject: [RHEL-7.2 qemu-kvm-rhev PATCH 2/9] acpi, mem-hotplug: add acpi_memory_slot_status() to get MemStatus Bugzilla: 1120706 RH-Acked-by: Michael S. Tsirkin RH-Acked-by: Andrew Jones RH-Acked-by: Laszlo Ersek From: Tang Chen 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. Reviewed-by: Igor Mammedov Signed-off-by: Tang Chen Signed-off-by: Zhu Guihua Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 4aae99b63333e71b2097b106bb15a6fde7f9b55b) Signed-off-by: Miroslav Rezanina --- 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.8.3.1