[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 12/35] dimm: do not allow to set already busy memdev
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH 12/35] dimm: do not allow to set already busy memdev |
Date: |
Fri, 4 Apr 2014 15:36:37 +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 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/hw/mem/dimm.c b/hw/mem/dimm.c
index 76f2a11..65d4cd0 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, "memdev", 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.9.0
- [Qemu-devel] [PATCH 03/35] object_add: allow completion handler to get canonical path, (continued)
- [Qemu-devel] [PATCH 03/35] object_add: allow completion handler to get canonical path, Igor Mammedov, 2014/04/04
- [Qemu-devel] [PATCH 08/35] qdev: hotplug for buss-less devices, Igor Mammedov, 2014/04/04
- [Qemu-devel] [PATCH 09/35] qdev: expose DeviceState.hotplugged field as a property, Igor Mammedov, 2014/04/04
- [Qemu-devel] [PATCH 12/35] dimm: do not allow to set already busy memdev,
Igor Mammedov <=
- [Qemu-devel] [PATCH 11/35] memory: add memory_region_is_mapped() API, Igor Mammedov, 2014/04/04
- [Qemu-devel] [PATCH 02/35] vl: convert -m to QemuOpts, Igor Mammedov, 2014/04/04
- [Qemu-devel] [PATCH 13/35] pc: initialize memory hotplug address space, Igor Mammedov, 2014/04/04
[Qemu-devel] [PATCH 14/35] pc: exit QEMU if slots > 256, Igor Mammedov, 2014/04/04