As opposed to previous approach, This series allows to hotplug 'arbitrary' DIMM devices specifying size, NUMA node mapping, slot and address where to map it, at runtime.
Due to ACPI limitation there is need to specify a number of possible DIMM devices. For this task -m option was extended to support following format: -m [mem=]RamSize[,slots=N,maxmem=M] To allow memory hotplug user must specify a pair additional parameters: 'slots' - number of possible increments 'maxmem' - max possible total memory size QEMU is allowed to use, including RamSize. minimal monitor command syntax to hotplug DIMM device: device_add dimm,id=dimmX DIMM device provides following properties that could be used with device_add / -device to alter default behavior: id - unique string identifying device [mandatory] slot - number in range [0-slots) [optional], if not specified the first free slot is used node - NUMA node id [optional] (default: 0) size - amount of memory to add [optional] (default: 1Gb) start - guest's physical address where to plug DIMM [optional], if not specified the first gap in hotplug memory region that fits DIMM is used -device option could be used for adding potentially hotunplugable DIMMs and also for specifying hotplugged DIMMs in migration case (not tested). Current implementation supports only x86-64 variant and places hotplug memory region above 4Gb before 64-bit PCI hole. Tested guests: - Fedora 19x64 - Windows 2012DCx64 - Windows 2008DCx64 Known limitations/bugs/TODOs: - only hot-add supported - q35 is not supported yet - max number of supported DIMM devices 255 (due to ACPI object name limit), could be increased creating several containers and putting DIMMs there. (exercise for future) - failed hotplug action consumes 1 slot (device_add doesn't delete device if realize failed) - e820 table doesn't include DIMM devices added with -device / (or after reboot devices added with device_add) - Windows 2008 remembers DIMM configuration, so if DIMM with other start/size is added into the same slot, it refuses to use it insisting on old mapping. Series is based on mst's acpi tables branch and requires corresponding seabios tree: git://git.kernel.org/pub/scm/virt/kvm/mst/seabios.git acpi Git tree for testing available at: https://github.com/imammedo/qemu/commits/memhp-v6 Example QEMU cmd line: qemu-system-x86_64 -enable-kvm -monitor unix:/tmp/mon,server,nowait \ -m 4096,slots=4,maxmem=8G -L /custome_seabios guest.img PS: Windows guest requires SRAT table for hotplug to work so add extra option: -numa node to QEMU command line. Igor Mammedov (13): pc: use pci_hole64 info consistently vl: set default ram_size during variable initialization vl: convert -m to qemu_opts_parse() dimm: map DimmDevice into DimBus provided address space pc: piix: make hotplug memory gap in high memory pc: i440fx: add DimmBus to chipset and map it into hotplug memory region dimm: add busy slot check and slot auto-allocation dimm: add busy address check and address auto-allocation dimm: introduce memory added notifier acpi/piix4: introduce memory hot-plug interface QEMU<->ACPI BIOS pc: ACPI BIOS: implement memory hotplug interface pc: update acpi-dsdt.hex.generated and add ssdt-mem.hex.generated pc: ACPI BIOS: reserve SRAT entry for hotplug mem hole Vasilis Liaskovitis (3): qapi: make visit_type_size fallback to type_int qdev: Add SIZE type to qdev properties dimm: implement dimm device abstraction default-configs/x86_64-softmmu.mak | 1 + docs/specs/acpi_mem_hotplug.txt | 38 +++ hw/Makefile.objs | 1 + hw/acpi/piix4.c | 170 ++++++++++- hw/core/qdev-properties.c | 55 +++ hw/i386/Makefile.objs | 2 +- hw/i386/acpi-build.c | 62 +++- hw/i386/acpi-dsdt-mem-hotplug.dsl | 144 ++++++++ hw/i386/acpi-dsdt.dsl | 5 +- hw/i386/acpi-dsdt.hex.generated | 633 +++++++++++++++++++++++++++++++++++- hw/i386/pc.c | 10 +- hw/i386/pc_piix.c | 5 +- hw/i386/ssdt-mem.dsl | 76 +++++ hw/i386/ssdt-mem.hex.generated | 161 +++++++++ hw/mem-hotplug/Makefile.objs | 1 + hw/mem-hotplug/dimm.c | 244 ++++++++++++++ hw/pci-host/piix.c | 29 ++- hw/pci-host/q35.c | 7 +- include/hw/i386/pc.h | 4 +- include/hw/mem-hotplug/dimm.h | 91 +++++ include/hw/qdev-properties.h | 3 + include/qemu/option.h | 2 + include/sysemu/sysemu.h | 3 + qapi/qapi-visit-core.c | 11 +- qemu-options.hx | 9 +- stubs/Makefile.objs | 1 + stubs/memory_hotplug.c | 6 + util/qemu-option.c | 2 +- vl.c | 60 +++- 29 files changed, 1782 insertions(+), 54 deletions(-) create mode 100644 docs/specs/acpi_mem_hotplug.txt create mode 100644 hw/i386/acpi-dsdt-mem-hotplug.dsl create mode 100644 hw/i386/ssdt-mem.dsl create mode 100644 hw/i386/ssdt-mem.hex.generated create mode 100644 hw/mem-hotplug/Makefile.objs create mode 100644 hw/mem-hotplug/dimm.c create mode 100644 include/hw/mem-hotplug/dimm.h create mode 100644 stubs/memory_hotplug.c