[libvirt PATCH 0/8] qemu: test command line of external helpers

Ján Tomko (8): qemu: passt: split out qemuPasstBuildCommand tests: qemuxmlconftests: store suffix in testQemuInfo tests: qemuxmlconftest: Introduce testQemuConfMarkUsed export qemuVirtioFSBuildCommandLine tests: qemuxmlconftest: test passt command line too tests: qemuxmlconf: virtiofs: remove locking from the readonly test case tests: qemuxmlconftests: test virtiofsd command line too tests: qemuxmlconftest: test locking with older virtiofsd src/qemu/qemu_passt.c | 38 ++++-- src/qemu/qemu_passt.h | 5 + src/qemu/qemu_virtiofs.c | 2 +- src/qemu/qemu_virtiofs.h | 5 + .../net-user-passt.x86_64-7.2.0.passt0.args | 13 ++ .../net-user-passt.x86_64-latest.passt0.args | 13 ++ ...-vhostuser-passt.x86_64-latest.passt0.args | 14 ++ ...-vhostuser-passt.x86_64-latest.passt1.args | 5 + ...-vhostuser-passt.x86_64-latest.passt2.args | 6 + ...main-subelements.x86_64-latest.passt0.args | 7 + ...t-user-fs-ccw.s390x-latest.virtiofsd0.args | 3 + ...fs-fd-memory.x86_64-latest.virtiofsd0.args | 9 ++ ...fd-openfiles.x86_64-latest.virtiofsd0.args | 10 ++ ...fs-hugepages.x86_64-latest.virtiofsd0.args | 3 + ...fs-hugepages.x86_64-latest.virtiofsd1.args | 3 + .../vhost-user-fs-locking.x86_64-7.2.0.args | 35 +++++ ...er-fs-locking.x86_64-7.2.0.virtiofsd0.args | 4 + .../vhost-user-fs-locking.x86_64-7.2.0.xml | 46 +++++++ .../qemuxmlconfdata/vhost-user-fs-locking.xml | 46 +++++++ ...-fs-readonly.x86_64-latest.virtiofsd0.args | 6 + .../vhost-user-fs-readonly.xml | 1 - tests/qemuxmlconftest.c | 125 ++++++++++++++++-- tests/testutilsqemu.h | 1 + 23 files changed, 381 insertions(+), 19 deletions(-) create mode 100644 tests/qemuxmlconfdata/net-user-passt.x86_64-7.2.0.passt0.args create mode 100644 tests/qemuxmlconfdata/net-user-passt.x86_64-latest.passt0.args create mode 100644 tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.passt0.args create mode 100644 tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.passt1.args create mode 100644 tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.passt2.args create mode 100644 tests/qemuxmlconfdata/schema-reorder-domain-subelements.x86_64-latest.passt0.args create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-ccw.s390x-latest.virtiofsd0.args create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-fd-memory.x86_64-latest.virtiofsd0.args create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-fd-openfiles.x86_64-latest.virtiofsd0.args create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-hugepages.x86_64-latest.virtiofsd0.args create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-hugepages.x86_64-latest.virtiofsd1.args create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-locking.x86_64-7.2.0.args create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-locking.x86_64-7.2.0.virtiofsd0.args create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-locking.x86_64-7.2.0.xml create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-locking.xml create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-readonly.x86_64-latest.virtiofsd0.args -- 2.50.1

