]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuxmlconftest: (consistently) use real FDs in tests for VDPA netdevs
authorPeter Krempa <pkrempa@redhat.com>
Tue, 17 May 2022 13:22:16 +0000 (15:22 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 25 May 2026 11:28:58 +0000 (13:28 +0200)
Use virTestMakeDummyFD() to get a real FD for the test in
qemuxmlconftest.

Use virTestMakeDummyFD() also in qemuhotplugmock.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tests/qemuhotplugmock.c
tests/qemuxml2argvmock.c
tests/qemuxmlconfdata/net-vdpa-multiqueue.x86_64-latest.args
tests/qemuxmlconfdata/net-vdpa.x86_64-latest.args

index 79e9bdd8a8c80ec318b33fc9968b0ae318d43b69..6c90f4e58ef134528e1eff63ac5d039bd75d07c6 100644 (file)
@@ -26,6 +26,8 @@
 #include "virdevmapper.h"
 #include <fcntl.h>
 
+#include "testutils.h"
+
 #define LIBVIRT_QEMU_MONITOR_PRIV_H_ALLOW
 #include "qemu/qemu_monitor_priv.h"
 
@@ -71,10 +73,9 @@ qemuProcessKillManagedPRDaemon(virDomainObj *vm G_GNUC_UNUSED)
 }
 
 int
-qemuVDPAConnect(const char *devicepath G_GNUC_UNUSED)
+qemuVDPAConnect(const char *devicepath)
 {
-    /* need a valid fd or sendmsg won't work. Just open /dev/null */
-    return open("/dev/null", O_RDONLY);
+    return virTestMakeDummyFD(g_strdup_printf("@vdpa-%s-fd@", devicepath));
 }
 
 
index 826109396435b6721af1d8b7f7b2957f871d2020..de101173309752bda027d937f79708e2f4ea53c0 100644 (file)
@@ -266,11 +266,9 @@ virNetDevBandwidthSetRootQDisc(const char *ifname G_GNUC_UNUSED,
 
 
 int
-qemuVDPAConnect(const char *devicepath G_GNUC_UNUSED)
+qemuVDPAConnect(const char *devicepath)
 {
-    if (fcntl(1732, F_GETFD) != -1)
-        abort();
-    return 1732;
+    return virTestMakeDummyFD(g_strdup_printf("@vdpa-%s-fd@", devicepath));
 }
 
 char *
index ccf76cb4227ad4027f6758578d98ab2aeba93d68..4de9a8667bc8c2434fe3cbd54da70c374001c879 100644 (file)
@@ -27,7 +27,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
 -no-shutdown \
 -boot strict=on \
 -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
--add-fd set=0,fd=XXXXXXX,opaque=net0-vdpa \
+-add-fd set=0,fd=@vdpa-/dev/vhost-vdpa-0-fd@,opaque=net0-vdpa \
 -netdev '{"type":"vhost-vdpa","vhostdev":"/dev/fdset/0","queues":2,"id":"hostnet0"}' \
 -device '{"driver":"virtio-net-pci","mq":true,"vectors":6,"netdev":"hostnet0","id":"net0","mac":"52:54:00:95:db:c0","bus":"pci.0","addr":"0x2"}' \
 -audiodev '{"id":"audio1","driver":"none"}' \
index 2bf22174e45c20dc6781bcc536f7ee4814566c22..ecefa3d59dc4c7243c16db981932b770a0937c73 100644 (file)
@@ -27,7 +27,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
 -no-shutdown \
 -boot strict=on \
 -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
--add-fd set=0,fd=XXXXXXX,opaque=net0-vdpa \
+-add-fd set=0,fd=@vdpa-/dev/vhost-vdpa-0-fd@,opaque=net0-vdpa \
 -netdev '{"type":"vhost-vdpa","vhostdev":"/dev/fdset/0","id":"hostnet0"}' \
 -device '{"driver":"virtio-net-pci","netdev":"hostnet0","id":"net0","mac":"52:54:00:95:db:c0","bus":"pci.0","addr":"0x2"}' \
 -audiodev '{"id":"audio1","driver":"none"}' \