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
On 9/9/25 8:05 AM, Ján Tomko via Devel wrote: > 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> The test results need to be regenerated due to commit cca246e0cbd9f793f91537800f649179d8354244 > --- > .../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:
© 2016 - 2025 Red Hat, Inc.