qemu/hw
David Hildenbrand aa910c20ec s390x: virtio-mem support
Let's add our virtio-mem-ccw proxy device and wire it up. We should
be supporting everything (e.g., device unplug, "dynamic-memslots") that
we already support for the virtio-pci variant.

With a Linux guest that supports virtio-mem (and has automatic memory
onlining properly configured) the following example will work:

1. Start a VM with 4G initial memory and a virtio-mem device with a maximum
   capacity of 16GB:

   qemu/build/qemu-system-s390x \
    --enable-kvm \
    -m 4G,maxmem=20G \
    -nographic \
    -smp 8 \
    -hda Fedora-Server-KVM-40-1.14.s390x.qcow2 \
    -chardev socket,id=monitor,path=/var/tmp/monitor,server,nowait \
    -mon chardev=monitor,mode=readline \
    -object memory-backend-ram,id=mem0,size=16G,reserve=off \
    -device virtio-mem-ccw,id=vmem0,memdev=mem0,dynamic-memslots=on

2. Query the current size of virtio-mem device:

    (qemu) info memory-devices
    Memory device [virtio-mem]: "vmem0"
      memaddr: 0x100000000
      node: 0
      requested-size: 0
      size: 0
      max-size: 17179869184
      block-size: 1048576
      memdev: /objects/mem0

3. Request to grow it to 8GB (hotplug 8GB):

    (qemu) qom-set vmem0 requested-size 8G
    (qemu) info memory-devices
    Memory device [virtio-mem]: "vmem0"
      memaddr: 0x100000000
      node: 0
      requested-size: 8589934592
      size: 8589934592
      max-size: 17179869184
      block-size: 1048576
      memdev: /objects/mem0

4. Request to grow to 16GB (hotplug another 8GB):

    (qemu) qom-set vmem0 requested-size 16G
    (qemu) info memory-devices
    Memory device [virtio-mem]: "vmem0"
      memaddr: 0x100000000
      node: 0
      requested-size: 17179869184
      size: 17179869184
      max-size: 17179869184
      block-size: 1048576
      memdev: /objects/mem0

5. Try to hotunplug all memory again, shrinking to 0GB:

    (qemu) qom-set vmem0 requested-size 0G
    (qemu) info memory-devices
    Memory device [virtio-mem]: "vmem0"
      memaddr: 0x100000000
      node: 0
      requested-size: 0
      size: 0
      max-size: 17179869184
      block-size: 1048576
      memdev: /objects/mem0

6. If it worked, unplug the device

    (qemu) device_del vmem0
    (qemu) info memory-devices
    (qemu) object_del mem0

7. Hotplug a new device with a smaller capacity and directly size it to 1GB

    (qemu) object_add memory-backend-ram,id=mem0,size=8G,reserve=off
    (qemu) device_add virtio-mem-ccw,id=vmem0,memdev=mem0,\
                      dynamic-memslots=on,requested-size=1G
    (qemu) info memory-devices
    Memory device [virtio-mem]: "vmem0"
      memaddr: 0x100000000
      node: 0
      requested-size: 1073741824
      size: 1073741824
      max-size: 8589934592
      block-size: 1048576
      memdev: /objects/mem0

Trying to use a virtio-mem device backed by hugetlb into a !hugetlb VM
correctly results in the error:
   ... Memory device uses a bigger page size than initial memory

Note that the virtio-mem driver in Linux will supports 1 MiB (pageblock)
granularity.

Message-ID: <20241219144115.2820241-15-david@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
2024-12-21 20:15:06 +01:00
..
9pfs hw/9pfs: Constify all Property 2024-12-15 12:54:19 -06:00
acpi hw/acpi: Constify all Property 2024-12-15 12:54:23 -06:00
adc hw/adc: Constify all Property 2024-12-15 12:54:25 -06:00
alpha alpha: switch boards to "default y" 2024-05-03 15:47:47 +02:00
arm hw/arm: Constify all Property 2024-12-15 12:54:27 -06:00
audio hw/audio: Constify all Property 2024-12-15 12:54:30 -06:00
avr hw/avr: Constify all Property 2024-12-15 12:54:33 -06:00
block hw/block: Constify all Property 2024-12-15 12:54:38 -06:00
char hw/char: Constify all Property 2024-12-15 12:54:40 -06:00
core x86/loader: fix efi binary loading 2024-12-16 14:20:33 -05:00
cpu hw/cpu: Constify all Property 2024-12-15 12:54:47 -06:00
cxl hw/cxl: Constify all Property 2024-12-15 12:54:49 -06:00
display hw/display: Constify all Property 2024-12-15 12:54:51 -06:00
dma hw/dma: Constify all Property 2024-12-15 12:54:54 -06:00
fsi hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
gpio hw/gpio: Constify all Property 2024-12-15 12:54:56 -06:00
hppa hw: Use pci_bus_add_fw_cfg_extra_pci_roots() 2024-12-14 00:16:20 +01:00
hyperv hw/hyperv: Constify all Property 2024-12-15 12:54:59 -06:00
i2c hw/i2c: Constify all Property 2024-12-15 12:55:01 -06:00
i386 x86/loader: fix efi binary loading 2024-12-16 14:20:33 -05:00
ide hw/ide: Constify all Property 2024-12-15 12:55:06 -06:00
input hw/input: Constify all Property 2024-12-15 12:55:09 -06:00
intc loongarch queue 2024-12-19 15:46:43 -05:00
ipack hw/ipack: Constify all Property 2024-12-15 12:55:14 -06:00
ipmi hw/ipmi: Constify all Property 2024-12-15 12:55:16 -06:00
isa hw/isa: Constify all Property 2024-12-15 12:55:19 -06:00
loongarch hw/intc/loongarch_pch: Code cleanup about loongarch_pch_pic 2024-12-19 15:23:29 +08:00
m68k hw/m68k: Constify all Property 2024-12-15 12:55:21 -06:00
mem hw/mem: Constify all Property 2024-12-15 12:55:29 -06:00
microblaze hw/microblaze/s3adsp1800: Declare machine type using DEFINE_TYPES macro 2024-11-05 23:32:13 +00:00
mips hw/mips: Constify all Property 2024-12-15 12:55:31 -06:00
misc hw/misc: Constify all Property 2024-12-15 12:55:39 -06:00
net hw/net: Constify all Property 2024-12-15 12:55:41 -06:00
nubus hw/nubus: Constify all Property 2024-12-15 12:55:44 -06:00
nvme hw/nvme: Constify all Property 2024-12-15 12:55:46 -06:00
nvram hw/nvram: Constify all Property 2024-12-15 12:55:49 -06:00
openrisc hw/openrisc/openrisc_sim: keep serial@90000000 as default 2024-12-03 12:26:24 +01:00
pci hw/pci: Constify all Property 2024-12-15 12:55:56 -06:00
pci-bridge hw/pci-bridge: Constify all Property 2024-12-15 12:55:51 -06:00
pci-host hw/pci-host: Constify all Property 2024-12-15 12:55:54 -06:00
ppc hw/ppc: Constify all Property 2024-12-15 12:55:59 -06:00
remote hw/remote: Constify all Property 2024-12-15 12:56:01 -06:00
riscv hw/riscv: Constify all Property 2024-12-15 12:56:03 -06:00
rtc hw/rtc: Constify all Property 2024-12-15 12:56:06 -06:00
rx hw/rx: Constify all Property 2024-12-15 12:56:08 -06:00
s390x s390x: virtio-mem support 2024-12-21 20:15:06 +01:00
scsi hw/scsi: Constify all Property 2024-12-15 12:56:12 -06:00
sd hw/sd: Constify all Property 2024-12-15 12:56:15 -06:00
sensor hw/sensor: Replace type_register() with type_register_static() 2024-12-10 18:49:25 +01:00
sh4 hw/sh4/r2d: Include missing 'exec/tswap.h' header 2024-12-14 00:16:20 +01:00
smbios smbios: make memory device size configurable per Machine 2024-07-22 20:15:41 -04:00
sparc hw/sparc: Constify all Property 2024-12-15 12:56:17 -06:00
sparc64 hw/sparc64: Constify all Property 2024-12-15 12:56:19 -06:00
ssi hw/ssi: Constify all Property 2024-12-15 12:56:22 -06:00
timer hw/timer: Constify all Property 2024-12-15 12:56:26 -06:00
tpm hw/tpm: Constify all Property 2024-12-15 12:56:29 -06:00
tricore hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
ufs hw/ufs: Constify all Property 2024-12-15 12:56:32 -06:00
usb hw/usb: Constify all Property 2024-12-15 12:56:34 -06:00
vfio hw/vfio: Constify all Property 2024-12-15 12:56:37 -06:00
virtio s390x: virtio-mem support 2024-12-21 20:15:06 +01:00
watchdog hw/watchdog: Constify all Property 2024-12-15 12:56:42 -06:00
xen hw/xen: Constify all Property 2024-12-15 12:56:45 -06:00
xenpv hw/xen: Register framebuffer backend via xen_backend_init() 2024-06-04 11:53:43 +02:00
xtensa hw/xtensa: Include missing 'exec/tswap.h' header 2024-12-14 00:16:20 +01:00
Kconfig hw: Remove PCMCIA subsystem 2024-10-15 15:16:17 +01:00
meson.build hw: Remove PCMCIA subsystem 2024-10-15 15:16:17 +01:00