From: Ján Tomko <jtomko@redhat.com> Separate the command line building to make it testable. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_passt.c | 38 +++++++++++++++++++++++++++++--------- src/qemu/qemu_passt.h | 5 +++++ 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c index fcc34de384..d8e281b7a1 100644 --- a/src/qemu/qemu_passt.c +++ b/src/qemu/qemu_passt.c @@ -194,15 +194,15 @@ qemuPasstPrepareVhostUser(virDomainObj *vm, net->data.vhostuser->data.nix.reconnect.timeout = QEMU_PASST_RECONNECT_TIMEOUT; } -int -qemuPasstStart(virDomainObj *vm, - virDomainNetDef *net) +virCommand * +qemuPasstBuildCommand(char **socketName, + char **pidfileRet, + virDomainObj *vm, + virDomainNetDef *net) { - qemuDomainObjPrivate *priv = vm->privateData; - virQEMUDriver *driver = priv->driver; g_autofree char *passtSocketName = qemuPasstCreateSocketPath(vm, net); - g_autoptr(virCommand) cmd = NULL; g_autofree char *pidfile = qemuPasstCreatePidFilename(vm, net); + g_autoptr(virCommand) cmd = NULL; size_t i; cmd = virCommandNew(PASST); @@ -238,7 +238,7 @@ qemuPasstStart(virDomainObj *vm, * a single IPv4 and single IPv6 address */ if (!(addr = virSocketAddrFormat(&ip->address))) - return -1; + return NULL; virCommandAddArgList(cmd, "--address", addr, NULL); @@ -266,14 +266,14 @@ qemuPasstStart(virDomainObj *vm, /* validation guarantees this will never happen */ virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid portForward proto value %1$u"), pf->proto); - return -1; + return NULL; } if (VIR_SOCKET_ADDR_VALID(&pf->address)) { g_autofree char *addr = NULL; if (!(addr = virSocketAddrFormat(&pf->address))) - return -1; + return NULL; virBufferAddStr(&buf, addr); emitsep = true; @@ -317,6 +317,26 @@ qemuPasstStart(virDomainObj *vm, virCommandAddArg(cmd, virBufferCurrentContent(&buf)); } + if (socketName) + *socketName = g_steal_pointer(&passtSocketName); + if (pidfileRet) + *pidfileRet = g_steal_pointer(&pidfile); + + return g_steal_pointer(&cmd); +} + +int +qemuPasstStart(virDomainObj *vm, + virDomainNetDef *net) +{ + qemuDomainObjPrivate *priv = vm->privateData; + g_autofree char *passtSocketName = NULL; + g_autofree char *pidfile = NULL; + virQEMUDriver *driver = priv->driver; + g_autoptr(virCommand) cmd = NULL; + + if (!(cmd = qemuPasstBuildCommand(&passtSocketName, &pidfile, vm, net))) + return -1; if (qemuExtDeviceLogCommand(driver, vm, cmd, "passt") < 0) return -1; diff --git a/src/qemu/qemu_passt.h b/src/qemu/qemu_passt.h index ea545ccf38..e16d4c1119 100644 --- a/src/qemu/qemu_passt.h +++ b/src/qemu/qemu_passt.h @@ -27,6 +27,11 @@ qemuPasstAddNetProps(virDomainObj *vm, virDomainNetDef *net, virJSONValue **netprops); +virCommand *qemuPasstBuildCommand(char **socketName, + char **pidfileRet, + virDomainObj *vm, + virDomainNetDef *net); + int qemuPasstStart(virDomainObj *vm, virDomainNetDef *net); -- 2.50.1

On 9/9/25 8:05 AM, Ján Tomko via Devel wrote:
From: Ján Tomko <jtomko@redhat.com>
Separate the command line building to make it testable.
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
--- src/qemu/qemu_passt.c | 38 +++++++++++++++++++++++++++++--------- src/qemu/qemu_passt.h | 5 +++++ 2 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c index fcc34de384..d8e281b7a1 100644 --- a/src/qemu/qemu_passt.c +++ b/src/qemu/qemu_passt.c @@ -194,15 +194,15 @@ qemuPasstPrepareVhostUser(virDomainObj *vm, net->data.vhostuser->data.nix.reconnect.timeout = QEMU_PASST_RECONNECT_TIMEOUT; }
-int -qemuPasstStart(virDomainObj *vm, - virDomainNetDef *net) +virCommand * +qemuPasstBuildCommand(char **socketName, + char **pidfileRet, + virDomainObj *vm, + virDomainNetDef *net) { - qemuDomainObjPrivate *priv = vm->privateData; - virQEMUDriver *driver = priv->driver; g_autofree char *passtSocketName = qemuPasstCreateSocketPath(vm, net); - g_autoptr(virCommand) cmd = NULL; g_autofree char *pidfile = qemuPasstCreatePidFilename(vm, net); + g_autoptr(virCommand) cmd = NULL; size_t i;
cmd = virCommandNew(PASST); @@ -238,7 +238,7 @@ qemuPasstStart(virDomainObj *vm, * a single IPv4 and single IPv6 address */ if (!(addr = virSocketAddrFormat(&ip->address))) - return -1; + return NULL;
virCommandAddArgList(cmd, "--address", addr, NULL);
@@ -266,14 +266,14 @@ qemuPasstStart(virDomainObj *vm, /* validation guarantees this will never happen */ virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid portForward proto value %1$u"), pf->proto); - return -1; + return NULL; }
if (VIR_SOCKET_ADDR_VALID(&pf->address)) { g_autofree char *addr = NULL;
if (!(addr = virSocketAddrFormat(&pf->address))) - return -1; + return NULL;
virBufferAddStr(&buf, addr); emitsep = true; @@ -317,6 +317,26 @@ qemuPasstStart(virDomainObj *vm, virCommandAddArg(cmd, virBufferCurrentContent(&buf)); }
+ if (socketName) + *socketName = g_steal_pointer(&passtSocketName); + if (pidfileRet) + *pidfileRet = g_steal_pointer(&pidfile); + + return g_steal_pointer(&cmd); +} + +int +qemuPasstStart(virDomainObj *vm, + virDomainNetDef *net) +{ + qemuDomainObjPrivate *priv = vm->privateData; + g_autofree char *passtSocketName = NULL; + g_autofree char *pidfile = NULL; + virQEMUDriver *driver = priv->driver; + g_autoptr(virCommand) cmd = NULL; + + if (!(cmd = qemuPasstBuildCommand(&passtSocketName, &pidfile, vm, net))) + return -1;
if (qemuExtDeviceLogCommand(driver, vm, cmd, "passt") < 0) return -1; diff --git a/src/qemu/qemu_passt.h b/src/qemu/qemu_passt.h index ea545ccf38..e16d4c1119 100644 --- a/src/qemu/qemu_passt.h +++ b/src/qemu/qemu_passt.h @@ -27,6 +27,11 @@ qemuPasstAddNetProps(virDomainObj *vm, virDomainNetDef *net, virJSONValue **netprops);
+virCommand *qemuPasstBuildCommand(char **socketName, + char **pidfileRet, + virDomainObj *vm, + virDomainNetDef *net); + int qemuPasstStart(virDomainObj *vm, virDomainNetDef *net);

From: Ján Tomko <jtomko@redhat.com> Next patch will need this to construct the path to the output file in a deeper level of nesting. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- tests/qemuxmlconftest.c | 1 + tests/testutilsqemu.h | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c index 171a6f1c78..a7e32a5a99 100644 --- a/tests/qemuxmlconftest.c +++ b/tests/qemuxmlconftest.c @@ -999,6 +999,7 @@ testRun(const char *name, va_list ap; info->name = name; + info->suffix = suffix; info->conf = testConf; va_start(ap, testConf); diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index 62943bb2d8..a8e0fefa84 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -98,6 +98,7 @@ struct testQemuArgs { struct _testQemuInfo { const char *name; + const char *suffix; char *infile; char *outfile; char *out_xml_active; -- 2.50.1

From: Ján Tomko <jtomko@redhat.com> Make the code readable enough to not need a comment. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- tests/qemuxmlconftest.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c index a7e32a5a99..dea75d805f 100644 --- a/tests/qemuxmlconftest.c +++ b/tests/qemuxmlconftest.c @@ -598,6 +598,15 @@ testInfoCheckDuplicate(testQemuInfo *info) } +static void +testQemuConfMarkUsed(testQemuInfo *info, + const char *file) +{ + if (file) + ignore_value(g_hash_table_remove(info->conf->existingTestCases, file)); +} + + /** * testQemuConfXMLCommon: Prepare common test data (e.g. parse input XML) * for a test case. @@ -630,14 +639,10 @@ testQemuConfXMLCommon(testQemuInfo *info, if (info->prepared) goto cleanup; - /* mark test case as used */ - ignore_value(g_hash_table_remove(info->conf->existingTestCases, info->infile)); - if (info->outfile) - ignore_value(g_hash_table_remove(info->conf->existingTestCases, info->outfile)); - if (info->errfile) - ignore_value(g_hash_table_remove(info->conf->existingTestCases, info->errfile)); - if (info->out_xml_inactive) - ignore_value(g_hash_table_remove(info->conf->existingTestCases, info->out_xml_inactive)); + testQemuConfMarkUsed(info, info->infile); + testQemuConfMarkUsed(info, info->outfile); + testQemuConfMarkUsed(info, info->errfile); + testQemuConfMarkUsed(info, info->out_xml_inactive); if (testQemuInfoInitArgs((testQemuInfo *) info) < 0) goto cleanup; -- 2.50.1

From: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_virtiofs.c | 2 +- src/qemu/qemu_virtiofs.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c index aa282024a4..d192f5ec3c 100644 --- a/src/qemu/qemu_virtiofs.c +++ b/src/qemu/qemu_virtiofs.c @@ -111,7 +111,7 @@ qemuVirtioFSOpenChardev(virQEMUDriver *driver, } -static virCommand * +virCommand * qemuVirtioFSBuildCommandLine(virQEMUDriverConfig *cfg, virDomainFSDef *fs, int *fd) diff --git a/src/qemu/qemu_virtiofs.h b/src/qemu/qemu_virtiofs.h index 5463acef98..6867f89929 100644 --- a/src/qemu/qemu_virtiofs.h +++ b/src/qemu/qemu_virtiofs.h @@ -26,6 +26,11 @@ char * qemuVirtioFSCreateSocketFilename(virDomainObj *vm, const char *alias); +virCommand * +qemuVirtioFSBuildCommandLine(virQEMUDriverConfig *cfg, + virDomainFSDef *fs, + int *fd); + int qemuVirtioFSStart(virQEMUDriver *driver, virDomainObj *vm, -- 2.50.1

From: Ján Tomko <jtomko@redhat.com> Introduce testing of the generated command line arguments of helper binaries too, not just QEMU. Start with passt. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- .../net-user-passt.x86_64-7.2.0.passt0.args | 13 ++++ .../net-user-passt.x86_64-latest.passt0.args | 13 ++++ ...-vhostuser-passt.x86_64-latest.passt0.args | 14 ++++ ...-vhostuser-passt.x86_64-latest.passt1.args | 5 ++ ...-vhostuser-passt.x86_64-latest.passt2.args | 6 ++ ...main-subelements.x86_64-latest.passt0.args | 7 ++ tests/qemuxmlconftest.c | 70 +++++++++++++++++++ 7 files changed, 128 insertions(+) create mode 100644 tests/qemuxmlconfdata/net-user-passt.x86_64-7.2.0.passt0.args create mode 100644 tests/qemuxmlconfdata/net-user-passt.x86_64-latest.passt0.args create mode 100644 tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.passt0.args create mode 100644 tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.passt1.args create mode 100644 tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.passt2.args create mode 100644 tests/qemuxmlconfdata/schema-reorder-domain-subelements.x86_64-latest.passt0.args diff --git a/tests/qemuxmlconfdata/net-user-passt.x86_64-7.2.0.passt0.args b/tests/qemuxmlconfdata/net-user-passt.x86_64-7.2.0.passt0.args new file mode 100644 index 0000000000..b244eb711d --- /dev/null +++ b/tests/qemuxmlconfdata/net-user-passt.x86_64-7.2.0.passt0.args @@ -0,0 +1,13 @@ +passt \ +--one-off \ +--socket /var/run/libvirt/qemu/passt/-1-QEMUGuest1-net0.socket \ +--pid /var/run/libvirt/qemu/passt/-1-QEMUGuest1-net0-passt.pid \ +--interface eth42 \ +--log-file /var/log/loglaw.blog \ +--address 172.17.2.0 \ +--netmask 24 \ +--address 2001:db8:ac10:fd01::feed \ +--tcp-ports '2001:db8:ac10:fd01::1:10/22:2022,1000-1050,~1020,~1030-1040' \ +--udp-ports '1.2.3.4%eth0/5000-5020:6000-6020,~5010-5015' \ +--tcp-ports 80 \ +--tcp-ports 443:344 diff --git a/tests/qemuxmlconfdata/net-user-passt.x86_64-latest.passt0.args b/tests/qemuxmlconfdata/net-user-passt.x86_64-latest.passt0.args new file mode 100644 index 0000000000..b244eb711d --- /dev/null +++ b/tests/qemuxmlconfdata/net-user-passt.x86_64-latest.passt0.args @@ -0,0 +1,13 @@ +passt \ +--one-off \ +--socket /var/run/libvirt/qemu/passt/-1-QEMUGuest1-net0.socket \ +--pid /var/run/libvirt/qemu/passt/-1-QEMUGuest1-net0-passt.pid \ +--interface eth42 \ +--log-file /var/log/loglaw.blog \ +--address 172.17.2.0 \ +--netmask 24 \ +--address 2001:db8:ac10:fd01::feed \ +--tcp-ports '2001:db8:ac10:fd01::1:10/22:2022,1000-1050,~1020,~1030-1040' \ +--udp-ports '1.2.3.4%eth0/5000-5020:6000-6020,~5010-5015' \ +--tcp-ports 80 \ +--tcp-ports 443:344 diff --git a/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.passt0.args b/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.passt0.args new file mode 100644 index 0000000000..f75fc0749a --- /dev/null +++ b/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.passt0.args @@ -0,0 +1,14 @@ +passt \ +--vhost-user \ +--one-off \ +--socket /var/run/libvirt/qemu/passt/-1-QEMUGuest1-net0.socket \ +--pid /var/run/libvirt/qemu/passt/-1-QEMUGuest1-net0-passt.pid \ +--interface eth42 \ +--log-file /var/log/loglaw.blog \ +--address 172.17.2.0 \ +--netmask 24 \ +--address 2001:db8:ac10:fd01::feed \ +--tcp-ports '2001:db8:ac10:fd01::1:10/22:2022,1000-1050,~1020,~1030-1040' \ +--udp-ports '1.2.3.4%eth0/5000-5020:6000-6020,~5010-5015' \ +--tcp-ports 80 \ +--tcp-ports 443:344 diff --git a/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.passt1.args b/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.passt1.args new file mode 100644 index 0000000000..4bebc2bcb1 --- /dev/null +++ b/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.passt1.args @@ -0,0 +1,5 @@ +passt \ +--vhost-user \ +--one-off \ +--socket /var/run/libvirt/qemu/passt/-1-QEMUGuest1-net1.socket \ +--pid /var/run/libvirt/qemu/passt/-1-QEMUGuest1-net1-passt.pid diff --git a/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.passt2.args b/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.passt2.args new file mode 100644 index 0000000000..35cd30a553 --- /dev/null +++ b/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.passt2.args @@ -0,0 +1,6 @@ +passt \ +--vhost-user \ +--one-off \ +--socket /var/run/libvirt/qemu/passt/-1-QEMUGuest1-net2.socket \ +--pid /var/run/libvirt/qemu/passt/-1-QEMUGuest1-net2-passt.pid \ +--interface eth43 diff --git a/tests/qemuxmlconfdata/schema-reorder-domain-subelements.x86_64-latest.passt0.args b/tests/qemuxmlconfdata/schema-reorder-domain-subelements.x86_64-latest.passt0.args new file mode 100644 index 0000000000..59574106e1 --- /dev/null +++ b/tests/qemuxmlconfdata/schema-reorder-domain-subelements.x86_64-latest.passt0.args @@ -0,0 +1,7 @@ +passt \ +--vhost-user \ +--one-off \ +--socket /var/run/libvirt/qemu/passt/-1-passtvhostuu-net0.socket \ +--pid /var/run/libvirt/qemu/passt/-1-passtvhostuu-net0-passt.pid \ +--address 10.30.0.5 \ +--netmask 24 diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c index dea75d805f..7280176de1 100644 --- a/tests/qemuxmlconftest.c +++ b/tests/qemuxmlconftest.c @@ -16,6 +16,7 @@ # include "qemu/qemu_capabilities.h" # include "qemu/qemu_domain.h" # include "qemu/qemu_migration.h" +# include "qemu/qemu_passt.h" # include "qemu/qemu_process.h" # include "qemu/qemu_slirp.h" # include "datatypes.h" @@ -803,6 +804,72 @@ testCompareOutXML2XML(const void *data) } +static int +testExtDeviceArgv(testQemuInfo *info, + virCommand *cmd, + const char *helper, + size_t idx) +{ + g_auto(virBuffer) actualBuf = VIR_BUFFER_INITIALIZER; + g_autofree char *actualargv = NULL; + g_autofree char *outfile = NULL; + virError *err = NULL; + + outfile = g_strdup_printf("%s/qemuxmlconfdata/%s%s%s.%s%zu.args", + abs_srcdir, info->name, info->suffix, + info->args.capsvariant, helper, idx); + testQemuConfMarkUsed(info, outfile); + + if (!cmd) { + err = virGetLastError(); + if (!err) { + VIR_TEST_DEBUG("no error was reported for expected failure"); + return -1; + } + return -1; + } + + if (virCommandToStringBuf(cmd, &actualBuf, true, false) < 0) + return -1; + + virBufferAddLit(&actualBuf, "\n"); + actualargv = virBufferContentAndReset(&actualBuf); + + if (virTestCompareToFileFull(actualargv, outfile, false) < 0) + return -1; + + return 0; +} + + +static int +testExtDevicesArgv(testQemuInfo *info, + virDomainObj *vm) +{ + size_t i = 42; + int ret = 0; + + for (i = 0; i < vm->def->nnets; i++) { + virDomainNetDef *net = vm->def->nets[i]; + + if (net->type != VIR_DOMAIN_NET_TYPE_USER && + net->type != VIR_DOMAIN_NET_TYPE_VHOSTUSER) { + continue; + } + + if (net->backend.type == VIR_DOMAIN_NET_BACKEND_PASST) { + g_autoptr(virCommand) cmd = NULL; + + cmd = qemuPasstBuildCommand(NULL, NULL, vm, net); + if (testExtDeviceArgv(info, cmd, "passt", i) < 0) + ret = -1; + } + } + + return ret; +} + + static int testCompareXMLToArgv(const void *data) { @@ -897,6 +964,9 @@ testCompareXMLToArgv(const void *data) if (virTestCompareToFileFull(actualargv, info->outfile, false) < 0) goto cleanup; + if (testExtDevicesArgv(info, vm) < 0) + goto cleanup; + ret = 0; ok: -- 2.50.1

From: Ján Tomko <jtomko@redhat.com> The combination of locking + readonly is bogus, because there has never been a virtiofsd release that supported both. Locking was a feature of the C-based virtiofsd that was living in the QEMU tree until v8.0.0 and the readonly feature was only introduced in the Rust version of virtiofsd. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- tests/qemuxmlconfdata/vhost-user-fs-readonly.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/qemuxmlconfdata/vhost-user-fs-readonly.xml b/tests/qemuxmlconfdata/vhost-user-fs-readonly.xml index c9c1e5c3d2..89a6616eec 100644 --- a/tests/qemuxmlconfdata/vhost-user-fs-readonly.xml +++ b/tests/qemuxmlconfdata/vhost-user-fs-readonly.xml @@ -30,7 +30,6 @@ <driver type='virtiofs' queue='1024'/> <binary path='/usr/libexec/virtiofsd' xattr='on'> <cache mode='always'/> - <lock posix='off' flock='off'/> </binary> <source dir='/path'/> <target dir='mount_tag'/> -- 2.50.1

From: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com> --- ...t-user-fs-ccw.s390x-latest.virtiofsd0.args | 3 ++ ...fs-fd-memory.x86_64-latest.virtiofsd0.args | 9 ++++++ ...fd-openfiles.x86_64-latest.virtiofsd0.args | 10 ++++++ ...fs-hugepages.x86_64-latest.virtiofsd0.args | 3 ++ ...fs-hugepages.x86_64-latest.virtiofsd1.args | 3 ++ ...-fs-readonly.x86_64-latest.virtiofsd0.args | 6 ++++ tests/qemuxmlconftest.c | 32 +++++++++++++++++++ 7 files changed, 66 insertions(+) create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-ccw.s390x-latest.virtiofsd0.args create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-fd-memory.x86_64-latest.virtiofsd0.args create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-fd-openfiles.x86_64-latest.virtiofsd0.args create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-hugepages.x86_64-latest.virtiofsd0.args create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-hugepages.x86_64-latest.virtiofsd1.args create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-readonly.x86_64-latest.virtiofsd0.args 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 index 0000000000..25567cc821 --- /dev/null +++ b/tests/qemuxmlconfdata/vhost-user-fs-ccw.s390x-latest.virtiofsd0.args @@ -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 index 0000000000..e16a8aba8f --- /dev/null +++ b/tests/qemuxmlconfdata/vhost-user-fs-fd-memory.x86_64-latest.virtiofsd0.args @@ -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 index 0000000000..fce94f454e --- /dev/null +++ b/tests/qemuxmlconfdata/vhost-user-fs-fd-openfiles.x86_64-latest.virtiofsd0.args @@ -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 index 0000000000..591afe82ec --- /dev/null +++ b/tests/qemuxmlconfdata/vhost-user-fs-hugepages.x86_64-latest.virtiofsd0.args @@ -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 index 0000000000..51cb30bf76 --- /dev/null +++ b/tests/qemuxmlconfdata/vhost-user-fs-hugepages.x86_64-latest.virtiofsd1.args @@ -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 index 0000000000..53809e208e --- /dev/null +++ b/tests/qemuxmlconfdata/vhost-user-fs-readonly.x86_64-latest.virtiofsd0.args @@ -0,0 +1,6 @@ +/usr/libexec/virtiofsd \ +--fd=1730 \ +--shared-dir /path \ +--cache always \ +--xattr \ +--readonly diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c index 7280176de1..aaca9b6c05 100644 --- a/tests/qemuxmlconftest.c +++ b/tests/qemuxmlconftest.c @@ -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,21 @@ 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 */ + 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 +863,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 +885,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; } -- 2.50.1

From: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com> --- .../vhost-user-fs-locking.x86_64-7.2.0.args | 35 ++++++++++++++ ...er-fs-locking.x86_64-7.2.0.virtiofsd0.args | 4 ++ .../vhost-user-fs-locking.x86_64-7.2.0.xml | 46 +++++++++++++++++++ .../qemuxmlconfdata/vhost-user-fs-locking.xml | 46 +++++++++++++++++++ tests/qemuxmlconftest.c | 1 + 5 files changed, 132 insertions(+) create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-locking.x86_64-7.2.0.args create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-locking.x86_64-7.2.0.virtiofsd0.args create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-locking.x86_64-7.2.0.xml create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-locking.xml diff --git a/tests/qemuxmlconfdata/vhost-user-fs-locking.x86_64-7.2.0.args b/tests/qemuxmlconfdata/vhost-user-fs-locking.x86_64-7.2.0.args new file mode 100644 index 0000000000..ee8625dc0d --- /dev/null +++ b/tests/qemuxmlconfdata/vhost-user-fs-locking.x86_64-7.2.0.args @@ -0,0 +1,35 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/var/lib/libvirt/qemu/domain--1-guest \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-guest/.local/share \ +XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-guest/.cache \ +XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-guest/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=guest,debug-threads=on \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-guest/master-key.aes"}' \ +-machine pc-i440fx-7.2,usb=off,dump-guest-core=off \ +-accel kvm \ +-cpu qemu64 \ +-m size=14680064k \ +-overcommit mem-lock=off \ +-smp 2,sockets=2,cores=1,threads=1 \ +-object '{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/var/lib/libvirt/qemu/ram/-1-guest/ram-node0","share":true,"size":15032385536}' \ +-numa node,nodeid=0,cpus=0-1,memdev=ram-node0 \ +-uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-chardev socket,id=chr-vu-fs0,path=/var/lib/libvirt/qemu/domain--1-guest/fs0-fs.sock \ +-device '{"driver":"vhost-user-fs-pci","id":"fs0","chardev":"chr-vu-fs0","queue-size":1024,"tag":"mount_tag","bus":"pci.0","addr":"0x2"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxmlconfdata/vhost-user-fs-locking.x86_64-7.2.0.virtiofsd0.args b/tests/qemuxmlconfdata/vhost-user-fs-locking.x86_64-7.2.0.virtiofsd0.args new file mode 100644 index 0000000000..c5db508e64 --- /dev/null +++ b/tests/qemuxmlconfdata/vhost-user-fs-locking.x86_64-7.2.0.virtiofsd0.args @@ -0,0 +1,4 @@ +/usr/libexec/virtiofsd \ +--fd=1730 \ +-o source=/path,cache=always,sandbox=namespace,xattr,flock,posix_lock \ +--thread-pool-size=16 diff --git a/tests/qemuxmlconfdata/vhost-user-fs-locking.x86_64-7.2.0.xml b/tests/qemuxmlconfdata/vhost-user-fs-locking.x86_64-7.2.0.xml new file mode 100644 index 0000000000..5909939ec3 --- /dev/null +++ b/tests/qemuxmlconfdata/vhost-user-fs-locking.x86_64-7.2.0.xml @@ -0,0 +1,46 @@ +<domain type='kvm'> + <name>guest</name> + <uuid>126f2720-6f8e-45ab-a886-ec9277079a67</uuid> + <memory unit='KiB'>14680064</memory> + <currentMemory unit='KiB'>14680064</currentMemory> + <memoryBacking> + <source type='file'/> + <access mode='shared'/> + </memoryBacking> + <vcpu placement='static'>2</vcpu> + <os> + <type arch='x86_64' machine='pc-i440fx-7.2'>hvm</type> + <boot dev='hd'/> + </os> + <cpu mode='custom' match='exact' check='none'> + <model fallback='forbid'>qemu64</model> + <numa> + <cell id='0' cpus='0-1' memory='14680064' unit='KiB' memAccess='shared'/> + </numa> + </cpu> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <controller type='usb' index='0' model='none'/> + <controller type='pci' index='0' model='pci-root'/> + <filesystem type='mount' accessmode='passthrough'> + <driver type='virtiofs' queue='1024'/> + <binary path='/usr/libexec/virtiofsd' xattr='on'> + <cache mode='always'/> + <sandbox mode='namespace'/> + <lock posix='on' flock='on'/> + <thread_pool size='16'/> + </binary> + <source dir='/path'/> + <target dir='mount_tag'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </filesystem> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <audio id='1' type='none'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxmlconfdata/vhost-user-fs-locking.xml b/tests/qemuxmlconfdata/vhost-user-fs-locking.xml new file mode 100644 index 0000000000..602f2c617d --- /dev/null +++ b/tests/qemuxmlconfdata/vhost-user-fs-locking.xml @@ -0,0 +1,46 @@ +<domain type='kvm'> + <name>guest</name> + <uuid>126f2720-6f8e-45ab-a886-ec9277079a67</uuid> + <memory unit='KiB'>14680064</memory> + <currentMemory unit='KiB'>14680064</currentMemory> + <memoryBacking> + <source type='file'/> + <access mode='shared'/> + </memoryBacking> + <vcpu placement='static'>2</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <cpu mode='custom' match='exact' check='none'> + <model fallback='forbid'>qemu64</model> + <numa> + <cell id='0' cpus='0-1' memory='14680064' unit='KiB' memAccess='shared'/> + </numa> + </cpu> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <controller type='usb' index='0' model='none'/> + <controller type='pci' index='0' model='pci-root'/> + <filesystem type='mount' accessmode='passthrough'> + <driver type='virtiofs' queue='1024'/> + <binary path='/usr/libexec/virtiofsd' xattr='on'> + <cache mode='always'/> + <sandbox mode='namespace'/> + <lock posix='on' flock='on'/> + <thread_pool size='16'/> + </binary> + <source dir='/path'/> + <target dir='mount_tag'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </filesystem> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <audio id='1' type='none'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c index aaca9b6c05..743f6aff45 100644 --- a/tests/qemuxmlconftest.c +++ b/tests/qemuxmlconftest.c @@ -3057,6 +3057,7 @@ mymain(void) DO_TEST_CAPS_LATEST("vhost-user-fs-fd-openfiles"); DO_TEST_CAPS_LATEST("vhost-user-fs-hugepages"); DO_TEST_CAPS_LATEST("vhost-user-fs-readonly"); + DO_TEST_CAPS_VER("vhost-user-fs-locking", "7.2.0"); DO_TEST_CAPS_ARCH_LATEST("vhost-user-fs-ccw", "s390x"); DO_TEST_CAPS_ARCH_LATEST_PARSE_ERROR("vhost-user-fs-ccw-bootindex", "s390x"); -- 2.50.1
participants (2)
-
Ján Tomko
-
Laine Stump