]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: mock qemuInterfaceOpenVhostNet
authorJán Tomko <jtomko@redhat.com>
Tue, 17 Apr 2018 10:11:17 +0000 (12:11 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 17 Apr 2018 12:02:09 +0000 (14:02 +0200)
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@redhat.com>
Reported-by: Jiří Denemark <jdenemar@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
tests/qemuxml2argvdata/user-aliases.args
tests/qemuxml2argvmock.c

index d887d53fa56c60a71d3c461fa4b305fd9e09ed1d..774c599b5795b9e35db72a7dfd4e777c3544b76c 100644 (file)
@@ -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 \
index 177b24e0a9538ba20db2c85a858d6b9eacd5c05f..adab5c91117fd5cbf4a653f6b3f73f6558fe6fa0 100644 (file)
@@ -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;
+}