From: Peter Krempa <[email protected]> Use virTestMakeDummyFD() to get a real FD for the test in qemuxmlconftest.
Use virTestMakeDummyFD() also in qemuhotplugmock. Signed-off-by: Peter Krempa <[email protected]> --- tests/qemuhotplugmock.c | 7 ++++--- tests/qemuxml2argvmock.c | 6 ++---- .../qemuxmlconfdata/net-vdpa-multiqueue.x86_64-latest.args | 2 +- tests/qemuxmlconfdata/net-vdpa.x86_64-latest.args | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/qemuhotplugmock.c b/tests/qemuhotplugmock.c index 79e9bdd8a8..6c90f4e58e 100644 --- a/tests/qemuhotplugmock.c +++ b/tests/qemuhotplugmock.c @@ -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)); } diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 8261093964..de10117330 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -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 * diff --git a/tests/qemuxmlconfdata/net-vdpa-multiqueue.x86_64-latest.args b/tests/qemuxmlconfdata/net-vdpa-multiqueue.x86_64-latest.args index ccf76cb422..4de9a8667b 100644 --- a/tests/qemuxmlconfdata/net-vdpa-multiqueue.x86_64-latest.args +++ b/tests/qemuxmlconfdata/net-vdpa-multiqueue.x86_64-latest.args @@ -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"}' \ diff --git a/tests/qemuxmlconfdata/net-vdpa.x86_64-latest.args b/tests/qemuxmlconfdata/net-vdpa.x86_64-latest.args index 2bf22174e4..ecefa3d59d 100644 --- a/tests/qemuxmlconfdata/net-vdpa.x86_64-latest.args +++ b/tests/qemuxmlconfdata/net-vdpa.x86_64-latest.args @@ -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"}' \ -- 2.54.0
