[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 11/31] dimm: do not allow to set already used mem
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH v2 11/31] dimm: do not allow to set already used memdev |
Date: |
Tue, 20 May 2014 17:15:14 +0200 |
using the same memdev backend more than once will cause
assersion at MemoryRegion mapping time becase it's already
mapped. Prevent it by checking that associated MemoryRegion
is not mapped.
Signed-off-by: Igor Mammedov <address@hidden>
---
hw/mem/dimm.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/hw/mem/dimm.c b/hw/mem/dimm.c
index bb81679..713ded5 100644
--- a/hw/mem/dimm.c
+++ b/hw/mem/dimm.c
@@ -42,6 +42,21 @@ static void dimm_get_size(Object *obj, Visitor *v, void
*opaque,
visit_type_int(v, &value, name, errp);
}
+static void dimm_check_memdev_is_busy(Object *obj, const char *name,
+ Object *val, Error **errp)
+{
+ MemoryRegion *mr;
+
+ mr = host_memory_backend_get_memory(MEMORY_BACKEND(val), errp);
+ if (memory_region_is_mapped(mr)) {
+ char *path = object_get_canonical_path_component(val);
+ error_setg(errp, "can't use already busy memdev: %s", path);
+ g_free(path);
+ } else {
+ qdev_prop_allow_set_link_before_realize(obj, name, val, errp);
+ }
+}
+
static void dimm_initfn(Object *obj)
{
DimmDevice *dimm = DIMM(obj);
@@ -50,7 +65,7 @@ static void dimm_initfn(Object *obj)
NULL, NULL, NULL, &error_abort);
object_property_add_link(obj, DIMM_MEMDEV_PROP, TYPE_MEMORY_BACKEND,
(Object **)&dimm->hostmem,
- qdev_prop_allow_set_link_before_realize,
+ dimm_check_memdev_is_busy,
OBJ_PROP_LINK_UNREF_ON_RELEASE,
&error_abort);
}
--
1.7.1
- [Qemu-devel] [PATCH v2 02/31] object_add: allow completion handler to get canonical path, (continued)
- [Qemu-devel] [PATCH v2 02/31] object_add: allow completion handler to get canonical path, Igor Mammedov, 2014/05/20
- [Qemu-devel] [PATCH v2 04/31] add memdev backend infrastructure, Igor Mammedov, 2014/05/20
- [Qemu-devel] [PATCH v2 03/31] vl.c: daemonize before guest memory allocation, Igor Mammedov, 2014/05/20
- [Qemu-devel] [PATCH v2 06/31] pc: create custom generic PC machine type, Igor Mammedov, 2014/05/20
- [Qemu-devel] [PATCH v2 05/31] vl.c: extend -m option to support options for memory hotplug, Igor Mammedov, 2014/05/20
- [Qemu-devel] [PATCH v2 07/31] qdev: hotplug for buss-less devices, Igor Mammedov, 2014/05/20
- [Qemu-devel] [PATCH v2 08/31] qdev: expose DeviceState.hotplugged field as a property, Igor Mammedov, 2014/05/20
- [Qemu-devel] [PATCH v2 09/31] dimm: implement dimm device abstraction, Igor Mammedov, 2014/05/20
- [Qemu-devel] [PATCH v2 10/31] memory: add memory_region_is_mapped() API, Igor Mammedov, 2014/05/20
- [Qemu-devel] [PATCH v2 11/31] dimm: do not allow to set already used memdev,
Igor Mammedov <=
- [Qemu-devel] [PATCH v2 13/31] pc: exit QEMU if number of slots more than supported 256, Igor Mammedov, 2014/05/20
- [Qemu-devel] [PATCH v2 14/31] pc: add 'etc/reserved-memory-end' fw_cfg interface for SeaBIOS, Igor Mammedov, 2014/05/20
- [Qemu-devel] [PATCH v2 15/31] pc: add memory hotplug handler to PC_MACHINE, Igor Mammedov, 2014/05/20
- [Qemu-devel] [PATCH v2 16/31] dimm: add busy address check and address auto-allocation, Igor Mammedov, 2014/05/20
- [Qemu-devel] [PATCH v2 17/31] dimm: add busy slot check and slot auto-allocation, Igor Mammedov, 2014/05/20
- [Qemu-devel] [PATCH v2 18/31] acpi: rename cpu_hotplug_defs.h to acpi_defs.h, Igor Mammedov, 2014/05/20
- [Qemu-devel] [PATCH v2 19/31] acpi: memory hotplug ACPI hardware implementation, Igor Mammedov, 2014/05/20
- [Qemu-devel] [PATCH v2 21/31] trace: pc: add DIMM slot & address allocation, Igor Mammedov, 2014/05/20