[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 42/54] vhost-net-user: add stubs for when no virtio-n
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 42/54] vhost-net-user: add stubs for when no virtio-net device is present |
Date: |
Wed, 12 Dec 2018 16:23:03 +0100 |
hw/net/vhost_net.c needs functions that are declared in net/vhost-user.c: the
vhost-user code is always compiled into QEMU, only the constructor
net_init_vhost_user is unreachable. Also, net/vhost-user.c needs functions
declared in hw/virtio/vhost-stub.c even if no virtio device exists.
Break this dependency. First, add a minimal version of net/vhost-user.c,
with no functionality and no dependency on vhost code. Second, #ifdef out
the calls back to net/vhost-user.c from hw/net/vhost_net.c.
While at it, this patch fixes the CONFIG_VHOST_NET_USE*D* typo.
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Thomas Huth <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
configure | 2 +-
hw/net/vhost_net.c | 4 ++++
net/Makefile.objs | 4 +++-
net/net.c | 2 +-
net/vhost-user-stub.c | 23 +++++++++++++++++++++++
5 files changed, 32 insertions(+), 3 deletions(-)
create mode 100644 net/vhost-user-stub.c
diff --git a/configure b/configure
index 131eae5..b995d71 100755
--- a/configure
+++ b/configure
@@ -6515,7 +6515,7 @@ if test "$vhost_scsi" = "yes" ; then
echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
fi
if test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
- echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
+ echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
fi
if test "$vhost_crypto" = "yes" ; then
echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index b901306..2a300ee 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -193,6 +193,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
}
/* Set sane init value. Override when guest acks. */
+#ifdef CONFIG_VHOST_NET_USER
if (net->nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
features = vhost_user_get_acked_features(net->nc);
if (~net->dev.features & features) {
@@ -202,6 +203,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
goto fail;
}
}
+#endif
vhost_net_ack_features(net, features);
@@ -413,10 +415,12 @@ VHostNetState *get_vhost_net(NetClientState *nc)
case NET_CLIENT_DRIVER_TAP:
vhost_net = tap_get_vhost_net(nc);
break;
+#ifdef CONFIG_VHOST_NET_USER
case NET_CLIENT_DRIVER_VHOST_USER:
vhost_net = vhost_user_get_vhost_net(nc);
assert(vhost_net);
break;
+#endif
default:
break;
}
diff --git a/net/Makefile.objs b/net/Makefile.objs
index b2bf88a..df2b409 100644
--- a/net/Makefile.objs
+++ b/net/Makefile.objs
@@ -3,7 +3,9 @@ common-obj-y += socket.o
common-obj-y += dump.o
common-obj-y += eth.o
common-obj-$(CONFIG_L2TPV3) += l2tpv3.o
-common-obj-$(CONFIG_POSIX) += vhost-user.o
+common-obj-$(call land,$(CONFIG_VIRTIO_NET),$(CONFIG_VHOST_NET_USER)) +=
vhost-user.o
+common-obj-$(call land,$(call
lnot,$(CONFIG_VIRTIO_NET)),$(CONFIG_VHOST_NET_USER)) += vhost-user-stub.o
+common-obj-$(CONFIG_ALL) += vhost-user-stub.o
common-obj-$(CONFIG_SLIRP) += slirp.o
common-obj-$(CONFIG_VDE) += vde.o
common-obj-$(CONFIG_NETMAP) += netmap.o
diff --git a/net/net.c b/net/net.c
index 3acbdcc..ca0e14c 100644
--- a/net/net.c
+++ b/net/net.c
@@ -961,7 +961,7 @@ static int (* const
net_client_init_fun[NET_CLIENT_DRIVER__MAX])(
[NET_CLIENT_DRIVER_BRIDGE] = net_init_bridge,
#endif
[NET_CLIENT_DRIVER_HUBPORT] = net_init_hubport,
-#ifdef CONFIG_VHOST_NET_USED
+#ifdef CONFIG_VHOST_NET_USER
[NET_CLIENT_DRIVER_VHOST_USER] = net_init_vhost_user,
#endif
#ifdef CONFIG_L2TPV3
diff --git a/net/vhost-user-stub.c b/net/vhost-user-stub.c
new file mode 100644
index 0000000..52ab4e1
--- /dev/null
+++ b/net/vhost-user-stub.c
@@ -0,0 +1,23 @@
+/*
+ * vhost-user-stub.c
+ *
+ * Copyright (c) 2018 Red Hat, Inc.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "qemu/osdep.h"
+#include "clients.h"
+#include "net/vhost_net.h"
+#include "net/vhost-user.h"
+#include "qemu/error-report.h"
+#include "qapi/error.h"
+
+int net_init_vhost_user(const Netdev *netdev, const char *name,
+ NetClientState *peer, Error **errp)
+{
+ error_setg(errp, "vhost-user requires frontend driver virtio-net-*");
+ return -1;
+}
--
1.8.3.1
- [Qemu-devel] [PULL 29/54] qemu/queue.h: remove Q_TAILQ_{HEAD, ENTRY}, (continued)
- [Qemu-devel] [PULL 29/54] qemu/queue.h: remove Q_TAILQ_{HEAD, ENTRY}, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 36/54] tcg/tcg.h: Remove GCC check for tcg_debug_assert() macro, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 33/54] configure: Add a test for the minimum compiler version, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 18/54] build-sys: don't include windows.h, osdep.h does it, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 37/54] audio/alsaaudio: Remove compiler check around pragma, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 27/54] qemu/queue.h: leave head structs anonymous unless necessary, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 30/54] qemu/queue.h: reimplement QTAILQ without pointer-to-pointers, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 38/54] includes: Replace QEMU_GNUC_PREREQ with "__has_builtin || !defined(__clang__)", Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 40/54] hw/watchdog/wdt_i6300esb : remove a unnecessary comment, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 46/54] vhost-user-test: use g_cond_broadcast, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 42/54] vhost-net-user: add stubs for when no virtio-net device is present,
Paolo Bonzini <=
- [Qemu-devel] [PULL 43/54] vhost: restrict Linux dependency to kernel vhost, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 39/54] Remove QEMU_ARTIFICIAL macro, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 54/54] vhost-user-test: create a temporary directory per TestServer, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 49/54] vhost-user-test: support VHOST_USER_PROTOCOL_F_CROSS_ENDIAN, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 53/54] vhost-user-test: small changes to init_hugepagefs, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 52/54] vhost-user-test: create a main loop per TestServer, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 48/54] vhost-user: support cross-endian vnet headers, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 50/54] vhost-user-test: skip if there is no memory at address 0, Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 44/54] vhost-net: compile it on all targets that have virtio-net., Paolo Bonzini, 2018/12/12
- [Qemu-devel] [PULL 51/54] vhost-user-test: reduce usage of global_qtest, Paolo Bonzini, 2018/12/12