From 31413101a80f91cb76a28fee59299ee0774bb618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Tue, 17 Apr 2018 12:11:17 +0200 Subject: [PATCH] tests: mock qemuInterfaceOpenVhostNet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This functions contains logic that tries to use vhost for virtio interfaces, even if 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 Reported-by: Jiří Denemark Reviewed-by: Martin Kletzander --- 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 d887d53fa5..774c599b57 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 177b24e0a9..adab5c9111 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 #include @@ -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; +} -- GitLab