]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Query for vhostuser iface names at runtime
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 7 Jun 2017 13:43:58 +0000 (15:43 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 8 Jun 2017 13:02:22 +0000 (15:02 +0200)
https://bugzilla.redhat.com/show_bug.cgi?id=1459091

Currently, we are querying for vhostuser interface name in post
parse callback. At that time interface might not yet exist.
However, it has to exist when starting domain. Therefore it makes
more sense to query its name at that point. This partially
reverts 57b5e27.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_command.c
src/qemu/qemu_domain.c
tests/Makefile.am
tests/qemuxml2xmlmock.c [deleted file]
tests/qemuxml2xmloutdata/qemuxml2xmlout-net-vhostuser.xml
tests/qemuxml2xmltest.c

index 015af1036cd45a2ba5196cba13ac7bef34059ccd..44f778b7bf545e4a9a7f3c38d3c76dd6627a6a69 100644 (file)
@@ -52,6 +52,7 @@
 #include "secret_conf.h"
 #include "network/bridge_driver.h"
 #include "virnetdevtap.h"
+#include "virnetdevopenvswitch.h"
 #include "device_conf.h"
 #include "virstoragefile.h"
 #include "virtpm.h"
@@ -8310,6 +8311,9 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
                                        NULL, 0, NULL, 0)))
         goto error;
 
+    if (virNetDevOpenvswitchGetVhostuserIfname(net->data.vhostuser->data.nix.path,
+                                               &net->ifname) < 0)
+        goto error;
 
     virCommandAddArg(cmd, "-chardev");
     virCommandAddArg(cmd, chardev);
index 2aa3aaa47eb02c39b42c05ecc61a0dedb163f316..36fa450e82dafbf89bd18f85a93dc9bfbeeffaae 100644 (file)
@@ -3488,20 +3488,12 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
                                           def->emulator);
     }
 
-    if (dev->type == VIR_DOMAIN_DEVICE_NET) {
-        if (dev->data.net->type != VIR_DOMAIN_NET_TYPE_HOSTDEV &&
-            !dev->data.net->model) {
-            if (VIR_STRDUP(dev->data.net->model,
-                           qemuDomainDefaultNetModel(def, qemuCaps)) < 0)
-                goto cleanup;
-        }
-        if (dev->data.net->type == VIR_DOMAIN_NET_TYPE_VHOSTUSER &&
-            !dev->data.net->ifname) {
-            if (virNetDevOpenvswitchGetVhostuserIfname(
-                   dev->data.net->data.vhostuser->data.nix.path,
-                   &dev->data.net->ifname) < 0)
-                goto cleanup;
-        }
+    if (dev->type == VIR_DOMAIN_DEVICE_NET &&
+        dev->data.net->type != VIR_DOMAIN_NET_TYPE_HOSTDEV &&
+        !dev->data.net->model) {
+        if (VIR_STRDUP(dev->data.net->model,
+                       qemuDomainDefaultNetModel(def, qemuCaps)) < 0)
+            goto cleanup;
     }
 
     /* set default disk types and drivers */
index 7673329f2741ddee6589c7674abf29b486f56524..19986dc992e3c0f816c2603021ca896d9c14c64e 100644 (file)
@@ -288,7 +288,6 @@ test_helpers += qemucapsprobe
 test_libraries += libqemumonitortestutils.la \
                libqemutestdriver.la \
                qemuxml2argvmock.la \
-               qemuxml2xmlmock.la \
                qemucaps2xmlmock.la \
                qemucapsprobemock.la \
                qemucpumock.la \
@@ -575,12 +574,6 @@ qemuxml2argvmock_la_CFLAGS = $(AM_CFLAGS)
 qemuxml2argvmock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS)
 qemuxml2argvmock_la_LIBADD = $(MOCKLIBS_LIBS)
 
-qemuxml2xmlmock_la_SOURCES = \
-       qemuxml2xmlmock.c
-qemuxml2xmlmock_la_CFLAGS = $(AM_CFLAGS)
-qemuxml2xmlmock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS)
-qemuxml2xmlmock_la_LIBADD = $(MOCKLIBS_LIBS)
-
 qemuxml2xmltest_SOURCES = \
        qemuxml2xmltest.c testutilsqemu.c testutilsqemu.h \
        testutils.c testutils.h
diff --git a/tests/qemuxml2xmlmock.c b/tests/qemuxml2xmlmock.c
deleted file mode 100644 (file)
index 0d3e6f2..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2016 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * Author: Michal Privoznik <mprivozn@redhat.com>
- */
-
-#include <config.h>
-
-#include "virnetdevopenvswitch.h"
-#include "virstring.h"
-
-#define VIR_FROM_THIS VIR_FROM_NONE
-
-int
-virNetDevOpenvswitchGetVhostuserIfname(const char *path ATTRIBUTE_UNUSED,
-                                       char **ifname)
-{
-    return VIR_STRDUP(*ifname, "vhost-user0");
-}
index a4f4e4142118a091d8c1dbb92388a962138d34b3..b7f1bdc57f1a47b46a83bc41b28ff72f0788c5a1 100644 (file)
     <interface type='vhostuser'>
       <mac address='52:54:00:ee:96:6b'/>
       <source type='unix' path='/tmp/vhost0.sock' mode='server'/>
-      <target dev='vhost-user0'/>
       <model type='virtio'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
     </interface>
     <interface type='vhostuser'>
       <mac address='52:54:00:ee:96:6c'/>
       <source type='unix' path='/tmp/vhost1.sock' mode='client'/>
-      <target dev='vhost-user0'/>
       <model type='virtio'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
     </interface>
index fff13e2361326ee1806cc6bb2ff2693208d65b9a..6aececb598ef6491f382b445537112bc77a08278 100644 (file)
@@ -1142,7 +1142,7 @@ mymain(void)
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
-VIR_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/qemuxml2xmlmock.so")
+VIR_TEST_MAIN(mymain)
 
 #else