summaryrefslogtreecommitdiff
path: root/hw/i386/pc.c
diff options
context:
space:
mode:
authorIgor Mammedov <imammedo@redhat.com>2014-06-02 15:25:13 +0200
committerMichael S. Tsirkin <mst@redhat.com>2014-06-19 16:41:49 +0300
commit0b3125711606374f04e279aebefcb7275480f040 (patch)
tree4d917c4e2c127a6d044aa3a0113ed7f67e9a0c16 /hw/i386/pc.c
parent95bee274fd1d22dc6d35e52987f8b5d29fe754dd (diff)
downloadqemu-0b3125711606374f04e279aebefcb7275480f040.tar.gz
pc-dimm: add busy address check and address auto-allocation
- if 'addr' property is not specified on -device/device_add command, treat the default value as request for assigning PCDIMMDevice to the first free memory region. - if 'addr' is provided with -device/device_add command, attempt to use it or fail command if it's already occupied or falls inside of an existing PCDIMMDevice memory region. Note: GCompareFunc(a, b) used by g_slist_insert_sorted() returns 'gint', however it might be too small to fit difference between 2 addresses. So use 128bit to calculate the difference and normalize result to -1/0/1 return values. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Andrey Korolyov <andrey@xdel.ru> MST: commit log tweaks
Diffstat (limited to 'hw/i386/pc.c')
-rw-r--r--hw/i386/pc.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 70527d8880..4dc86d5bc4 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1558,6 +1558,15 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev,
goto out;
}
+ addr = pc_dimm_get_free_addr(pcms->hotplug_memory_base,
+ memory_region_size(&pcms->hotplug_memory),
+ !addr ? NULL : &addr,
+ memory_region_size(mr), &local_err);
+ if (local_err) {
+ goto out;
+ }
+ object_property_set_int(OBJECT(dev), addr, PC_DIMM_ADDR_PROP, &local_err);
+
memory_region_add_subregion(&pcms->hotplug_memory,
addr - pcms->hotplug_memory_base, mr);
vmstate_register_ram(mr, dev);