summaryrefslogtreecommitdiffstats
path: root/hw
diff options
context:
space:
mode:
authorLaurent Vivier2017-05-23 13:18:09 +0200
committerDavid Gibson2017-05-24 09:27:39 +0200
commitc871bc70bb22d1d70451bc813ecb008fe98cc92b (patch)
tree1ef96adb6898e419a2068502324d90805ec9876a /hw
parentpseries: Restore support for total vcpus not a multiple of threads-per-core f... (diff)
downloadqemu-c871bc70bb22d1d70451bc813ecb008fe98cc92b.tar.gz
qemu-c871bc70bb22d1d70451bc813ecb008fe98cc92b.tar.xz
qemu-c871bc70bb22d1d70451bc813ecb008fe98cc92b.zip
spapr: add pre_plug function for memory
This allows to manage errors before the memory has started to be hotplugged. We already have the function for the CPU cores. Signed-off-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Greg Kurz <groug@kaod.org> [dwg: Fixed a couple of style nits] Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'hw')
-rw-r--r--hw/ppc/spapr.c41
1 files changed, 26 insertions, 15 deletions
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index bcb0e184a0..3760d37c02 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2578,20 +2578,6 @@ static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
uint64_t align = memory_region_get_alignment(mr);
uint64_t size = memory_region_size(mr);
uint64_t addr;
- char *mem_dev;
-
- if (size % SPAPR_MEMORY_BLOCK_SIZE) {
- error_setg(&local_err, "Hotplugged memory size must be a multiple of "
- "%lld MB", SPAPR_MEMORY_BLOCK_SIZE/M_BYTE);
- goto out;
- }
-
- mem_dev = object_property_get_str(OBJECT(dimm), PC_DIMM_MEMDEV_PROP, NULL);
- if (mem_dev && !kvmppc_is_mem_backend_page_size_ok(mem_dev)) {
- error_setg(&local_err, "Memory backend has bad page size. "
- "Use 'memory-backend-file' with correct mem-path.");
- goto out;
- }
pc_dimm_memory_plug(dev, &ms->hotplug_memory, mr, align, &local_err);
if (local_err) {
@@ -2612,6 +2598,29 @@ out:
error_propagate(errp, local_err);
}
+static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
+ Error **errp)
+{
+ PCDIMMDevice *dimm = PC_DIMM(dev);
+ PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
+ MemoryRegion *mr = ddc->get_memory_region(dimm);
+ uint64_t size = memory_region_size(mr);
+ char *mem_dev;
+
+ if (size % SPAPR_MEMORY_BLOCK_SIZE) {
+ error_setg(errp, "Hotplugged memory size must be a multiple of "
+ "%lld MB", SPAPR_MEMORY_BLOCK_SIZE / M_BYTE);
+ return;
+ }
+
+ mem_dev = object_property_get_str(OBJECT(dimm), PC_DIMM_MEMDEV_PROP, NULL);
+ if (mem_dev && !kvmppc_is_mem_backend_page_size_ok(mem_dev)) {
+ error_setg(errp, "Memory backend has bad page size. "
+ "Use 'memory-backend-file' with correct mem-path.");
+ return;
+ }
+}
+
typedef struct sPAPRDIMMState {
uint32_t nr_lmbs;
} sPAPRDIMMState;
@@ -3006,7 +3015,9 @@ static void spapr_machine_device_unplug_request(HotplugHandler *hotplug_dev,
static void spapr_machine_device_pre_plug(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
- if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) {
+ if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
+ spapr_memory_pre_plug(hotplug_dev, dev, errp);
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) {
spapr_core_pre_plug(hotplug_dev, dev, errp);
}
}