thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
Blob Blame History Raw
From 398bebe1d3c1feea6e4578b1ce40366ac39f933e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
Date: Wed, 2 Aug 2017 15:13:18 +0200
Subject: [PATCH 3/4] pegas: add --disable-vhost-user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-id: <20170802151319.16790-2-marcandre.lureau@redhat.com>
Patchwork-id: 75884
O-Subject: [RHEL-ALT-7.4 qemu-kvm PATCH v2 1/2] pegas: add --disable-vhost-user
Bugzilla: 1455269
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>

Learn to disable vhost-user for Pegas builds.

When trying to make a vhost-user netdev, it gives the following error:

-netdev vhost-user,id=foo,chardev=chr-test: Parameter 'type' expects a netdev backend type

And similar error with the HMP/QMP monitors.

Upstream-status:
https://lists.nongnu.org/archive/html/qemu-devel/2017-07/msg09016.html

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 configure              | 14 +++++++++++++-
 hw/net/vhost_net.c     | 10 ++++++++--
 hw/net/virtio-net.c    |  4 ++++
 net/Makefile.objs      |  3 ++-
 net/hub.c              |  2 ++
 net/net.c              |  4 +++-
 qemu-options.hx        |  4 ++++
 tests/Makefile.include |  6 +++---
 8 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index 9f200c2..ca82854 100755
--- a/configure
+++ b/configure
@@ -227,6 +227,7 @@ xfs=""
 vhost_net="no"
 vhost_scsi="no"
 vhost_vsock="no"
+vhost_user="yes"
 kvm="no"
 hax="no"
 rdma=""
@@ -1204,6 +1205,10 @@ for opt do
   ;;
   --enable-vtd) vtd="yes"
   ;;
+  --disable-vhost-user) vhost_user="no"
+  ;;
+  --enable-vhost-user) vhost_user="yes"
+  ;;
   *)
       echo "ERROR: unknown option $opt"
       echo "Try '$0 --help' for more information"
@@ -1452,6 +1457,7 @@ disabled with --disable-FEATURE, default is enabled if available:
   tools           build qemu-io, qemu-nbd and qemu-image tools
   vxhs            Veritas HyperScale vDisk backend support
   vtd             Emulated VT-d support (only affects x86 targets)
+  vhost-user      vhost-user support
 
 NOTE: The object files are built at the place where configure is launched
 EOF
@@ -5135,6 +5141,7 @@ echo "libcap-ng support $cap_ng"
 echo "vhost-net support $vhost_net"
 echo "vhost-scsi support $vhost_scsi"
 echo "vhost-vsock support $vhost_vsock"
+echo "vhost-user support $vhost_user"
 echo "Trace backends    $trace_backends"
 if have_backend "simple"; then
 echo "Trace output file $trace_file-<pid>"
@@ -5557,6 +5564,9 @@ fi
 if test "$vhost_vsock" = "yes" ; then
   echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
 fi
+if test "$vhost_user" = "yes" ; then
+  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
+fi
 if test "$blobs" = "yes" ; then
   echo "INSTALL_BLOBS=yes" >> $config_host_mak
 fi
@@ -6159,7 +6169,9 @@ case "$target_name" in
       echo "CONFIG_KVM=y" >> $config_target_mak
       if test "$vhost_net" = "yes" ; then
         echo "CONFIG_VHOST_NET=y" >> $config_target_mak
-        echo "CONFIG_VHOST_NET_TEST_$target_name=y" >> $config_host_mak
+        if test "$vhost_user" = "yes" ; then
+          echo "CONFIG_VHOST_USER_TEST_$target_name=y" >> $config_host_mak
+        fi
       fi
     fi
 esac
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index e037db6..40438a8 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -95,9 +95,11 @@ static const int *vhost_net_get_feature_bits(struct vhost_net *net)
     case NET_CLIENT_DRIVER_TAP:
         feature_bits = kernel_feature_bits;
         break;
+#ifdef CONFIG_VHOST_USER
     case NET_CLIENT_DRIVER_VHOST_USER:
         feature_bits = user_feature_bits;
         break;
+#endif
     default:
         error_report("Feature bits not defined for this type: %d",
                 net->nc->info->type);
@@ -193,6 +195,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
         }
     }
 
+#ifdef CONFIG_VHOST_USER
     /* Set sane init value. Override when guest acks. */
     if (net->nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
         features = vhost_user_get_acked_features(net->nc);
@@ -203,7 +206,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
             goto fail;
         }
     }
-
+#endif
     vhost_net_ack_features(net, features);
 
     return net;
@@ -309,6 +312,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
         net = get_vhost_net(ncs[i].peer);
         vhost_net_set_vq_index(net, i * 2);
 
