qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

vhost-net-user: add stubs for when no virtio-net device is present

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é <philmd@redhat.com>
Message-Id: <1543851204-41186-3-git-send-email-pbonzini@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1550165756-21617-3-git-send-email-pbonzini@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

authored by

Paolo Bonzini and committed by
Michael S. Tsirkin
56f41de7 7b28c615

+32 -3
+1 -1
configure
··· 6590 6590 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak 6591 6591 fi 6592 6592 if test "$vhost_net" = "yes" && test "$vhost_user" = "yes"; then 6593 - echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak 6593 + echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak 6594 6594 fi 6595 6595 if test "$vhost_crypto" = "yes" ; then 6596 6596 echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
+4
hw/net/vhost_net.c
··· 193 193 } 194 194 195 195 /* Set sane init value. Override when guest acks. */ 196 + #ifdef CONFIG_VHOST_NET_USER 196 197 if (net->nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) { 197 198 features = vhost_user_get_acked_features(net->nc); 198 199 if (~net->dev.features & features) { ··· 202 203 goto fail; 203 204 } 204 205 } 206 + #endif 205 207 206 208 vhost_net_ack_features(net, features); 207 209 ··· 413 415 case NET_CLIENT_DRIVER_TAP: 414 416 vhost_net = tap_get_vhost_net(nc); 415 417 break; 418 + #ifdef CONFIG_VHOST_NET_USER 416 419 case NET_CLIENT_DRIVER_VHOST_USER: 417 420 vhost_net = vhost_user_get_vhost_net(nc); 418 421 assert(vhost_net); 419 422 break; 423 + #endif 420 424 default: 421 425 break; 422 426 }
+3 -1
net/Makefile.objs
··· 3 3 common-obj-y += dump.o 4 4 common-obj-y += eth.o 5 5 common-obj-$(CONFIG_L2TPV3) += l2tpv3.o 6 - common-obj-$(CONFIG_POSIX) += vhost-user.o 6 + common-obj-$(call land,$(CONFIG_VIRTIO_NET),$(CONFIG_VHOST_NET_USER)) += vhost-user.o 7 + common-obj-$(call land,$(call lnot,$(CONFIG_VIRTIO_NET)),$(CONFIG_VHOST_NET_USER)) += vhost-user-stub.o 8 + common-obj-$(CONFIG_ALL) += vhost-user-stub.o 7 9 common-obj-$(CONFIG_SLIRP) += slirp.o 8 10 common-obj-$(CONFIG_VDE) += vde.o 9 11 common-obj-$(CONFIG_NETMAP) += netmap.o
+1 -1
net/net.c
··· 961 961 [NET_CLIENT_DRIVER_BRIDGE] = net_init_bridge, 962 962 #endif 963 963 [NET_CLIENT_DRIVER_HUBPORT] = net_init_hubport, 964 - #ifdef CONFIG_VHOST_NET_USED 964 + #ifdef CONFIG_VHOST_NET_USER 965 965 [NET_CLIENT_DRIVER_VHOST_USER] = net_init_vhost_user, 966 966 #endif 967 967 #ifdef CONFIG_L2TPV3
+23
net/vhost-user-stub.c
··· 1 + /* 2 + * vhost-user-stub.c 3 + * 4 + * Copyright (c) 2018 Red Hat, Inc. 5 + * 6 + * This work is licensed under the terms of the GNU GPL, version 2 or later. 7 + * See the COPYING file in the top-level directory. 8 + * 9 + */ 10 + 11 + #include "qemu/osdep.h" 12 + #include "clients.h" 13 + #include "net/vhost_net.h" 14 + #include "net/vhost-user.h" 15 + #include "qemu/error-report.h" 16 + #include "qapi/error.h" 17 + 18 + int net_init_vhost_user(const Netdev *netdev, const char *name, 19 + NetClientState *peer, Error **errp) 20 + { 21 + error_setg(errp, "vhost-user requires frontend driver virtio-net-*"); 22 + return -1; 23 + }