This functions contains logic that tries to use vhost for virtio
interfaces, even if <driver name='vhost'/> was not supplied.
In this case, a failure is non-fatal.
On my system, /dev/vhost-net was not accessible to the user running
'make check', but we should not depend on that.
Mock it to prevent accessing /dev/vhost-net and return some predictable
file descriptor numbers instead.
Introduced by commit c1f684e - deprecate QEMU_CAPS_VHOST_NET.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
Reported-by: Jiří Denemark <jdenemar(a)redhat.com>
---
tests/qemuxml2argvdata/user-aliases.args | 2 +-
tests/qemuxml2argvmock.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/tests/qemuxml2argvdata/user-aliases.args
b/tests/qemuxml2argvdata/user-aliases.args
index d887d53fa..774c599b5 100644
--- a/tests/qemuxml2argvdata/user-aliases.args
+++ b/tests/qemuxml2argvdata/user-aliases.args
@@ -51,7 +51,7 @@ id=ua-myEncryptedDisk1 \
if=none,id=drive-ua-WhatAnAwesomeCDROM,media=cdrom,readonly=on,cache=none \
-device ide-drive,bus=ide.1,unit=0,drive=drive-ua-WhatAnAwesomeCDROM,\
id=ua-WhatAnAwesomeCDROM \
--netdev tap,fd=3,id=hostua-CheckoutThisNIC \
+-netdev tap,fd=3,id=hostua-CheckoutThisNIC,vhost=on,vhostfd=44 \
-device virtio-net-pci,netdev=hostua-CheckoutThisNIC,id=ua-CheckoutThisNIC,\
mac=52:54:00:d6:c0:0b,bus=pci.0,addr=0x3 \
-netdev socket,listen=127.0.0.1:1234,id=hostua-WeCanAlsoDoServerMode \
diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index 177b24e0a..adab5c911 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -36,6 +36,7 @@
#include "virstring.h"
#include "virtpm.h"
#include "virutil.h"
+#include "qemu/qemu_interface.h"
#include <time.h>
#include <unistd.h>
@@ -188,3 +189,21 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path
ATTRIBUTE_UNUSED,
{
return VIR_STRDUP(*ifname, "vhost-user0");
}
+
+int
+qemuInterfaceOpenVhostNet(virDomainDefPtr def ATTRIBUTE_UNUSED,
+ virDomainNetDefPtr net,
+ int *vhostfd,
+ size_t *vhostfdSize)
+{
+ size_t i;
+
+ if (!(net->model && STREQ(net->model, "virtio"))) {
+ *vhostfdSize = 0;
+ return 0;
+ }
+
+ for (i = 0; i < *vhostfdSize; i++)
+ vhostfd[i] = STDERR_FILENO + 42 + i;
+ return 0;
+}
--
2.16.1