+#ifdef CONFIG_VHOST_USER
         /* Suppress the masking guest notifiers on vhost user
          * because vhost user doesn't interrupt masking/unmasking
          * properly.
@@ -316,8 +320,8 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
         if (net->nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
             dev->use_guest_notifier_mask = false;
         }
+#endif
      }
-
     r = k->set_guest_notifiers(qbus->parent, total_queues * 2, true);
     if (r < 0) {
         error_report("Error binding guest notifier: %d", -r);
@@ -414,10 +418,12 @@ VHostNetState *get_vhost_net(NetClientState *nc)
     case NET_CLIENT_DRIVER_TAP:
         vhost_net = tap_get_vhost_net(nc);
         break;
+#ifdef CONFIG_VHOST_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/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 39c336e..9f61432 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -502,9 +502,11 @@ static int peer_attach(VirtIONet *n, int index)
         return 0;
     }
 
+#ifdef CONFIG_VHOST_USER
     if (nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
         vhost_set_vring_enable(nc->peer, 1);
     }
+#endif
 
     if (nc->peer->info->type != NET_CLIENT_DRIVER_TAP) {
         return 0;
@@ -525,9 +527,11 @@ static int peer_detach(VirtIONet *n, int index)
         return 0;
     }
 
+#ifdef CONFIG_VHOST_USER
     if (nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
         vhost_set_vring_enable(nc->peer, 0);
     }
+#endif
 
     if (nc->peer->info->type !=  NET_CLIENT_DRIVER_TAP) {
         return 0;
diff --git a/net/Makefile.objs b/net/Makefile.objs
index 2e2fd43..a8f6556 100644
--- a/net/Makefile.objs
+++ b/net/Makefile.objs
@@ -3,7 +3,8 @@ 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) += tap.o vhost-user.o
+common-obj-$(CONFIG_POSIX) += tap.o
+common-obj-$(CONFIG_VHOST_USER) += vhost-user.o
 common-obj-$(CONFIG_LINUX) += tap-linux.o
 common-obj-$(CONFIG_WIN32) += tap-win32.o
 common-obj-$(CONFIG_BSD) += tap-bsd.o
diff --git a/net/hub.c b/net/hub.c
index 32d8cf5..ec06275 100644
--- a/net/hub.c
+++ b/net/hub.c
@@ -322,7 +322,9 @@ void net_hub_check_clients(void)
             case NET_CLIENT_DRIVER_TAP:
             case NET_CLIENT_DRIVER_SOCKET:
             case NET_CLIENT_DRIVER_VDE:
+#ifdef CONFIG_VHOST_USER
             case NET_CLIENT_DRIVER_VHOST_USER:
+#endif
                 has_host_dev = 1;
                 break;
             default:
diff --git a/net/net.c b/net/net.c
index 0ac3b9e..4da90c1 100644
--- a/net/net.c
+++ b/net/net.c
@@ -955,7 +955,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
+#if defined(CONFIG_VHOST_NET_USED) && defined(CONFIG_VHOST_USER)
         [NET_CLIENT_DRIVER_VHOST_USER] = net_init_vhost_user,
 #endif
 #ifdef CONFIG_L2TPV3
@@ -1031,10 +1031,12 @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp)
             legacy.type = NET_CLIENT_DRIVER_NETMAP;
             legacy.u.netmap = opts->u.netmap;
             break;
+#ifdef CONFIG_VHOST_USER
         case NET_LEGACY_OPTIONS_TYPE_VHOST_USER:
             legacy.type = NET_CLIENT_DRIVER_VHOST_USER;
             legacy.u.vhost_user = opts->u.vhost_user;
             break;
+#endif
         default:
             abort();
         }
diff --git a/qemu-options.hx b/qemu-options.hx
index 2f25547..30b6256 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1741,8 +1741,10 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
     "                VALE port (created on the fly) called 'name' ('nmname' is name of the \n"
     "                netmap device, defaults to '/dev/netmap')\n"
 #endif
+#ifdef CONFIG_VHOST_USER
     "-netdev vhost-user,id=str,chardev=dev[,vhostforce=on|off]\n"
     "                configure a vhost-user network, backed by a chardev 'dev'\n"
+#endif
     "-netdev hubport,id=str,hubid=n\n"
     "                configure a hub port on QEMU VLAN 'n'\n", QEMU_ARCH_ALL)
 DEF("net", HAS_ARG, QEMU_OPTION_net,
@@ -2175,6 +2177,7 @@ The hubport netdev lets you connect a NIC to a QEMU "vlan" instead of a single
 netdev.  @code{-net} and @code{-device} with parameter @option{vlan} create the
 required hub automatically.
 
+#ifdef CONFIG_VHOST_USER
 @item -netdev vhost-user,chardev=@var{id}[,vhostforce=on|off][,queues=n]
 
 Establish a vhost-user netdev, backed by a chardev @var{id}. The chardev should
@@ -2192,6 +2195,7 @@ qemu-kvm -m 512 -object memory-backend-file,id=mem,size=512M,mem-path=/hugetlbfs
          -netdev type=vhost-user,id=net0,chardev=chr0 \
          -device virtio-net-pci,netdev=net0
 @end example
+#endif
 
 @item -net dump[,vlan=@var{n}][,file=@var{file}][,len=@var{len}]
 Dump network traffic on VLAN @var{n} to file @var{file} (@file{qemu-vlan0.pcap} by default).
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 0b94a20..3e3870f 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -230,9 +230,9 @@ gcov-files-i386-y += hw/usb/hcd-xhci.c
 check-qtest-i386-y += tests/pc-cpu-test$(EXESUF)
 check-qtest-i386-y += tests/q35-test$(EXESUF)
 gcov-files-i386-y += hw/pci-host/q35.c
-check-qtest-i386-$(CONFIG_VHOST_NET_TEST_i386) += tests/vhost-user-test$(EXESUF)
-ifeq ($(CONFIG_VHOST_NET_TEST_i386),)
-check-qtest-x86_64-$(CONFIG_VHOST_NET_TEST_x86_64) += tests/vhost-user-test$(EXESUF)
+check-qtest-i386-$(CONFIG_VHOST_USER_TEST_i386) += tests/vhost-user-test$(EXESUF)
+ifeq ($(CONFIG_VHOST_USER_TEST_i386),)
+check-qtest-x86_64-$(CONFIG_VHOST_USER_TEST_x86_64) += tests/vhost-user-test$(EXESUF)
 endif
 check-qtest-i386-y += tests/test-netfilter$(EXESUF)
 check-qtest-i386-y += tests/test-filter-mirror$(EXESUF)
-- 
1.8.3.1