Skip to contentSkip to conversation

pc, pci, virtio, hotplug fixes, enhancements

GIT PULL Michael S. Tsirkin 1 participant 7 messages Jun 18, 2014 Arm STM32

lore
Share & tools
lore
#0 lore raw

The following changes since commit 0360fbd076e8bdbb9498598b0c559464346babe4:

Merge remote-tracking branch 'remotes/riku/linux-user-for-upstream' into staging (2014-06-17 16:08:06 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to 2de1c32c6aa4fdcef9e1e0c25246329f7cfd2981:

vhost: fix resource leak in error handling (2014-06-18 18:55:22 +0300)

----------------------------------------------------------------
pc,pci,virtio,hotplug fixes, enhancements

numa work by Hu Tao and others
memory hotplug by Igor
vhost-user by Nikolay, Antonios and others
guest virtio announcements by Jason
qtest fixes by Sergey
qdev hotplug fixes by Paolo
misc other fixes mostly by myself

----------------------------------------------------------------
Hu Tao (10):
Introduce signed range.
qom: introduce object_property_get_enum and object_property_get_uint16List backend:hostmem: replace hostmemory with host_memory
hostmem: separate allocation from UserCreatable complete method
hostmem: add properties for NUMA memory policy
qmp: add query-memdev
hmp: add info memdev
tests: fix memory leak in test of string input visitor
qapi: make string input visitor parse int list
qapi: make string output visitor parse int list

Igor Mammedov (40):
pc: create custom generic PC machine type
pc: ACPI BIOS: use enum for defining memory affinity flags
object_add: allow completion handler to get canonical path
vl.c: daemonize before guest memory allocation
add memdev backend infrastructure
vl.c: extend -m option to support options for memory hotplug
qdev: hotplug for bus-less devices
qdev: expose DeviceState.hotplugged field as a property
memory: add memory_region_is_mapped() API
pc-dimm: do not allow setting an in-use memdev
pc: initialize memory hotplug address space
pc: exit QEMU if number of slots more than supported 256
pc: add 'etc/reserved-memory-end' fw_cfg interface for SeaBIOS
pc: exit QEMU if compat machine doesn't support memory hotlpug
pc: add memory hotplug handler to PC_MACHINE
pc-dimm: add busy address check and address auto-allocation
pc-dimm: add busy slot check and slot auto-allocation
acpi: rename cpu_hotplug_defs.h to pc-hotplug.h
acpi: memory hotplug ACPI hardware implementation
trace: add acpi memory hotplug IO region events
trace: pc: add PC_DIMM slot & address allocation
acpi:piix4: allow plug/unlug callbacks handle not only PCI devices acpi:piix4: add memory hotplug handling
pc: ich9 lpc: make it work with global/compat properties acpi:ich9: add memory hotplug handling
pc: migrate piix4 & ich9 MemHotplugState
pc: add acpi-device link to PCMachineState
pc: propagate memory hotplug event to ACPI device
pc: ACPI BIOS: implement memory hotplug interface
pc: add "hotplug-memory-region-size" property to PC_MACHINE
pc: ACPI BIOS: reserve SRAT entry for hotplug mem hole
pc: ACPI BIOS: make GPE.3 handle memory hotplug event on PIIX and Q35 machines
pc: q35: acpi: report error to user on unsupported unplug request
pc: acpi: do not hardcode preprocessor
numa: handle mmaped memory allocation failure correctly
qmp: add query-memory-devices command
acpi: introduce TYPE_ACPI_DEVICE_IF interface
acpi: implement ospm_status() method for PIIX4/ICH9_LPC devices
qmp: add query-acpi-ospm-status command
qmp: add ACPI_DEVICE_OST event handling

Jason Wang (3):
migration: export SELF_ANNOUNCE_ROUNDS
migration: introduce self_announce_delay()
virtio-net: announce self by guest

Luiz Capitulino (1):
man: improve -numa doc

Markus Armbruster (2):
virtio: Drop superfluous conditionals around g_free()
virtio: Drop superfluous conditionals around g_strdup()

Michael S. Tsirkin (11):
acpi: update generated files
acpi-test: update expected tables
ich: get rid of spaces in type name
qapi: fix build on glib < 2.28
qmp: clean out whitespace
acpi: rephrase comment
qapi: fix input visitor bugs
tests: simplify code qapi/string-output-visitor: fix bugs
vhost: block migration if backend does not log memory
vhost: fix resource leak in error handling

Nikolay Nikolaev (18):
Add kvm_eventfds_enabled function
Add chardev API qemu_chr_fe_read_all
Add chardev API qemu_chr_fe_set_msgfds
Add chardev API qemu_chr_fe_get_msgfds
Add G_IO_HUP handler for socket chardev
vhost: add vhost_get_features and vhost_ack_features vhost_net should call the poll callback only when it is set Refactor virtio-net to use generic get_vhost_net vhost_net_init will use VhostNetOptions to get all its arguments Add vhost_ops to vhost_dev struct and replace all relevant ioctls Add vhost-backend and VhostBackendType
Add vhost-user as a vhost backend.
vhost-net: vhost-user feature bits support
Add new vhost-user netdev backend
Add the vhost-user netdev backend to the command line Add vhost-user protocol documentation
libqemustub: add stubs to be able to use qemu-char.c Add qtest for vhost-user

Paolo Bonzini (16):
qmp: improve error reporting for -object and object-add
numa: introduce memory_region_allocate_system_memory
memory: reorganize file-based allocation
memory: move preallocation code out of exec.c
memory: move RAM_PREALLOC_MASK to exec.c, rename
numa: add -numa node,memdev= option
memory: move mem_path handling to memory_region_allocate_system_memory
memory: add error propagation to file-based RAM allocation
vl: redo -object parsing
pc: pass MachineState to pc_memory_init
hostmem: add file-based HostMemoryBackend
hostmem: add merge and dump properties
hostmem: allow preallocation of any memory region
hostmem: add property to map memory with MAP_SHARED
qdev: reorganize error reporting in bus_set_realized
qdev: recursively unrealize devices when unrealizing bus

Vasilis Liaskovitis (1):
pc: implement pc-dimm device abstraction

Wanlong Gao (6):
NUMA: move numa related code to new file numa.c
NUMA: check if the total numa memory size is equal to ram_size
NUMA: Add numa_info structure to contain numa nodes info
NUMA: convert -numa option to use OptsVisitor
NUMA: expand MAX_NODES from 64 to 128
configure: add Linux libnuma detection

 configure                            |  32 ++
 Makefile.target                      |   2 +-
 qapi-schema.json                     | 208 ++++++++-
 hmp.h                                |   1 +
 include/exec/cpu-all.h               |   8 -
 include/exec/cpu-common.h            |   2 +
 include/exec/memory.h                |  41 ++
 include/exec/ram_addr.h              |   4 +
 include/hw/acpi/acpi.h               |   5 +
 include/hw/acpi/acpi_dev_interface.h |  43 ++
 include/hw/acpi/cpu_hotplug.h        |   2 +-
 include/hw/acpi/cpu_hotplug_defs.h   |  32 --
 include/hw/acpi/ich9.h               |   7 +
 include/hw/acpi/memory_hotplug.h     |  38 ++
 include/hw/acpi/pc-hotplug.h         |  56 +++
 include/hw/boards.h                  |  16 +-
 include/hw/i386/ich9.h               |   2 +-
 include/hw/i386/pc.h                 |  79 +++-
 include/hw/mem/pc-dimm.h             |  81 ++++
 include/hw/virtio/vhost-backend.h    |  38 ++
 include/hw/virtio/vhost.h            |  14 +-
 include/hw/virtio/virtio-net.h       |  17 +
 include/migration/vmstate.h          |  10 +
 include/monitor/monitor.h            |   1 +
 include/net/vhost-user.h             |  17 +
 include/net/vhost_net.h              |  11 +-
 include/qemu/osdep.h                 |  12 +
 include/qemu/range.h                 |  72 ++++
 include/qom/object.h                 |  28 ++
 include/sysemu/char.h                |  44 +-
 include/sysemu/cpus.h                |   1 -
 include/sysemu/hostmem.h             |  68 +++
 include/sysemu/kvm.h                 |  11 +
 include/sysemu/sysemu.h              |  18 +-
 net/clients.h                        |   3 +
 backends/hostmem-file.c              | 134 ++++++
 backends/hostmem-ram.c               |  53 +++
 backends/hostmem.c                   | 375 ++++++++++++++++
 cpus.c                               |  14 -
 exec.c                               | 211 +++++----
 hmp.c                                |  36 ++
 hw/9pfs/virtio-9p.c                  |   4 +-
 hw/acpi/acpi_interface.c             |  15 +
 hw/acpi/ich9.c                       |  69 +++
 hw/acpi/memory_hotplug.c             | 245 +++++++++++
 hw/acpi/piix4.c                      |  85 +++-
 hw/core/qdev.c                       |  57 ++-
 hw/i386/acpi-build.c                 |  75 +++-
 hw/i386/pc.c                         | 252 ++++++++++-
 hw/i386/pc_piix.c                    |  59 +--
 hw/i386/pc_q35.c                     |  29 +-
 hw/isa/lpc_ich9.c                    |  38 +-
 hw/mem/pc-dimm.c                     | 281 ++++++++++++
 hw/mips/mips_malta.c                 |   2 +-
 hw/net/vhost_net.c                   | 228 +++++++---
 hw/net/virtio-net.c                  |  98 +++--
 hw/ppc/spapr.c                       |  11 +-
 hw/scsi/vhost-scsi.c                 |  45 +-
 hw/virtio/vhost-backend.c            |  71 +++
 hw/virtio/vhost-user.c               | 342 +++++++++++++++
 hw/virtio/vhost.c                    | 112 +++--
 hw/virtio/virtio.c                   |  16 +-
 kvm-all.c                            |   4 +
 kvm-stub.c                           |   1 +
 memory.c                             |  39 +-
 monitor.c                            |  10 +-
 net/hub.c                            |   1 +
 net/net.c                            |   3 +
 net/tap.c                            |  18 +-
 net/vhost-user.c                     | 258 +++++++++++
 numa.c                               | 369 ++++++++++++++++
 qapi/string-input-visitor.c          | 201 ++++++++-
 qapi/string-output-visitor.c         | 235 +++++++++-
 qemu-char.c                          | 277 ++++++++++--
 qmp.c                                |  44 +-
 qom/object.c                         |  35 ++
 savevm.c                             |   3 +-
 stubs/bdrv-commit-all.c              |   7 +
 stubs/chr-msmouse.c                  |   7 +
 stubs/get-next-serial.c              |   3 +
 stubs/is-daemonized.c                |   7 +
 stubs/machine-init-done.c            |   6 +
 stubs/monitor-init.c                 |   6 +
 stubs/notify-event.c                 |   6 +
 stubs/qmp_pc_dimm_device_list.c      |   7 +
 stubs/vc-init.c                      |   7 +
 tests/test-string-input-visitor.c    |  37 ++
 tests/test-string-output-visitor.c   |  38 +-
 tests/vhost-user-test.c              | 312 ++++++++++++++
 util/oslib-posix.c                   |  73 ++++
 vl.c                                 | 268 +++++-------
 backends/Makefile.objs               |   3 +
 default-configs/i386-softmmu.mak     |   1 +
 default-configs/x86_64-softmmu.mak   |   1 +
 docs/qmp/qmp-events.txt              |  10 +
 docs/specs/acpi_mem_hotplug.txt      |  44 ++
 docs/specs/vhost-user.txt            | 266 ++++++++++++
 hmp-commands.hx                      |   4 +-
 hw/Makefile.objs                     |   1 +
 hw/acpi/Makefile.objs                |   2 +
 hw/i386/Makefile.objs                |   5 +-
 hw/i386/acpi-dsdt.dsl                |   7 +-
 hw/i386/acpi-dsdt.hex.generated      |  31 +-
 hw/i386/q35-acpi-dsdt.dsl            |   7 +-
 hw/i386/q35-acpi-dsdt.hex.generated  |  31 +-
 hw/i386/ssdt-mem.dsl                 |  77 ++++
 hw/i386/ssdt-mem.hex.generated       | 213 +++++++++
 hw/i386/ssdt-misc.dsl                | 164 +++++++
 hw/i386/ssdt-misc.hex.generated      | 811 ++++++++++++++++++++++++++++++++++-
 hw/i386/ssdt-pcihp.hex.generated     |   6 +-
 hw/i386/ssdt-proc.hex.generated      |   6 +-
 hw/mem/Makefile.objs                 |   1 +
 hw/virtio/Makefile.objs              |   2 +-
 net/Makefile.objs                    |   2 +-
 qemu-options.hx                      |  45 +-
 qmp-commands.hx                      |  89 +++-
 stubs/Makefile.objs                  |   9 +
 tests/Makefile                       |   4 +
 tests/acpi-test-data/pc/DSDT         | Bin 4480 -> 4499 bytes
 tests/acpi-test-data/pc/SSDT         | Bin 2269 -> 3065 bytes
 tests/acpi-test-data/q35/DSDT        | Bin 7378 -> 7397 bytes
 tests/acpi-test-data/q35/SSDT        | Bin 550 -> 1346 bytes
 trace-events                         |  17 +
 123 files changed, 7399 insertions(+), 723 deletions(-)
 create mode 100644 include/hw/acpi/acpi_dev_interface.h
 delete mode 100644 include/hw/acpi/cpu_hotplug_defs.h
 create mode 100644 include/hw/acpi/memory_hotplug.h
 create mode 100644 include/hw/acpi/pc-hotplug.h
 create mode 100644 include/hw/mem/pc-dimm.h
 create mode 100644 include/hw/virtio/vhost-backend.h
 create mode 100644 include/net/vhost-user.h
 create mode 100644 include/sysemu/hostmem.h
 create mode 100644 backends/hostmem-file.c
 create mode 100644 backends/hostmem-ram.c
 create mode 100644 backends/hostmem.c
 create mode 100644 hw/acpi/acpi_interface.c
 create mode 100644 hw/acpi/memory_hotplug.c
 create mode 100644 hw/mem/pc-dimm.c
 create mode 100644 hw/virtio/vhost-backend.c
 create mode 100644 hw/virtio/vhost-user.c
 create mode 100644 net/vhost-user.c
 create mode 100644 numa.c
 create mode 100644 stubs/bdrv-commit-all.c
 create mode 100644 stubs/chr-msmouse.c
 create mode 100644 stubs/get-next-serial.c
 create mode 100644 stubs/is-daemonized.c
 create mode 100644 stubs/machine-init-done.c
 create mode 100644 stubs/monitor-init.c
 create mode 100644 stubs/notify-event.c
 create mode 100644 stubs/qmp_pc_dimm_device_list.c
 create mode 100644 stubs/vc-init.c
 create mode 100644 tests/vhost-user-test.c
 create mode 100644 docs/specs/acpi_mem_hotplug.txt
 create mode 100644 docs/specs/vhost-user.txt
 create mode 100644 hw/i386/ssdt-mem.dsl
 create mode 100644 hw/i386/ssdt-mem.hex.generated
 create mode 100644 hw/mem/Makefile.objs
#1 lore raw

[Qemu-devel] [PULL v2 001/108] pc: create custom generic PC machine type

From: Igor Mammedov <[email protected]>

it will be used for PC specific options/variables

---
 include/hw/i386/pc.h | 24 ++++++++++++++++++++++
 hw/i386/pc.c         | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/i386/pc_piix.c    | 36 ++++++++++++++++-----------------
 hw/i386/pc_q35.c     | 12 +++++------
 4 files changed, 105 insertions(+), 24 deletions(-)
include/hw/i386/pc.h +24 -0
index fa9d997..aade1b2 100644
@@ -12,9 +12,33 @@
 #include "qemu/bitmap.h"
 #include "sysemu/sysemu.h"
 #include "hw/pci/pci.h"
+#include "hw/boards.h"
 
 #define HPET_INTCAP "hpet-intcap"
 
+struct PCMachineState {
+    /*< private >*/
+    MachineState parent_obj;
+};
+
+struct PCMachineClass {
+    /*< private >*/
+    MachineClass parent_class;
+};
+
+typedef struct PCMachineState PCMachineState;
+typedef struct PCMachineClass PCMachineClass;
+
+#define TYPE_PC_MACHINE "generic-pc-machine"
+#define PC_MACHINE(obj) \
+    OBJECT_CHECK(PCMachineState, (obj), TYPE_PC_MACHINE)
+#define PC_MACHINE_GET_CLASS(obj) \
+    OBJECT_GET_CLASS(PCMachineClass, (obj), TYPE_PC_MACHINE)
+#define PC_MACHINE_CLASS(klass) \
+    OBJECT_CLASS_CHECK(PCMachineClass, (klass), TYPE_PC_MACHINE)
+
+void qemu_register_pc_machine(QEMUMachine *m);
+
 /* PC-style peripherals (also used by other machines).  */
 
 typedef struct PcPciInfo {
hw/i386/pc.c +57 -0

60 lines not on this page · raw message

hw/i386/pc_piix.c +18 -18
index a48e263..abb599b 100644
@@ -843,25 +843,25 @@ static QEMUMachine xenfv_machine = {
 
 static void pc_machine_init(void)
 {
-    qemu_register_machine(&pc_i440fx_machine_v2_1);
-    qemu_register_machine(&pc_i440fx_machine_v2_0);
-    qemu_register_machine(&pc_i440fx_machine_v1_7);
-    qemu_register_machine(&pc_i440fx_machine_v1_6);
-    qemu_register_machine(&pc_i440fx_machine_v1_5);
-    qemu_register_machine(&pc_i440fx_machine_v1_4);
-    qemu_register_machine(&pc_machine_v1_3);
-    qemu_register_machine(&pc_machine_v1_2);
-    qemu_register_machine(&pc_machine_v1_1);
-    qemu_register_machine(&pc_machine_v1_0);
-    qemu_register_machine(&pc_machine_v0_15);
-    qemu_register_machine(&pc_machine_v0_14);
-    qemu_register_machine(&pc_machine_v0_13);
-    qemu_register_machine(&pc_machine_v0_12);
-    qemu_register_machine(&pc_machine_v0_11);
-    qemu_register_machine(&pc_machine_v0_10);
-    qemu_register_machine(&isapc_machine);
+    qemu_register_pc_machine(&pc_i440fx_machine_v2_1);
+    qemu_register_pc_machine(&pc_i440fx_machine_v2_0);
+    qemu_register_pc_machine(&pc_i440fx_machine_v1_7);
+    qemu_register_pc_machine(&pc_i440fx_machine_v1_6);
+    qemu_register_pc_machine(&pc_i440fx_machine_v1_5);
+    qemu_register_pc_machine(&pc_i440fx_machine_v1_4);
+    qemu_register_pc_machine(&pc_machine_v1_3);
+    qemu_register_pc_machine(&pc_machine_v1_2);
+    qemu_register_pc_machine(&pc_machine_v1_1);
+    qemu_register_pc_machine(&pc_machine_v1_0);
+    qemu_register_pc_machine(&pc_machine_v0_15);
+    qemu_register_pc_machine(&pc_machine_v0_14);
+    qemu_register_pc_machine(&pc_machine_v0_13);
+    qemu_register_pc_machine(&pc_machine_v0_12);
+    qemu_register_pc_machine(&pc_machine_v0_11);
+    qemu_register_pc_machine(&pc_machine_v0_10);
+    qemu_register_pc_machine(&isapc_machine);
 #ifdef CONFIG_XEN
-    qemu_register_machine(&xenfv_machine);
+    qemu_register_pc_machine(&xenfv_machine);
 #endif
 }
 
hw/i386/pc_q35.c +6 -6
index b3c02c1..d211393 100644
@@ -384,12 +384,12 @@ static QEMUMachine pc_q35_machine_v1_4 = {
 
 static void pc_q35_machine_init(void)
 {
-    qemu_register_machine(&pc_q35_machine_v2_1);
-    qemu_register_machine(&pc_q35_machine_v2_0);
-    qemu_register_machine(&pc_q35_machine_v1_7);
-    qemu_register_machine(&pc_q35_machine_v1_6);
-    qemu_register_machine(&pc_q35_machine_v1_5);
-    qemu_register_machine(&pc_q35_machine_v1_4);
+    qemu_register_pc_machine(&pc_q35_machine_v2_1);
+    qemu_register_pc_machine(&pc_q35_machine_v2_0);
+    qemu_register_pc_machine(&pc_q35_machine_v1_7);
+    qemu_register_pc_machine(&pc_q35_machine_v1_6);
+    qemu_register_pc_machine(&pc_q35_machine_v1_5);
+    qemu_register_pc_machine(&pc_q35_machine_v1_4);
 }
 
 machine_init(pc_q35_machine_init);
Signature · 1 line
MST
#2 lore raw

[Qemu-devel] [PULL v2 002/108] pc: ACPI BIOS: use enum for defining memory affinity flags

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

replace magic numbers with enum describing Flags field of memory affinity in SRAT table.

MemoryAffinityFlags enum will define flags decribed by:
ACPI spec 5.0, "5.2.16.2 Memory Affinity Structure", "Table 5-69 Flags - Memory Affinity Structure"

---
 hw/i386/acpi-build.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
hw/i386/acpi-build.c +16 -7
index 1e0aa09..9a41510 100644
@@ -1132,15 +1132,22 @@ build_hpet(GArray *table_data, GArray *linker)
                  (void *)hpet, "HPET", sizeof(*hpet), 1);
 }
 
+typedef enum {
+    MEM_AFFINITY_NOFLAGS      = 0,
+    MEM_AFFINITY_ENABLED      = (1 << 0),
+    MEM_AFFINITY_HOTPLUGGABLE = (1 << 1),
+    MEM_AFFINITY_NON_VOLATILE = (1 << 2),
+} MemoryAffinityFlags;
+
 static void
-acpi_build_srat_memory(AcpiSratMemoryAffinity *numamem,
-                       uint64_t base, uint64_t len, int node, int enabled)
+acpi_build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base,
+                       uint64_t len, int node, MemoryAffinityFlags flags)
 {
     numamem->type = ACPI_SRAT_MEMORY;
     numamem->length = sizeof(*numamem);
     memset(numamem->proximity, 0, 4);
     numamem->proximity[0] = node;
-    numamem->flags = cpu_to_le32(!!enabled);
+    numamem->flags = cpu_to_le32(flags);
     numamem->base_addr = cpu_to_le64(base);
     numamem->range_length = cpu_to_le64(len);
 }
@@ -1188,7 +1195,7 @@ build_srat(GArray *table_data, GArray *linker,
     numa_start = table_data->len;
 
     numamem = acpi_data_push(table_data, sizeof *numamem);
-    acpi_build_srat_memory(numamem, 0, 640*1024, 0, 1);
+    acpi_build_srat_memory(numamem, 0, 640*1024, 0, MEM_AFFINITY_ENABLED);
     next_base = 1024 * 1024;
     for (i = 1; i < guest_info->numa_nodes + 1; ++i) {
         mem_base = next_base;
@@ -1204,19 +1211,21 @@ build_srat(GArray *table_data, GArray *linker,
             mem_len -= next_base - guest_info->ram_size_below_4g;
             if (mem_len > 0) {
                 numamem = acpi_data_push(table_data, sizeof *numamem);
-                acpi_build_srat_memory(numamem, mem_base, mem_len, i-1, 1);
+                acpi_build_srat_memory(numamem, mem_base, mem_len, i - 1,
+                                       MEM_AFFINITY_ENABLED);
             }
             mem_base = 1ULL << 32;
             mem_len = next_base - guest_info->ram_size_below_4g;
             next_base += (1ULL << 32) - guest_info->ram_size_below_4g;
         }
         numamem = acpi_data_push(table_data, sizeof *numamem);
-        acpi_build_srat_memory(numamem, mem_base, mem_len, i - 1, 1);
+        acpi_build_srat_memory(numamem, mem_base, mem_len, i - 1,
+                               MEM_AFFINITY_ENABLED);
     }
     slots = (table_data->len - numa_start) / sizeof *numamem;
     for (; slots < guest_info->numa_nodes + 2; slots++) {
         numamem = acpi_data_push(table_data, sizeof *numamem);
-        acpi_build_srat_memory(numamem, 0, 0, 0, 0);
+        acpi_build_srat_memory(numamem, 0, 0, 0, MEM_AFFINITY_NOFLAGS);
     }
 
     build_header(linker, table_data,
Signature · 1 line
MST
#3 lore raw

[Qemu-devel] [PULL v2 005/108] add memdev backend infrastructure

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Provides framework for splitting host RAM allocation/ policies into a separate backend that could be used by devices.

Initially only legacy RAM backend is provided, which uses memory_region_init_ram() allocator and compatible with every CLI option that affects memory_region_init_ram().

---
 include/sysemu/hostmem.h | 60 ++++++++++++++++++++++++++++++
 backends/hostmem-ram.c   | 54 +++++++++++++++++++++++++++
 backends/hostmem.c       | 97 ++++++++++++++++++++++++++++++++++++++++++++++++
 backends/Makefile.objs   |  2 +
 4 files changed, 213 insertions(+)
 create mode 100644 include/sysemu/hostmem.h
 create mode 100644 backends/hostmem-ram.c
 create mode 100644 backends/hostmem.c
include/sysemu/hostmem.h new file +60 -0
new file mode 100644
index 0000000..4fc081e
@@ -0,0 +1,60 @@
+/*
+ * QEMU Host Memory Backend
+ *
+ * Copyright (C) 2013-2014 Red Hat Inc
+ *
+ * Authors:
+ *   Igor Mammedov <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef QEMU_RAM_H
+#define QEMU_RAM_H
+
+#include "qom/object.h"
+#include "qapi/error.h"
+#include "exec/memory.h"
+#include "qemu/option.h"
+
+#define TYPE_MEMORY_BACKEND "memory-backend"
+#define MEMORY_BACKEND(obj) \
+    OBJECT_CHECK(HostMemoryBackend, (obj), TYPE_MEMORY_BACKEND)
+#define MEMORY_BACKEND_GET_CLASS(obj) \
+    OBJECT_GET_CLASS(HostMemoryBackendClass, (obj), TYPE_MEMORY_BACKEND)
+#define MEMORY_BACKEND_CLASS(klass) \
+    OBJECT_CLASS_CHECK(HostMemoryBackendClass, (klass), TYPE_MEMORY_BACKEND)
+
+typedef struct HostMemoryBackend HostMemoryBackend;
+typedef struct HostMemoryBackendClass HostMemoryBackendClass;
+
+/**
+ * HostMemoryBackendClass:
+ * @parent_class: opaque parent class container
+ */
+struct HostMemoryBackendClass {
+    ObjectClass parent_class;
+};
+
+/**
+ * @HostMemoryBackend
+ *
+ * @parent: opaque parent object container
+ * @size: amount of memory backend provides
+ * @id: unique identification string in memdev namespace
+ * @mr: MemoryRegion representing host memory belonging to backend
+ */
+struct HostMemoryBackend {
+    /* private */
+    Object parent;
+
+    /* protected */
+    uint64_t size;
+
+    MemoryRegion mr;
+};
+
+MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend,
+                                             Error **errp);
+
+#endif
backends/hostmem-ram.c new file +54 -0

54 lines not on this page · raw message

backends/hostmem.c new file +97 -0

97 lines not on this page · raw message

backends/Makefile.objs +2 -0
index 591ddcf..7fb7acd 100644
@@ -6,3 +6,5 @@ common-obj-$(CONFIG_BRLAPI) += baum.o
 baum.o-cflags := $(SDL_CFLAGS)
 
 common-obj-$(CONFIG_TPM) += tpm.o
+
+common-obj-y += hostmem.o hostmem-ram.o
Signature · 1 line
MST
#4 lore raw

[Qemu-devel] [PULL v2 006/108] vl.c: extend -m option to support options for memory hotplug

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Add following parameters:
"slots" - total number of hotplug memory slots
"maxmem" - maximum possible memory

"slots" and "maxmem" should go in pair and "maxmem" should be greater than "mem" for memory hotplug to be enabled.

---
 include/hw/boards.h |  2 ++
 vl.c                | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 qemu-options.hx     |  9 ++++++---
 3 files changed, 59 insertions(+), 3 deletions(-)
include/hw/boards.h +2 -0
index 2d2e2be..184d245 100644
@@ -113,6 +113,8 @@ struct MachineState {
     char *firmware;
 
     ram_addr_t ram_size;
+    ram_addr_t maxram_size;
+    uint64_t   ram_slots;
     const char *boot_order;
     char *kernel_filename;
     char *kernel_cmdline;
vl.c +51 -0

81 lines not on this page · raw message

qemu-options.hx +6 -3
index d0714c4..5a4eff9 100644
@@ -210,17 +210,20 @@ use is discouraged as it may be removed from future versions.
 ETEXI
 
 DEF("m", HAS_ARG, QEMU_OPTION_m,
-    "-m [size=]megs\n"
+    "-m[emory] [size=]megs[,slots=n,maxmem=size]\n"
     "                configure guest RAM\n"
     "                size: initial amount of guest memory (default: "
-    stringify(DEFAULT_RAM_SIZE) "MiB)\n",
+    stringify(DEFAULT_RAM_SIZE) "MiB)\n"
+    "                slots: number of hotplug slots (default: none)\n"
+    "                maxmem: maximum amount of guest memory (default: none)\n",
     QEMU_ARCH_ALL)
 STEXI
 @item -m [size=]@var{megs}
 @findex -m
 Set virtual RAM size to @var{megs} megabytes. Default is 128 MiB.  Optionally,
 a suffix of ``M'' or ``G'' can be used to signify a value in megabytes or
-gigabytes respectively.
+gigabytes respectively. Optional pair @var{slots}, @var{maxmem} could be used
+to set amount of hotluggable memory slots and possible maximum amount of memory.
 ETEXI
 
 DEF("mem-path", HAS_ARG, QEMU_OPTION_mempath,
Signature · 1 line
MST
#5 lore raw

[Qemu-devel] [PULL v2 007/108] qdev: hotplug for bus-less devices

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Add get_hotplug_handler() method to machine, and make bus-less device use it during hotplug as a means to discover a hotplug handler controller. The returned controller is used to perform hotplug actions.

---
 include/hw/boards.h |  8 ++++++++
 hw/core/qdev.c      | 13 +++++++++++++
 2 files changed, 21 insertions(+)
include/hw/boards.h +8 -0
index 184d245..429ac43 100644
@@ -61,6 +61,11 @@ extern MachineState *current_machine;
 /**
  * MachineClass:
  * @qemu_machine: #QEMUMachine
+ * @get_hotplug_handler: this function is called during bus-less
+ *    device hotplug. If defined it returns pointer to an instance
+ *    of HotplugHandler object, which handles hotplug operation
+ *    for a given @dev. It may return NULL if @dev doesn't require
+ *    any actions to be performed by hotplug handler.
  */
 struct MachineClass {
     /*< private >*/
@@ -90,6 +95,9 @@ struct MachineClass {
     const char *default_boot_order;
     GlobalProperty *compat_props;
     const char *hw_version;
+
+    HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
+                                           DeviceState *dev);
 };
 
 /**
hw/core/qdev.c +13 -0
index e65a5aa..fded645 100644
@@ -34,6 +34,7 @@
 #include "qapi/qmp/qjson.h"
 #include "monitor/monitor.h"
 #include "hw/hotplug.h"
+#include "hw/boards.h"
 
 int qdev_hotplug = 0;
 static bool qdev_hot_added = false;
@@ -813,6 +814,18 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
             local_err == NULL) {
             hotplug_handler_plug(dev->parent_bus->hotplug_handler,
                                  dev, &local_err);
+        } else if (local_err == NULL &&
+                   object_dynamic_cast(qdev_get_machine(), TYPE_MACHINE)) {
+            HotplugHandler *hotplug_ctrl;
+            MachineState *machine = MACHINE(qdev_get_machine());
+            MachineClass *mc = MACHINE_GET_CLASS(machine);
+
+            if (mc->get_hotplug_handler) {
+                hotplug_ctrl = mc->get_hotplug_handler(machine, dev);
+                if (hotplug_ctrl) {
+                    hotplug_handler_plug(hotplug_ctrl, dev, &local_err);
+                }
+            }
         }
 
         if (qdev_get_vmsd(dev) && local_err == NULL) {
Signature · 1 line
MST
#6 lore raw

[Qemu-devel] [PULL v2 008/108] qdev: expose DeviceState.hotplugged field as a property

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

so that management could detect via QOM interface if device was hotplugged

---
 hw/core/qdev.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
hw/core/qdev.c +17 -0
index fded645..3226a71 100644
@@ -878,6 +878,20 @@ static bool device_get_hotpluggable(Object *obj, Error **errp)
                                 dev->parent_bus->allow_hotplug);
 }
 
+static bool device_get_hotplugged(Object *obj, Error **err)
+{
+    DeviceState *dev = DEVICE(obj);
+
+    return dev->hotplugged;
+}
+
+static void device_set_hotplugged(Object *obj, bool value, Error **err)
+{
+    DeviceState *dev = DEVICE(obj);
+
+    dev->hotplugged = value;
+}
+
 static void device_initfn(Object *obj)
 {
     DeviceState *dev = DEVICE(obj);
@@ -896,6 +910,9 @@ static void device_initfn(Object *obj)
                              device_get_realized, device_set_realized, NULL);
     object_property_add_bool(obj, "hotpluggable",
                              device_get_hotpluggable, NULL, NULL);
+    object_property_add_bool(obj, "hotplugged",
+                             device_get_hotplugged, device_set_hotplugged,
+                             &error_abort);
 
     class = object_get_class(OBJECT(dev));
     do {
Signature · 1 line
MST