diff options
author | Igor Mammedov | 2014-06-02 15:25:13 +0200 |
---|---|---|
committer | Michael S. Tsirkin | 2014-06-19 15:41:49 +0200 |
commit | 0b3125711606374f04e279aebefcb7275480f040 (patch) | |
tree | 4d917c4e2c127a6d044aa3a0113ed7f67e9a0c16 /hw/i386 | |
parent | pc: add memory hotplug handler to PC_MACHINE (diff) | |
download | qemu-0b3125711606374f04e279aebefcb7275480f040.tar.gz qemu-0b3125711606374f04e279aebefcb7275480f040.tar.xz qemu-0b3125711606374f04e279aebefcb7275480f040.zip |
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')
-rw-r--r-- | hw/i386/pc.c | 9 |
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); |