Initially introduced in v3.10.0-rc1~172. When generating a path for memory-backend-file or -mem-path, qemu driver will use the following pattern: $memoryBackingDir/libvirt/qemu/$id-$shortName where $memoryBackingDir defaults to /var/lib/libvirt/qemu/ram but can be overridden in qemu.conf. Anyway, the "/libvirt/qemu/" part looks redundant, because it's already contained in the default, or creates unnecessary nesting if overridden in qemu.conf. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/qemu/qemu_conf.c | 12 +----------- src/qemu/qemu_conf.h | 2 -- src/qemu/qemu_driver.c | 12 +----------- tests/qemuxml2argvdata/cpu-numa-memshared.args | 8 ++++---- .../qemuxml2argvdata/fd-memory-no-numa-topology.args | 2 +- tests/qemuxml2argvdata/fd-memory-numa-topology.args | 4 ++-- tests/qemuxml2argvdata/fd-memory-numa-topology2.args | 8 ++++---- tests/qemuxml2argvdata/fd-memory-numa-topology3.args | 12 ++++++------ tests/qemuxml2argvdata/hugepages-memaccess2.args | 12 ++++++------ tests/qemuxml2argvdata/pages-dimm-discard.args | 4 ++-- .../vhost-user-fs-fd-memory.x86_64-latest.args | 2 +- 11 files changed, 28 insertions(+), 50 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 15837cece4..9786e19f8f 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1951,27 +1951,17 @@ qemuGetDomainHupageMemPath(const virDomainDef *def, } -void -qemuGetMemoryBackingBasePath(virQEMUDriverConfigPtr cfg, - char **path) -{ - *path = g_strdup_printf("%s/libvirt/qemu", cfg->memoryBackingDir); -} - - int qemuGetMemoryBackingDomainPath(const virDomainDef *def, virQEMUDriverConfigPtr cfg, char **path) { g_autofree char *shortName = NULL; - g_autofree char *base = NULL; if (!(shortName = virDomainDefGetShortName(def))) return -1; - qemuGetMemoryBackingBasePath(cfg, &base); - *path = g_strdup_printf("%s/%s", base, shortName); + *path = g_strdup_printf("%s/%s", cfg->memoryBackingDir, shortName); return 0; } diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 14f9b9e81e..c8d3e439e0 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -398,8 +398,6 @@ int qemuGetDomainHupageMemPath(const virDomainDef *def, unsigned long long pagesize, char **memPath); -void qemuGetMemoryBackingBasePath(virQEMUDriverConfigPtr cfg, - char **path); int qemuGetMemoryBackingDomainPath(const virDomainDef *def, virQEMUDriverConfigPtr cfg, char **path); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 570dc059e9..5cbf2f2478 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -640,7 +640,6 @@ qemuStateInitialize(bool privileged, virQEMUDriverConfigPtr cfg; uid_t run_uid = -1; gid_t run_gid = -1; - g_autofree char *memoryBackingPath = NULL; bool autostart = true; size_t i; const char *defsecmodel = NULL; @@ -935,17 +934,8 @@ qemuStateInitialize(bool privileged, goto error; } - qemuGetMemoryBackingBasePath(cfg, &memoryBackingPath); - - if (virFileMakePath(memoryBackingPath) < 0) { - virReportSystemError(errno, - _("unable to create memory backing path %s"), - memoryBackingPath); - goto error; - } - if (privileged && - virFileUpdatePerm(memoryBackingPath, + virFileUpdatePerm(cfg->memoryBackingDir, 0, S_IXGRP | S_IXOTH) < 0) goto error; diff --git a/tests/qemuxml2argvdata/cpu-numa-memshared.args b/tests/qemuxml2argvdata/cpu-numa-memshared.args index 752eed8d13..8e214189db 100644 --- a/tests/qemuxml2argvdata/cpu-numa-memshared.args +++ b/tests/qemuxml2argvdata/cpu-numa-memshared.args @@ -15,12 +15,12 @@ QEMU_AUDIO_DRV=none \ -realtime mlock=off \ -smp 16,sockets=2,cores=4,threads=2 \ -object memory-backend-file,id=ram-node0,\ -mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node0,\ -share=yes,size=112197632 \ +mem-path=/var/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node0,share=yes,\ +size=112197632 \ -numa node,nodeid=0,cpus=0-7,memdev=ram-node0 \ -object memory-backend-file,id=ram-node1,\ -mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node1,\ -share=no,size=112197632 \ +mem-path=/var/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node1,share=no,\ +size=112197632 \ -numa node,nodeid=1,cpus=8-15,memdev=ram-node1 \ -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ -display none \ diff --git a/tests/qemuxml2argvdata/fd-memory-no-numa-topology.args b/tests/qemuxml2argvdata/fd-memory-no-numa-topology.args index d23c575553..dec35cc10a 100644 --- a/tests/qemuxml2argvdata/fd-memory-no-numa-topology.args +++ b/tests/qemuxml2argvdata/fd-memory-no-numa-topology.args @@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \ -machine pc-i440fx-2.3,accel=kvm,usb=off,dump-guest-core=off \ -m 14336 \ -mem-prealloc \ --mem-path /var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram \ +-mem-path /var/lib/libvirt/qemu/ram/-1-instance-00000092/ram \ -realtime mlock=off \ -smp 8,sockets=8,cores=1,threads=1 \ -uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \ diff --git a/tests/qemuxml2argvdata/fd-memory-numa-topology.args b/tests/qemuxml2argvdata/fd-memory-numa-topology.args index 4fbbc8185b..2d3e90ff7a 100644 --- a/tests/qemuxml2argvdata/fd-memory-numa-topology.args +++ b/tests/qemuxml2argvdata/fd-memory-numa-topology.args @@ -16,8 +16,8 @@ QEMU_AUDIO_DRV=none \ -realtime mlock=off \ -smp 8,sockets=1,cores=8,threads=1 \ -object memory-backend-file,id=ram-node0,\ -mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram-node0,\ -share=yes,size=15032385536 \ +mem-path=/var/lib/libvirt/qemu/ram/-1-instance-00000092/ram-node0,share=yes,\ +size=15032385536 \ -numa node,nodeid=0,cpus=0-7,memdev=ram-node0 \ -uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \ -display none \ diff --git a/tests/qemuxml2argvdata/fd-memory-numa-topology2.args b/tests/qemuxml2argvdata/fd-memory-numa-topology2.args index 1eeeaec0ce..6b1695feb1 100644 --- a/tests/qemuxml2argvdata/fd-memory-numa-topology2.args +++ b/tests/qemuxml2argvdata/fd-memory-numa-topology2.args @@ -16,12 +16,12 @@ QEMU_AUDIO_DRV=none \ -realtime mlock=off \ -smp 20,sockets=1,cores=8,threads=1 \ -object memory-backend-file,id=ram-node0,\ -mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram-node0,\ -share=no,size=15032385536 \ +mem-path=/var/lib/libvirt/qemu/ram/-1-instance-00000092/ram-node0,share=no,\ +size=15032385536 \ -numa node,nodeid=0,cpus=0-7,memdev=ram-node0 \ -object memory-backend-file,id=ram-node1,\ -mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram-node1,\ -share=yes,size=15032385536 \ +mem-path=/var/lib/libvirt/qemu/ram/-1-instance-00000092/ram-node1,share=yes,\ +size=15032385536 \ -numa node,nodeid=1,cpus=8-15,memdev=ram-node1 \ -uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \ -display none \ diff --git a/tests/qemuxml2argvdata/fd-memory-numa-topology3.args b/tests/qemuxml2argvdata/fd-memory-numa-topology3.args index d75b67916c..205d14a7db 100644 --- a/tests/qemuxml2argvdata/fd-memory-numa-topology3.args +++ b/tests/qemuxml2argvdata/fd-memory-numa-topology3.args @@ -16,16 +16,16 @@ QEMU_AUDIO_DRV=none \ -realtime mlock=off \ -smp 32,sockets=1,cores=24,threads=1 \ -object memory-backend-file,id=ram-node0,\ -mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram-node0,\ -share=yes,size=15032385536 \ +mem-path=/var/lib/libvirt/qemu/ram/-1-instance-00000092/ram-node0,share=yes,\ +size=15032385536 \ -numa node,nodeid=0,cpus=0-1,memdev=ram-node0 \ -object memory-backend-file,id=ram-node1,\ -mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram-node1,\ -share=yes,size=15032385536 \ +mem-path=/var/lib/libvirt/qemu/ram/-1-instance-00000092/ram-node1,share=yes,\ +size=15032385536 \ -numa node,nodeid=1,cpus=2-3,memdev=ram-node1 \ -object memory-backend-file,id=ram-node2,\ -mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram-node2,\ -share=no,size=15032385536 \ +mem-path=/var/lib/libvirt/qemu/ram/-1-instance-00000092/ram-node2,share=no,\ +size=15032385536 \ -numa node,nodeid=2,cpus=4-5,memdev=ram-node2 \ -uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \ -display none \ diff --git a/tests/qemuxml2argvdata/hugepages-memaccess2.args b/tests/qemuxml2argvdata/hugepages-memaccess2.args index 654baebf9f..c1560e63c3 100644 --- a/tests/qemuxml2argvdata/hugepages-memaccess2.args +++ b/tests/qemuxml2argvdata/hugepages-memaccess2.args @@ -15,20 +15,20 @@ QEMU_AUDIO_DRV=none \ -realtime mlock=off \ -smp 4,sockets=4,cores=1,threads=1 \ -object memory-backend-file,id=ram-node0,\ -mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node0,\ -share=no,size=1073741824,host-nodes=0-3,policy=bind \ +mem-path=/var/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node0,share=no,\ +size=1073741824,host-nodes=0-3,policy=bind \ -numa node,nodeid=0,cpus=0,memdev=ram-node0 \ -object memory-backend-file,id=ram-node1,prealloc=yes,\ mem-path=/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,share=yes,size=1073741824,\ host-nodes=0-3,policy=bind \ -numa node,nodeid=1,cpus=1,memdev=ram-node1 \ -object memory-backend-file,id=ram-node2,\ -mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node2,\ -share=no,size=1073741824,host-nodes=0-3,policy=bind \ +mem-path=/var/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node2,share=no,\ +size=1073741824,host-nodes=0-3,policy=bind \ -numa node,nodeid=2,cpus=2,memdev=ram-node2 \ -object memory-backend-file,id=ram-node3,\ -mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node3,\ -share=no,size=1073741824,host-nodes=3,policy=bind \ +mem-path=/var/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node3,share=no,\ +size=1073741824,host-nodes=3,policy=bind \ -numa node,nodeid=3,cpus=3,memdev=ram-node3 \ -object memory-backend-file,id=memdimm0,prealloc=yes,\ mem-path=/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,share=yes,size=536870912,\ diff --git a/tests/qemuxml2argvdata/pages-dimm-discard.args b/tests/qemuxml2argvdata/pages-dimm-discard.args index fefa205597..96e9ffdec3 100644 --- a/tests/qemuxml2argvdata/pages-dimm-discard.args +++ b/tests/qemuxml2argvdata/pages-dimm-discard.args @@ -20,8 +20,8 @@ mem-path=/dev/hugepages1G/libvirt/qemu/-1-fedora,size=1073741824,\ host-nodes=1-3,policy=bind \ -device pc-dimm,node=0,memdev=memdimm0,id=dimm0,slot=0 \ -object memory-backend-file,id=memdimm1,\ -mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-fedora/dimm1,\ -discard-data=yes,share=no,size=536870912 \ +mem-path=/var/lib/libvirt/qemu/ram/-1-fedora/dimm1,discard-data=yes,share=no,\ +size=536870912 \ -device pc-dimm,node=0,memdev=memdimm1,id=dimm1,slot=1 \ -uuid 63840878-0deb-4095-97e6-fc444d9bc9fa \ -display none \ diff --git a/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args b/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args index a7df45a7f0..dd5f68abc5 100644 --- a/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args +++ b/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args @@ -18,7 +18,7 @@ file=/tmp/lib/domain--1-guest/master-key.aes \ -overcommit mem-lock=off \ -smp 2,sockets=2,cores=1,threads=1 \ -object memory-backend-file,id=ram-node0,\ -mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-guest/ram-node0,share=yes,\ +mem-path=/var/lib/libvirt/qemu/ram/-1-guest/ram-node0,share=yes,\ size=15032385536 \ -numa node,nodeid=0,cpus=0-1,memdev=ram-node0 \ -uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \ -- 2.24.1