[PATCH 4/4] qemu_command: Generate cmd line for virtio-mem dynamicMemslots

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is straightforward, pretty much. The only odd thing is:
.dynamic-memslots=true requires .unplugged-inaccessible="on".
While the latter is currently the default, it's not guaranteed to
stay that way. Play it safe and explicitly set both.

Resolves: https://issues.redhat.com/browse/RHEL-15316
Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_command.c                              | 12 ++++++++++++
 .../memory-hotplug-virtio-mem.x86_64-latest.args     |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index bc285c0b6f..5c79fa0836 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3608,6 +3608,8 @@ qemuBuildMemoryDeviceProps(virQEMUDriverConfig *cfg,
     unsigned long long requestedsize = 0;
     unsigned long long address = 0;
     bool prealloc = false;
+    bool dynamicMemslots = false;
+    const char *unpluggedInacessible = NULL;
 
     if (!mem->info.alias) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -3649,6 +3651,14 @@ qemuBuildMemoryDeviceProps(virQEMUDriverConfig *cfg,
         blocksize = mem->target.virtio_mem.blocksize;
         requestedsize = mem->target.virtio_mem.requestedsize;
         address = mem->target.virtio_mem.address;
+        dynamicMemslots = mem->target.virtio_mem.dynamicMemslots;
+        if (dynamicMemslots) {
+            /* Currently, .dynamic-memslots=true requires
+             * .unplugged-inaccessible="on" (see QEMU commit
+             * v8.2.0-rc0~74^2~2). And while the latter is the default
+             * (currently), let's not rely on that. */
+            unpluggedInacessible = "on";
+        }
         break;
 
     case VIR_DOMAIN_MEMORY_MODEL_SGX_EPC:
@@ -3671,6 +3681,8 @@ qemuBuildMemoryDeviceProps(virQEMUDriverConfig *cfg,
                               "s:memdev", memdev,
                               "B:prealloc", prealloc,
                               "P:memaddr", address,
+                              "B:dynamic-memslots", dynamicMemslots,
+                              "S:unplugged-inaccessible", unpluggedInacessible,
                               "s:id", mem->info.alias,
                               NULL) < 0)
         return NULL;
diff --git a/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest.args b/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest.args
index 607ce9b0e8..ae23504c32 100644
--- a/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest.args
@@ -32,7 +32,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
 -object '{"qom-type":"memory-backend-ram","id":"memvirtiomem0","reserve":false,"size":1073741824}' \
 -device '{"driver":"virtio-mem-pci","node":0,"block-size":2097152,"requested-size":536870912,"memdev":"memvirtiomem0","id":"virtiomem0","bus":"pci.0","addr":"0x2"}' \
 -object '{"qom-type":"memory-backend-file","id":"memvirtiomem1","mem-path":"/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1","reserve":false,"size":2147483648,"host-nodes":[1,2,3],"policy":"bind"}' \
--device '{"driver":"virtio-mem-pci","node":0,"block-size":2097152,"requested-size":1073741824,"memdev":"memvirtiomem1","prealloc":true,"memaddr":5637144576,"id":"virtiomem1","bus":"pci.1","addr":"0x1"}' \
+-device '{"driver":"virtio-mem-pci","node":0,"block-size":2097152,"requested-size":1073741824,"memdev":"memvirtiomem1","prealloc":true,"memaddr":5637144576,"dynamic-memslots":true,"unplugged-inaccessible":"on","id":"virtiomem1","bus":"pci.1","addr":"0x1"}' \
 -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \
 -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \
 -device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-format","id":"ide0-0-0","bootindex":1}' \
-- 
2.41.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux