]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: qemuxmlconftests: test virtiofsd command line too
authorJán Tomko <jtomko@redhat.com>
Thu, 17 Jul 2025 17:11:43 +0000 (19:11 +0200)
committerJán Tomko <jtomko@redhat.com>
Wed, 24 Sep 2025 13:11:18 +0000 (15:11 +0200)
Fake the capabilities based on the QEMU version so that we can test
the command line for both the C version of virtiofsd (removed in QEMU
8.0.0) and the Rust version.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
tests/qemuxmlconfdata/vhost-user-fs-ccw.s390x-latest.virtiofsd0.args [new file with mode: 0644]
tests/qemuxmlconfdata/vhost-user-fs-fd-memory.x86_64-latest.virtiofsd0.args [new file with mode: 0644]
tests/qemuxmlconfdata/vhost-user-fs-fd-openfiles.x86_64-latest.virtiofsd0.args [new file with mode: 0644]
tests/qemuxmlconfdata/vhost-user-fs-hugepages.x86_64-latest.virtiofsd0.args [new file with mode: 0644]
tests/qemuxmlconfdata/vhost-user-fs-hugepages.x86_64-latest.virtiofsd1.args [new file with mode: 0644]
tests/qemuxmlconfdata/vhost-user-fs-readonly.x86_64-latest.virtiofsd0.args [new file with mode: 0644]
tests/qemuxmlconftest.c

diff --git a/tests/qemuxmlconfdata/vhost-user-fs-ccw.s390x-latest.virtiofsd0.args b/tests/qemuxmlconfdata/vhost-user-fs-ccw.s390x-latest.virtiofsd0.args
new file mode 100644 (file)
index 0000000..25567cc
--- /dev/null
@@ -0,0 +1,3 @@
+/usr/libexec/virtiofsd \
+--fd=1730 \
+--shared-dir /tmp
diff --git a/tests/qemuxmlconfdata/vhost-user-fs-fd-memory.x86_64-latest.virtiofsd0.args b/tests/qemuxmlconfdata/vhost-user-fs-fd-memory.x86_64-latest.virtiofsd0.args
new file mode 100644 (file)
index 0000000..e16a8ab
--- /dev/null
@@ -0,0 +1,9 @@
+/usr/libexec/qemu/vhost-user/test-virtiofsd \
+--fd=1730 \
+--shared-dir /path \
+--cache always \
+--sandbox chroot \
+--xattr \
+--thread-pool-size=16 \
+--uid-map=:0:100000:65535: \
+--gid-map=:0:100000:65535:
diff --git a/tests/qemuxmlconfdata/vhost-user-fs-fd-openfiles.x86_64-latest.virtiofsd0.args b/tests/qemuxmlconfdata/vhost-user-fs-fd-openfiles.x86_64-latest.virtiofsd0.args
new file mode 100644 (file)
index 0000000..fce94f4
--- /dev/null
@@ -0,0 +1,10 @@
+/usr/libexec/qemu/vhost-user/test-virtiofsd \
+--fd=1730 \
+--shared-dir /path \
+--cache always \
+--sandbox chroot \
+--xattr \
+--thread-pool-size=16 \
+--rlimit-nofile=122333 \
+--uid-map=:0:100000:65535: \
+--gid-map=:0:100000:65535:
diff --git a/tests/qemuxmlconfdata/vhost-user-fs-hugepages.x86_64-latest.virtiofsd0.args b/tests/qemuxmlconfdata/vhost-user-fs-hugepages.x86_64-latest.virtiofsd0.args
new file mode 100644 (file)
index 0000000..591afe8
--- /dev/null
@@ -0,0 +1,3 @@
+/usr/libexec/virtiofsd \
+--fd=1730 \
+--shared-dir /path
diff --git a/tests/qemuxmlconfdata/vhost-user-fs-hugepages.x86_64-latest.virtiofsd1.args b/tests/qemuxmlconfdata/vhost-user-fs-hugepages.x86_64-latest.virtiofsd1.args
new file mode 100644 (file)
index 0000000..51cb30b
--- /dev/null
@@ -0,0 +1,3 @@
+/usr/libexec/virtiofsd \
+--fd=1731 \
+--shared-dir /path
diff --git a/tests/qemuxmlconfdata/vhost-user-fs-readonly.x86_64-latest.virtiofsd0.args b/tests/qemuxmlconfdata/vhost-user-fs-readonly.x86_64-latest.virtiofsd0.args
new file mode 100644 (file)
index 0000000..53809e2
--- /dev/null
@@ -0,0 +1,6 @@
+/usr/libexec/virtiofsd \
+--fd=1730 \
+--shared-dir /path \
+--cache always \
+--xattr \
+--readonly
index 4beea912820d78116c15c430030623db7a925b12..11a2d2d244e6075ab9d4547bb0c63a7642320eb4 100644 (file)
@@ -19,6 +19,8 @@
 # include "qemu/qemu_passt.h"
 # include "qemu/qemu_process.h"
 # include "qemu/qemu_slirp.h"
+# include "qemu/qemu_virtiofs.h"
+# include "qemu/qemu_vhost_user.h"
 # include "datatypes.h"
 # include "conf/storage_conf.h"
 # include "virfilewrapper.h"
@@ -456,6 +458,24 @@ testCompareXMLToArgvCreateArgs(virQEMUDriver *drv,
         vsockPriv->vhostfd = 6789;
     }
 
+    for (i = 0; i < vm->def->nfss; i++) {
+        unsigned long long ver = 0;
+        virDomainFSDef *fs = vm->def->fss[i];
+
+        virStringParseVersion(&ver, info->args.capsver, false);
+
+        if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS && !fs->sock) {
+            /* QEMU 8.0.0 was the first release without virtiofsd included.
+               Assume that from that version, the Rust version of virtiofsd
+               which supports separate options is used. */
+
+            if (ver != 0 && ver < 8 * 1000 * 1000)
+                continue;
+            virBitmapSetBitExpand(fs->caps, QEMU_VHOST_USER_FS_FEATURE_SEPARATE_OPTIONS);
+        }
+    }
+
+
     for (i = 0; i < vm->def->ntpms; i++) {
         if (vm->def->tpms[i]->type != VIR_DOMAIN_TPM_TYPE_EMULATOR)
             continue;
@@ -846,8 +866,10 @@ static int
 testExtDevicesArgv(testQemuInfo *info,
                    virDomainObj *vm)
 {
+    g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(QEMU_DOMAIN_PRIVATE(vm)->driver);
     size_t i = 42;
     int ret = 0;
+    int fd;
 
     for (i = 0; i < vm->def->nnets; i++) {
         virDomainNetDef *net = vm->def->nets[i];
@@ -866,6 +888,19 @@ testExtDevicesArgv(testQemuInfo *info,
         }
     }
 
+    for (i = 0; i < vm->def->nfss; i++) {
+        virDomainFSDef *fs = vm->def->fss[i];
+
+        if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS && !fs->sock) {
+            g_autoptr(virCommand) cmd = NULL;
+            fd = 1730 + i;
+
+            cmd = qemuVirtioFSBuildCommandLine(cfg, fs, &fd);
+            if (testExtDeviceArgv(info, cmd, "virtiofsd", i) < 0)
+                ret = -1;
+        }
+    }
+
     return ret;
 }