The code is trying to open /dev/vhost-net from the host machine and if the current user has access to it, the command line will end up having two more options for an interface (,vhost=on,vhostfd=X where X is next free file descriptor). Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx> --- tests/qemuxml2argvmock.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 177b24e0a953..11626e2794c1 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -20,6 +20,10 @@ #include <config.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + #include "internal.h" #include "viralloc.h" #include "vircommand.h" @@ -188,3 +192,35 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path ATTRIBUTE_UNUSED, { return VIR_STRDUP(*ifname, "vhost-user0"); } + +static int (*real_open)(const char *path, int flags, ...); + +static void init_syms(void) +{ + if (real_open) + return; + + VIR_MOCK_REAL_INIT(open); +} + +int open(const char *path, int flags, ...) +{ + va_list ap; + mode_t mode = 0; + + init_syms(); + + if (STREQ(path, "/dev/vhost-net")) + return -1; + + /* The mode argument is mandatory when O_CREAT is set in flags, + * otherwise the argument is ignored. + */ + if (flags & O_CREAT) { + va_start(ap, flags); + mode = (mode_t) va_arg(ap, int); + va_end(ap); + } + + return real_open(path, flags, mode); +} -- 2.17.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list