提交 31413101 编写于 作者: J Ján Tomko

tests: mock qemuInterfaceOpenVhostNet

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 c1f684ea - deprecate QEMU_CAPS_VHOST_NET.
Signed-off-by: NJán Tomko <jtomko@redhat.com>
Reported-by: NJiří Denemark <jdenemar@redhat.com>
Reviewed-by: NMartin Kletzander <mkletzan@redhat.com>
上级 374777ee
......@@ -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 \
......
......@@ -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;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册