diff options
author | Igor Mammedov | 2014-06-02 15:25:14 +0200 |
---|---|---|
committer | Michael S. Tsirkin | 2014-06-19 15:41:49 +0200 |
commit | 0cd03d89b98154fcc03d9a8eeea70b9c50cb9457 (patch) | |
tree | 0b49df52f1d3c7a81fb4d7bc94fdc6e06b686dfe /hw/i386 | |
parent | pc-dimm: add busy address check and address auto-allocation (diff) | |
download | qemu-0cd03d89b98154fcc03d9a8eeea70b9c50cb9457.tar.gz qemu-0cd03d89b98154fcc03d9a8eeea70b9c50cb9457.tar.xz qemu-0cd03d89b98154fcc03d9a8eeea70b9c50cb9457.zip |
pc-dimm: add busy slot check and slot auto-allocation
- if slot property is not specified on -device/device_add command,
treat default value as request for assigning PCDIMMDevice to
the first free slot.
- if slot is provided with -device/device_add command, attempt to
use it or fail command if it's already occupied.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/i386')
-rw-r--r-- | hw/i386/pc.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 4dc86d5bc4..be5e3bbafd 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1547,8 +1547,10 @@ void qemu_register_pc_machine(QEMUMachine *m) static void pc_dimm_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { + int slot; Error *local_err = NULL; PCMachineState *pcms = PC_MACHINE(hotplug_dev); + MachineState *machine = MACHINE(hotplug_dev); PCDIMMDevice *dimm = PC_DIMM(dev); PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm); MemoryRegion *mr = ddc->get_memory_region(dimm); @@ -1565,7 +1567,26 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev, if (local_err) { goto out; } + object_property_set_int(OBJECT(dev), addr, PC_DIMM_ADDR_PROP, &local_err); + if (local_err) { + goto out; + } + + slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP, &local_err); + if (local_err) { + goto out; + } + + slot = pc_dimm_get_free_slot(slot == PC_DIMM_UNASSIGNED_SLOT ? NULL : &slot, + machine->ram_slots, &local_err); + if (local_err) { + goto out; + } + object_property_set_int(OBJECT(dev), slot, PC_DIMM_SLOT_PROP, &local_err); + if (local_err) { + goto out; + } memory_region_add_subregion(&pcms->hotplug_memory, addr - pcms->hotplug_memory_base, mr); |