]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: qemuxmlconftest: test passt command line too
authorJán Tomko <jtomko@redhat.com>
Thu, 17 Jul 2025 16:45:29 +0000 (18:45 +0200)
committerJán Tomko <jtomko@redhat.com>
Wed, 24 Sep 2025 13:11:18 +0000 (15:11 +0200)
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>
Reviewed-by: Laine Stump <laine@redhat.com>
tests/qemuxmlconfdata/net-user-passt.x86_64-7.2.0.passt0.args [new file with mode: 0644]
tests/qemuxmlconfdata/net-user-passt.x86_64-latest.passt0.args [new file with mode: 0644]
tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.passt0.args [new file with mode: 0644]
tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.passt1.args [new file with mode: 0644]
tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.passt2.args [new file with mode: 0644]
tests/qemuxmlconfdata/schema-reorder-domain-subelements.x86_64-latest.passt0.args [new file with mode: 0644]
tests/qemuxmlconftest.c

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 (file)
index 0000000..b0f26d8
--- /dev/null
@@ -0,0 +1,15 @@
+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 \
+--hostname hostname1 \
+--fqdn hostname1.test.local \
+--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 (file)
index 0000000..b0f26d8
--- /dev/null
@@ -0,0 +1,15 @@
+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 \
+--hostname hostname1 \
+--fqdn hostname1.test.local \
+--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 (file)
index 0000000..bd176fd
--- /dev/null
@@ -0,0 +1,16 @@
+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 \
+--hostname hostname1 \
+--fqdn hostname1.test.local \
+--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 (file)
index 0000000..4bebc2b
--- /dev/null
@@ -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 (file)
index 0000000..35cd30a
--- /dev/null
@@ -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 (file)
index 0000000..5957410
--- /dev/null
@@ -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
index 3101f7eef4d650df387962afaebb90fc6912079b..4beea912820d78116c15c430030623db7a925b12 100644 (file)
@@ -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: