From nobody Fri Nov 7 08:03:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547574166993442.06148752916897; Tue, 15 Jan 2019 09:42:46 -0800 (PST) Received: from localhost ([127.0.0.1]:59185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjSjd-0001if-VG for importer@patchew.org; Tue, 15 Jan 2019 12:42:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjSaq-0002kE-Fu for qemu-devel@nongnu.org; Tue, 15 Jan 2019 12:33:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gjSao-0007p8-Mc for qemu-devel@nongnu.org; Tue, 15 Jan 2019 12:33:40 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:53626) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gjSao-0007jE-DT for qemu-devel@nongnu.org; Tue, 15 Jan 2019 12:33:38 -0500 Received: by mail-wm1-x343.google.com with SMTP id d15so4159937wmb.3 for ; Tue, 15 Jan 2019 09:33:30 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id n9sm62982018wrx.80.2019.01.15.09.33.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 09:33:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=svxHMm89H++K7kq7zcKWU4xe69K6HIgJULl2pjVcnGI=; b=RMTaDSKJf0YS0nX8sAtRPGP1MgPEl8bkH0MU5tZy83Sq+ievUJT14GzpHsqTKWg8pg JlrH6JwRlxmgsXM/98+ueg3c+kac8QY+zaJ1ydCkJsJJMssC9Oh48oWdyx8aHWX5Kc+C eUjcJkQIN3YjnE6xXyc0hCaZFWJYNqR3a8nBC74/Ph/vkFgUo+Qq+VZWeFlBspAGGXMh KkA9Rog2HYRV5KnPBh1nOT9Wnb+6yG8l7MivrZZL2FjFJ8O62ayRzpPAlXv72xk67zRB ZemqoMqexKb2gNrfLgrC1XnqON+ji4lN/mWTqORp64VA35TrBp0z4ZDqNGtZKCRdOIpM vFUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=svxHMm89H++K7kq7zcKWU4xe69K6HIgJULl2pjVcnGI=; b=bNfy7+dBNrWpuFsllCOZGZ14U5JHY+uBl/OJOPAlVvfXO4t+HJteF2OYt+x0kJD+D1 TuoItCZfRuUFfhUpiRaMZ2WAF+xPYryPthQYvZ+VzwZHDd1XJLtSyjkxYrt7TJZ1z7IA AaOPVCrdJ/vHblvqdUsU5468k2LXIlSO5Y2x0cKJO8DTHaHCVPnLiZSrbtbDgVdq9ouG HGHQcqn5Uio+Hcbe32As6rD05UN7l9U96GpoKWXPWpAGM7dM77JsCwH3G4PL9478EmT/ ScQ+zg/jbGHlQ5bMukeUG5xRXgGt/EpSc6Q8b9Be8jiFd9evEyCqp9+IZiNjjDQh/9mK fSzg== X-Gm-Message-State: AJcUukfSJ9k3JPOl07lBgHFBDRPfi6i2K01iPmyuQ0Yt/vV70jitGTps 1SKsNikikOF73G4AurGVLYq09d8M X-Google-Smtp-Source: ALg8bN4FtrUwxpEriyx49c1e6/gRPjG+f2IXHO/pfPU5yQ5vOLUd7vtdvHvOz7xLes9wNLoBj5z5ng== X-Received: by 2002:a1c:5f8a:: with SMTP id t132mr4375364wmb.40.1547573609007; Tue, 15 Jan 2019 09:33:29 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 15 Jan 2019 18:33:21 +0100 Message-Id: <1547573605-25711-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1547573605-25711-1-git-send-email-pbonzini@redhat.com> References: <1547573605-25711-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PATCH 1/5] vhost-net: move stubs to a separate file X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: philmd@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) There is no reason for CONFIG_VHOST_NET to be specific to a single target; it is a host feature that can be add to all targets, as long as they support the virtio-net device. Currently CONFIG_VHOST_NET depends on CONFIG_KVM, but ioeventfd support is present in the core memory API and works with other accelerators as well. As a first step, move the vhost-net stubs to a separate file. Later, they will become conditional on CONFIG_VIRTIO_NET, which is not available in .c files. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Thomas Huth Signed-off-by: Paolo Bonzini Message-Id: <1543851204-41186-2-git-send-email-pbonzini@redhat.com> --- hw/net/Makefile.objs | 4 ++- hw/net/vhost_net-stub.c | 92 +++++++++++++++++++++++++++++++++++++++++++++= ++++ hw/net/vhost_net.c | 74 --------------------------------------- 3 files changed, 95 insertions(+), 75 deletions(-) create mode 100644 hw/net/vhost_net-stub.c diff --git a/hw/net/Makefile.objs b/hw/net/Makefile.objs index fa461d4..c2705e6 100644 --- a/hw/net/Makefile.objs +++ b/hw/net/Makefile.objs @@ -37,7 +37,9 @@ obj-$(CONFIG_PSERIES) +=3D spapr_llan.o obj-$(CONFIG_XILINX_ETHLITE) +=3D xilinx_ethlite.o =20 obj-$(CONFIG_VIRTIO_NET) +=3D virtio-net.o -obj-y +=3D vhost_net.o +obj-$(CONFIG_VHOST_NET) +=3D vhost_net.o +common-obj-$(call lnot,$(CONFIG_VHOST_NET)) +=3D vhost_net-stub.o +common-obj-$(CONFIG_ALL) +=3D vhost_net-stub.o =20 obj-$(CONFIG_ETSEC) +=3D fsl_etsec/etsec.o fsl_etsec/registers.o \ fsl_etsec/rings.o fsl_etsec/miim.o diff --git a/hw/net/vhost_net-stub.c b/hw/net/vhost_net-stub.c new file mode 100644 index 0000000..aac0e98 --- /dev/null +++ b/hw/net/vhost_net-stub.c @@ -0,0 +1,92 @@ +/* + * vhost-net support + * + * Copyright Red Hat, Inc. 2010 + * + * Authors: + * Michael S. Tsirkin + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "net/net.h" +#include "net/tap.h" +#include "net/vhost-user.h" + +#include "hw/virtio/virtio-net.h" +#include "net/vhost_net.h" +#include "qemu/error-report.h" + + +uint64_t vhost_net_get_max_queues(VHostNetState *net) +{ + return 1; +} + +struct vhost_net *vhost_net_init(VhostNetOptions *options) +{ + error_report("vhost-net support is not compiled in"); + return NULL; +} + +int vhost_net_start(VirtIODevice *dev, + NetClientState *ncs, + int total_queues) +{ + return -ENOSYS; +} +void vhost_net_stop(VirtIODevice *dev, + NetClientState *ncs, + int total_queues) +{ +} + +void vhost_net_cleanup(struct vhost_net *net) +{ +} + +uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features) +{ + return features; +} + +void vhost_net_ack_features(struct vhost_net *net, uint64_t features) +{ +} + +uint64_t vhost_net_get_acked_features(VHostNetState *net) +{ + return 0; +} + +bool vhost_net_virtqueue_pending(VHostNetState *net, int idx) +{ + return false; +} + +void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev, + int idx, bool mask) +{ +} + +int vhost_net_notify_migration_done(struct vhost_net *net, char* mac_addr) +{ + return -1; +} + +VHostNetState *get_vhost_net(NetClientState *nc) +{ + return 0; +} + +int vhost_set_vring_enable(NetClientState *nc, int enable) +{ + return 0; +} + +int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu) +{ + return 0; +} diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index e037db6..b901306 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -23,7 +23,6 @@ #include "qemu/error-report.h" =20 =20 -#ifdef CONFIG_VHOST_NET #include #include #include @@ -449,76 +448,3 @@ int vhost_net_set_mtu(struct vhost_net *net, uint16_t = mtu) =20 return vhost_ops->vhost_net_set_mtu(&net->dev, mtu); } - -#else -uint64_t vhost_net_get_max_queues(VHostNetState *net) -{ - return 1; -} - -struct vhost_net *vhost_net_init(VhostNetOptions *options) -{ - error_report("vhost-net support is not compiled in"); - return NULL; -} - -int vhost_net_start(VirtIODevice *dev, - NetClientState *ncs, - int total_queues) -{ - return -ENOSYS; -} -void vhost_net_stop(VirtIODevice *dev, - NetClientState *ncs, - int total_queues) -{ -} - -void vhost_net_cleanup(struct vhost_net *net) -{ -} - -uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features) -{ - return features; -} - -void vhost_net_ack_features(struct vhost_net *net, uint64_t features) -{ -} - -uint64_t vhost_net_get_acked_features(VHostNetState *net) -{ - return 0; -} - -bool vhost_net_virtqueue_pending(VHostNetState *net, int idx) -{ - return false; -} - -void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev, - int idx, bool mask) -{ -} - -int vhost_net_notify_migration_done(struct vhost_net *net, char* mac_addr) -{ - return -1; -} - -VHostNetState *get_vhost_net(NetClientState *nc) -{ - return 0; -} - -int vhost_set_vring_enable(NetClientState *nc, int enable) -{ - return 0; -} - -int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu) -{ - return 0; -} -#endif --=20 1.8.3.1 From nobody Fri Nov 7 08:03:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547573886768962.7133671024627; Tue, 15 Jan 2019 09:38:06 -0800 (PST) Received: from localhost ([127.0.0.1]:57858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjSf4-0005zO-Dm for importer@patchew.org; Tue, 15 Jan 2019 12:38:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjSaq-0002k8-1g for qemu-devel@nongnu.org; Tue, 15 Jan 2019 12:33:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gjSao-0007oO-D7 for qemu-devel@nongnu.org; Tue, 15 Jan 2019 12:33:40 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:38197) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gjSao-0007kN-5w for qemu-devel@nongnu.org; Tue, 15 Jan 2019 12:33:38 -0500 Received: by mail-wr1-x444.google.com with SMTP id v13so3931906wrw.5 for ; Tue, 15 Jan 2019 09:33:31 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id n9sm62982018wrx.80.2019.01.15.09.33.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 09:33:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mGBPwAxihd2yn5LmnK1u0gh/zJu4mYEJVqU1h3EjciA=; b=fvhB9p9o2XXoawoTFmjvEFkQ32zTyHFUOKLRb1pkJduWfm3274pMQiphHN7n70+YZQ iOHGijfqZJEgExtNZztfGlud4kQ90amG7bpKbGE/nU31gLvxxHiVeKZPxPTDk+ZWUKAm ptLDgS9aY6gDE9Hu98KUktazySVzBWeKjt5x8ZFhAUj/szKJ0qRv3h8NIeb3Iqg0sKs4 8/Jz7iViLewxdEIjfhC476VxjlJg2Ii1SCCvV9m6ZkAaQOs3MCQgL3rl5FPm9BHljbZ7 T3zUxNFM4xl6chAmdt4SrpV9X0V/UhAi69XrDvvhw0jYkWUEhjJzj4YdOd665bAdhj1h O6ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=mGBPwAxihd2yn5LmnK1u0gh/zJu4mYEJVqU1h3EjciA=; b=WTJluBmslriuK5/Zh/lZWYhnonxY8O6c7aexlkNSctXl6UuJ4N9BDcto163amhyCsc VUEF9c98W6a+E0uNC7Fly0vMzJrbyWVrOyZhXtMibh6qHI0X09EjHJz0CpSKbt3JWSBL +/VKBj0VrBBVPe1iyE5K3X4pot/o3pbzIbbFoxX/wcVmeW93/1AS03TNYZHys+pBhfDw UYHPzADbH4O2nURktnDmZ1ffgKNVuXpBTtEPj7/Z5TG8AqXZhquSXsLSONekaaLSEheI i7dgioWndwkeuu5EQwgYdm9zzb7IBCD/gU3mGqQBTu+Lgy4BX9ZdAQrtVzlMOP+H8fex 9hZw== X-Gm-Message-State: AJcUukc98t69//pvuDqRAwd/dX0DtB6oiWP0DfIO1x98J1edO/dXN2Ne NTfOQ8G5pdlbBjLetKWqBFQUqEjO X-Google-Smtp-Source: ALg8bN4iyiEeN2804qtG9oSKb6E/DN7fGxCyHQ7DlZoTQ9RkXEdF0Fbx29PZgMrqdk2hqnd5yztbaA== X-Received: by 2002:adf:b102:: with SMTP id l2mr3936780wra.296.1547573610082; Tue, 15 Jan 2019 09:33:30 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 15 Jan 2019 18:33:22 +0100 Message-Id: <1547573605-25711-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1547573605-25711-1-git-send-email-pbonzini@redhat.com> References: <1547573605-25711-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PATCH 2/5] vhost-net-user: add stubs for when no virtio-net device is present X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: philmd@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) hw/net/vhost_net.c needs functions that are declared in net/vhost-user.c: t= he 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=C3=A9 Message-Id: <1543851204-41186-3-git-send-email-pbonzini@redhat.com> Reviewed-by: Thomas Huth Signed-off-by: Paolo Bonzini --- 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 e0915da..e3e6dd3 100755 --- a/configure +++ b/configure @@ -6565,7 +6565,7 @@ if test "$vhost_scsi" =3D "yes" ; then echo "CONFIG_VHOST_SCSI=3Dy" >> $config_host_mak fi if test "$vhost_net" =3D "yes" -a "$vhost_user" =3D "yes"; then - echo "CONFIG_VHOST_NET_USED=3Dy" >> $config_host_mak + echo "CONFIG_VHOST_NET_USER=3Dy" >> $config_host_mak fi if test "$vhost_crypto" =3D "yes" ; then echo "CONFIG_VHOST_CRYPTO=3Dy" >> $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 *optio= ns) } =20 /* Set sane init value. Override when guest acks. */ +#ifdef CONFIG_VHOST_NET_USER if (net->nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_USER) { features =3D vhost_user_get_acked_features(net->nc); if (~net->dev.features & features) { @@ -202,6 +203,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *optio= ns) goto fail; } } +#endif =20 vhost_net_ack_features(net, features); =20 @@ -413,10 +415,12 @@ VHostNetState *get_vhost_net(NetClientState *nc) case NET_CLIENT_DRIVER_TAP: vhost_net =3D tap_get_vhost_net(nc); break; +#ifdef CONFIG_VHOST_NET_USER case NET_CLIENT_DRIVER_VHOST_USER: vhost_net =3D 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 +=3D socket.o common-obj-y +=3D dump.o common-obj-y +=3D eth.o common-obj-$(CONFIG_L2TPV3) +=3D l2tpv3.o -common-obj-$(CONFIG_POSIX) +=3D vhost-user.o +common-obj-$(call land,$(CONFIG_VIRTIO_NET),$(CONFIG_VHOST_NET_USER)) +=3D= vhost-user.o +common-obj-$(call land,$(call lnot,$(CONFIG_VIRTIO_NET)),$(CONFIG_VHOST_NE= T_USER)) +=3D vhost-user-stub.o +common-obj-$(CONFIG_ALL) +=3D vhost-user-stub.o common-obj-$(CONFIG_SLIRP) +=3D slirp.o common-obj-$(CONFIG_VDE) +=3D vde.o common-obj-$(CONFIG_NETMAP) +=3D 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_DRIV= ER__MAX])( [NET_CLIENT_DRIVER_BRIDGE] =3D net_init_bridge, #endif [NET_CLIENT_DRIVER_HUBPORT] =3D net_init_hubport, -#ifdef CONFIG_VHOST_NET_USED +#ifdef CONFIG_VHOST_NET_USER [NET_CLIENT_DRIVER_VHOST_USER] =3D 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 late= r. + * 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; +} --=20 1.8.3.1 From nobody Fri Nov 7 08:03:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547573754815888.5885814531739; Tue, 15 Jan 2019 09:35:54 -0800 (PST) Received: from localhost ([127.0.0.1]:57326 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjScz-0004CB-Ml for importer@patchew.org; Tue, 15 Jan 2019 12:35:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56120) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjSaq-0002kC-Ag for qemu-devel@nongnu.org; Tue, 15 Jan 2019 12:33:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gjSao-0007oY-Fd for qemu-devel@nongnu.org; Tue, 15 Jan 2019 12:33:40 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:34834) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gjSao-0007l1-78 for qemu-devel@nongnu.org; Tue, 15 Jan 2019 12:33:38 -0500 Received: by mail-wr1-x444.google.com with SMTP id 96so3948289wrb.2 for ; Tue, 15 Jan 2019 09:33:32 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id n9sm62982018wrx.80.2019.01.15.09.33.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 09:33:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/eWr4k9J6YIScFX2CNKzOt7DFaAd1BW9ZdrQ4vBatOQ=; b=fG/X9j+VmC7GxWn86zeuJou9cfRNhWI8y9vw/fp461+XL0xz/vOQ7LoCYR4lJfJ+0y OXqYlvP2jptQTWHAfJCM2Nd708l8Nkj7vGPakLzjs+g0KG14s9EWRX3wx2XQseCKfHVl zRTpkJnQ8/WfDrvxAv6o6BEdVoCZ11/uEbVTlQ0lbZwz4jj/Qn38MF+sXtxmpGXCJS7J 2BSDoGNycZSYIWmZMLj/Dgsw5Nq0k3GtTjWr971cwC4qqZ91WhPP/qg3o/OTNDckBESf iUjWac1N0AZKuMXTrYH3kZ2SP8F2Mf9ZXEuOrDYXucYCyj4Ks+2luSNk96dwHdPwKMDd N7VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=/eWr4k9J6YIScFX2CNKzOt7DFaAd1BW9ZdrQ4vBatOQ=; b=qSKfdVDsz+vXFfIW9ohglvPNpf9ny1S00I991W6W//QoWLNwzQOiDJ+Df//JSHxuWU 7X8AlOB3J7QuhDkObtKmQaZpMClHZYxs1ToDrFnWrw1ZL70KMYq1AMRRT9WNII6rG3zC uMYQoqbr3H51MeiEZkg0wUzlZGw1LI9YiJBWbIyM48ewVhqJTzzTNciVMHtdBqzlKgqQ wlzscaMNFrWNnjjP0PdyB+AzENsX4ZppspQUBGpOG3DZ2wgjw0X7hUbZ4AsdWF0Lr9DU WB0uI7fYjiwHQpMkPOYGkA5A2xLPm2o2Ghd519T3sFTlnYcipFk8pRl0gxSRc5utRd+1 dlzw== X-Gm-Message-State: AJcUukeLo6eDKAc0KgpgiJMVsmQR54zVL0ieKu6Teb+9YhXpB9QG8Mw7 mnb1OLkvgpexk+cvmP6QK49dgS/A X-Google-Smtp-Source: ALg8bN4rCPqCw4e4JYqH+9sy2KmM+yZ2TDBR/iQhhYjhhQU7mqUfEj7LF8h0492j2Ub6zKa1NXIG8g== X-Received: by 2002:a5d:6b81:: with SMTP id n1mr4334040wrx.149.1547573611205; Tue, 15 Jan 2019 09:33:31 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 15 Jan 2019 18:33:23 +0100 Message-Id: <1547573605-25711-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1547573605-25711-1-git-send-email-pbonzini@redhat.com> References: <1547573605-25711-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PATCH 3/5] vhost: restrict Linux dependency to kernel vhost X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: philmd@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) vhost-user does not depend on Linux; it can run on any POSIX system. Restr= ict vhost-kernel to Linux in hw/virtio/vhost-backend.c, everything else can be compiled on all POSIX systems. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Thomas Huth Message-Id: <1543851204-41186-4-git-send-email-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini --- backends/Makefile.objs | 5 ++--- default-configs/virtio.mak | 4 ++-- hw/net/vhost_net.c | 3 +-- hw/virtio/Makefile.objs | 5 +++-- hw/virtio/vhost-backend.c | 12 ++++++++++-- hw/virtio/vhost-user.c | 13 ++++++++++++- hw/virtio/vhost.c | 2 +- 7 files changed, 31 insertions(+), 13 deletions(-) diff --git a/backends/Makefile.objs b/backends/Makefile.objs index 717fcbd..ff619d3 100644 --- a/backends/Makefile.objs +++ b/backends/Makefile.objs @@ -9,10 +9,9 @@ common-obj-$(CONFIG_POSIX) +=3D hostmem-file.o common-obj-y +=3D cryptodev.o common-obj-y +=3D cryptodev-builtin.o =20 -ifeq ($(CONFIG_VIRTIO),y) +ifeq ($(CONFIG_VIRTIO_CRYPTO),y) common-obj-y +=3D cryptodev-vhost.o -common-obj-$(call land,$(CONFIG_VHOST_USER),$(CONFIG_LINUX)) +=3D \ - cryptodev-vhost-user.o +common-obj-$(CONFIG_VHOST_CRYPTO) +=3D cryptodev-vhost-user.o endif =20 common-obj-$(CONFIG_LINUX) +=3D hostmem-memfd.o diff --git a/default-configs/virtio.mak b/default-configs/virtio.mak index 1304849..340050a 100644 --- a/default-configs/virtio.mak +++ b/default-configs/virtio.mak @@ -1,5 +1,5 @@ -CONFIG_VHOST_USER_SCSI=3D$(call land,$(CONFIG_VHOST_USER),$(CONFIG_LINUX)) -CONFIG_VHOST_USER_BLK=3D$(call land,$(CONFIG_VHOST_USER),$(CONFIG_LINUX)) +CONFIG_VHOST_USER_SCSI=3D$(CONFIG_VHOST_USER) +CONFIG_VHOST_USER_BLK=3D$(CONFIG_VHOST_USER) CONFIG_VIRTIO=3Dy CONFIG_VIRTIO_9P=3Dy CONFIG_VIRTIO_BALLOON=3Dy diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 2a300ee..ae3ca23 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -18,14 +18,13 @@ #include "net/tap.h" #include "net/vhost-user.h" =20 +#include "standard-headers/linux/vhost_types.h" #include "hw/virtio/virtio-net.h" #include "net/vhost_net.h" #include "qemu/error-report.h" =20 =20 -#include #include -#include #include #include #include diff --git a/hw/virtio/Makefile.objs b/hw/virtio/Makefile.objs index 1b2799c..e8eff80 100644 --- a/hw/virtio/Makefile.objs +++ b/hw/virtio/Makefile.objs @@ -9,9 +9,10 @@ obj-$(CONFIG_VIRTIO_BALLOON) +=3D virtio-balloon.o obj-$(CONFIG_VIRTIO_CRYPTO) +=3D virtio-crypto.o obj-$(call land,$(CONFIG_VIRTIO_CRYPTO),$(CONFIG_VIRTIO_PCI)) +=3D virtio-= crypto-pci.o =20 -obj-$(CONFIG_LINUX) +=3D vhost.o vhost-backend.o vhost-user.o +obj-$(CONFIG_VHOST_USER) +=3D vhost-user.o obj-$(CONFIG_VHOST_VSOCK) +=3D vhost-vsock.o +obj-$(call lor,$(CONFIG_VHOST_USER),$(CONFIG_LINUX)) +=3D vhost.o vhost-ba= ckend.o +common-obj-$(call lnot,$(call lor,$(CONFIG_VHOST_USER),$(CONFIG_LINUX))) += =3D vhost-stub.o endif =20 -common-obj-$(call lnot,$(call land,$(CONFIG_VIRTIO),$(CONFIG_LINUX))) +=3D= vhost-stub.o common-obj-$(CONFIG_ALL) +=3D vhost-stub.o diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index 7f09efa..e0f0bb7 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -9,11 +9,14 @@ */ =20 #include "qemu/osdep.h" -#include -#include #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-backend.h" #include "qemu/error-report.h" +#include "standard-headers/linux/vhost_types.h" + +#ifdef CONFIG_LINUX +#include +#include =20 static int vhost_kernel_call(struct vhost_dev *dev, unsigned long int requ= est, void *arg) @@ -265,18 +268,23 @@ static const VhostOps kernel_ops =3D { .vhost_set_iotlb_callback =3D vhost_kernel_set_iotlb_callback, .vhost_send_device_iotlb_msg =3D vhost_kernel_send_device_iotlb_ms= g, }; +#endif =20 int vhost_set_backend_type(struct vhost_dev *dev, VhostBackendType backend= _type) { int r =3D 0; =20 switch (backend_type) { +#ifdef CONFIG_LINUX case VHOST_BACKEND_TYPE_KERNEL: dev->vhost_ops =3D &kernel_ops; break; +#endif +#ifdef CONFIG_VHOST_USER case VHOST_BACKEND_TYPE_USER: dev->vhost_ops =3D &user_ops; break; +#endif default: error_report("Unknown vhost backend type"); r =3D -1; diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index e09bed0..836bca5 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -27,8 +27,12 @@ #include #include #include -#include + +#include "standard-headers/linux/vhost_types.h" + +#ifdef CONFIG_LINUX #include +#endif =20 #define VHOST_MEMORY_MAX_NREGIONS 8 #define VHOST_USER_F_PROTOCOL_FEATURES 30 @@ -1110,6 +1114,7 @@ out: return ret; } =20 +#ifdef CONFIG_LINUX /* * Called back from the postcopy fault thread when a fault is received on = our * ufd. @@ -1177,6 +1182,7 @@ static int vhost_user_postcopy_waker(struct PostCopyF= D *pcfd, RAMBlock *rb, trace_vhost_user_postcopy_waker_nomatch(qemu_ram_get_idstr(rb), offset= ); return 0; } +#endif =20 /* * Called at the start of an inbound postcopy on reception of the @@ -1184,6 +1190,7 @@ static int vhost_user_postcopy_waker(struct PostCopyF= D *pcfd, RAMBlock *rb, */ static int vhost_user_postcopy_advise(struct vhost_dev *dev, Error **errp) { +#ifdef CONFIG_LINUX struct vhost_user *u =3D dev->opaque; CharBackend *chr =3D u->user->chr; int ufd; @@ -1227,6 +1234,10 @@ static int vhost_user_postcopy_advise(struct vhost_d= ev *dev, Error **errp) u->postcopy_fd.idstr =3D "vhost-user"; /* Need to find unique name */ postcopy_register_shared_ufd(&u->postcopy_fd); return 0; +#else + error_setg(errp, "Postcopy not supported on non-Linux systems"); + return -1; +#endif } =20 /* diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 569c405..311432f 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -21,7 +21,7 @@ #include "qemu/range.h" #include "qemu/error-report.h" #include "qemu/memfd.h" -#include +#include "standard-headers/linux/vhost_types.h" #include "exec/address-spaces.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" --=20 1.8.3.1 From nobody Fri Nov 7 08:03:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547574233055474.21105410623124; Tue, 15 Jan 2019 09:43:53 -0800 (PST) Received: from localhost ([127.0.0.1]:59416 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjSkV-0002Rq-Jk for importer@patchew.org; Tue, 15 Jan 2019 12:43:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjSaq-0002kB-AE for qemu-devel@nongnu.org; Tue, 15 Jan 2019 12:33:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gjSao-0007ok-Ji for qemu-devel@nongnu.org; Tue, 15 Jan 2019 12:33:40 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:37032) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gjSao-0007lo-7Z for qemu-devel@nongnu.org; Tue, 15 Jan 2019 12:33:38 -0500 Received: by mail-wm1-x343.google.com with SMTP id g67so4095260wmd.2 for ; Tue, 15 Jan 2019 09:33:33 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id n9sm62982018wrx.80.2019.01.15.09.33.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 09:33:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7LDLa/mtvFnzfeJI+mZCUdsQGVkJ4fSWNcOM9q8gNT4=; b=Sc+cIAZcyB3VxIdYYj0M76SqZkGf03reXWK982DASBeV0O5k2jv8z6ZEKahc4T/Kge eejx0Nmx5hcVltFPRgTUsfiH2NAp8iLUQ45l/1T8dyOeH22dswdWPCcix/olp+I0TDyz /LbcNVrdjMqSGoEZElZt0WHQgsJJT3bFxKqJJuxMWbZRXLpeIQoeV0tZoQ89B+ahj+OG Wzf0F96UN/NNCzMq4RyDRti8W55ygdacCCxyF09rCpRLNr21gP7TxosNOVflrmnlNJIv Cyybiru/aHTZFxbJCwMU0aWgOMdSsxL7QVqb0ir3PHm73AhGAVHS+7BRFyRZuuZWMyvk T1Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=7LDLa/mtvFnzfeJI+mZCUdsQGVkJ4fSWNcOM9q8gNT4=; b=UzccfyI2VWANxGeDs4RnuFfLBz7wHKcIB+inWjeedwSh3E8A80WpN41705H+pTjMmb 0xjzBF8NYh+P3cyv5cONRVSCA8hEGuzj7tt1GjXvyGF+TZ6qxtB82+bCmcqRvFj2KrRI NVBFYwFWpDC70gaSA19VmNpqEAkjMXUfXCu06eVqPClnEntbtAAxPjNWAfAWQgTN+A73 Cp0IHzsv19NnCaf/uP1+DI32AKIUNaAtjg9MULVqfFlP1WiJcbaiP+peg9k/bCRBVuaK xQ7rbDoX7hunYkR9qzbmaiw24WfZ0Ky6uaABHfqWsc6C4VMEI63G3dd6gvr7kq/Bn90V o9TQ== X-Gm-Message-State: AJcUukctVVPuwskPXxFv6kGVMH4UG/r5nDDClsdha8QZypksnIR02O4J lVs/WnM/Ji8YoVN5wmkkPI8v2+Uk X-Google-Smtp-Source: ALg8bN4D7eNa12fv9dy8Im3lNSOeqQp/twDCsLWgFjq4cZX0SmmbcZGg+FZ8f3k5WK9+6Z/EHEo8ww== X-Received: by 2002:a1c:22c5:: with SMTP id i188mr4209691wmi.39.1547573612139; Tue, 15 Jan 2019 09:33:32 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 15 Jan 2019 18:33:24 +0100 Message-Id: <1547573605-25711-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1547573605-25711-1-git-send-email-pbonzini@redhat.com> References: <1547573605-25711-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PATCH 4/5] vhost-net: compile it on all targets that have virtio-net. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: philmd@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This shows a preexisting bug: if a KVM target did not have virtio-net enabl= ed, it would fail with undefined symbols when vhost was enabled. This must now be fixed, lest targets that have no virtio-net fail to compile. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini Reviewed-by: Thomas Huth Message-Id: <1543851204-41186-5-git-send-email-pbonzini@redhat.com> --- configure | 11 ++++------- hw/net/Makefile.objs | 4 ++-- hw/net/vhost_net.c | 4 +--- include/exec/poison.h | 1 - tests/Makefile.include | 5 +---- tests/vhost-user-test.c | 16 +++++++++++----- 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/configure b/configure index e3e6dd3..87f2d15 100755 --- a/configure +++ b/configure @@ -6564,7 +6564,10 @@ fi if test "$vhost_scsi" =3D "yes" ; then echo "CONFIG_VHOST_SCSI=3Dy" >> $config_host_mak fi -if test "$vhost_net" =3D "yes" -a "$vhost_user" =3D "yes"; then +if test "$vhost_net" =3D "yes" ; then + echo "CONFIG_VHOST_NET=3Dy" >> $config_host_mak +fi +if test "$vhost_net_user" =3D "yes" ; then echo "CONFIG_VHOST_NET_USER=3Dy" >> $config_host_mak fi if test "$vhost_crypto" =3D "yes" ; then @@ -7336,12 +7339,6 @@ if supported_xen_target $target; then fi if supported_kvm_target $target; then echo "CONFIG_KVM=3Dy" >> $config_target_mak - if test "$vhost_net" =3D "yes" ; then - echo "CONFIG_VHOST_NET=3Dy" >> $config_target_mak - if test "$vhost_user" =3D "yes" ; then - echo "CONFIG_VHOST_USER_NET_TEST_$target_name=3Dy" >> $config_= host_mak - fi - fi fi if supported_hax_target $target; then echo "CONFIG_HAX=3Dy" >> $config_target_mak diff --git a/hw/net/Makefile.objs b/hw/net/Makefile.objs index c2705e6..2d7ee0a 100644 --- a/hw/net/Makefile.objs +++ b/hw/net/Makefile.objs @@ -37,8 +37,8 @@ obj-$(CONFIG_PSERIES) +=3D spapr_llan.o obj-$(CONFIG_XILINX_ETHLITE) +=3D xilinx_ethlite.o =20 obj-$(CONFIG_VIRTIO_NET) +=3D virtio-net.o -obj-$(CONFIG_VHOST_NET) +=3D vhost_net.o -common-obj-$(call lnot,$(CONFIG_VHOST_NET)) +=3D vhost_net-stub.o +common-obj-$(call land,$(CONFIG_VIRTIO_NET),$(CONFIG_VHOST_NET)) +=3D vhos= t_net.o +common-obj-$(call lnot,$(call land,$(CONFIG_VIRTIO_NET),$(CONFIG_VHOST_NET= ))) +=3D vhost_net-stub.o common-obj-$(CONFIG_ALL) +=3D vhost_net-stub.o =20 obj-$(CONFIG_ETSEC) +=3D fsl_etsec/etsec.o fsl_etsec/registers.o \ diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index ae3ca23..be3cc88 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -25,8 +25,6 @@ =20 =20 #include -#include -#include #include #include =20 @@ -134,7 +132,7 @@ static int vhost_net_get_fd(NetClientState *backend) return tap_get_fd(backend); default: fprintf(stderr, "vhost-net requires tap backend\n"); - return -EBADFD; + return -ENOSYS; } } =20 diff --git a/include/exec/poison.h b/include/exec/poison.h index ecdc83c..1a7a57b 100644 --- a/include/exec/poison.h +++ b/include/exec/poison.h @@ -86,7 +86,6 @@ #pragma GCC poison CONFIG_XTENSA_DIS =20 #pragma GCC poison CONFIG_LINUX_USER -#pragma GCC poison CONFIG_VHOST_NET #pragma GCC poison CONFIG_KVM #pragma GCC poison CONFIG_SOFTMMU =20 diff --git a/tests/Makefile.include b/tests/Makefile.include index c17f6d5..195af1f 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -204,10 +204,7 @@ check-qtest-i386-$(CONFIG_USB_XHCI_NEC) +=3D tests/usb= -hcd-xhci-test$(EXESUF) check-qtest-i386-y +=3D tests/cpu-plug-test$(EXESUF) check-qtest-i386-y +=3D tests/q35-test$(EXESUF) check-qtest-i386-y +=3D tests/vmgenid-test$(EXESUF) -check-qtest-i386-$(CONFIG_VHOST_USER_NET_TEST_i386) +=3D tests/vhost-user-= test$(EXESUF) -ifeq ($(CONFIG_VHOST_USER_NET_TEST_i386),) -check-qtest-x86_64-$(CONFIG_VHOST_USER_NET_TEST_x86_64) +=3D tests/vhost-u= ser-test$(EXESUF) -endif +check-qtest-i386-$(CONFIG_VHOST_NET_USER) +=3D tests/vhost-user-test$(EXES= UF) check-qtest-i386-$(CONFIG_TPM_CRB) +=3D tests/tpm-crb-swtpm-test$(EXESUF) check-qtest-i386-$(CONFIG_TPM_CRB) +=3D tests/tpm-crb-test$(EXESUF) check-qtest-i386-$(CONFIG_TPM_TIS) +=3D tests/tpm-tis-swtpm-test$(EXESUF) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 54982f6..ab87865 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -27,10 +27,13 @@ #include "libqos/malloc-pc.h" #include "hw/virtio/virtio-net.h" =20 -#include -#include -#include +#include "standard-headers/linux/vhost_types.h" +#include "standard-headers/linux/virtio_ids.h" +#include "standard-headers/linux/virtio_net.h" + +#ifdef CONFIG_LINUX #include +#endif =20 =20 #define QEMU_CMD_MEM " -m %d -object memory-backend-file,id=3Dmem,size= =3D%dM," \ @@ -442,6 +445,7 @@ static void chr_read(void *opaque, const uint8_t *buf, = int size) g_mutex_unlock(&s->data_mutex); } =20 +#ifdef CONFIG_LINUX static const char *init_hugepagefs(const char *path) { struct statfs fs; @@ -468,6 +472,7 @@ static const char *init_hugepagefs(const char *path) =20 return path; } +#endif =20 static TestServer *test_server_new(const gchar *name) { @@ -951,13 +956,14 @@ int main(int argc, char **argv) } g_assert(tmpfs); =20 + root =3D tmpfs; +#ifdef CONFIG_LINUX hugefs =3D getenv("QTEST_HUGETLBFS_PATH"); if (hugefs) { root =3D init_hugepagefs(hugefs); g_assert(root); - } else { - root =3D tmpfs; } +#endif =20 loop =3D g_main_loop_new(NULL, FALSE); /* run the main loop thread so the chardev may operate */ --=20 1.8.3.1 From nobody Fri Nov 7 08:03:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547573938965593.2933732153592; Tue, 15 Jan 2019 09:38:58 -0800 (PST) Received: from localhost ([127.0.0.1]:58088 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjSfx-0006ja-SC for importer@patchew.org; Tue, 15 Jan 2019 12:38:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjSaq-0002kD-Ej for qemu-devel@nongnu.org; Tue, 15 Jan 2019 12:33:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gjSao-0007op-Ki for qemu-devel@nongnu.org; Tue, 15 Jan 2019 12:33:40 -0500 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:40950) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gjSao-0007mL-8s for qemu-devel@nongnu.org; Tue, 15 Jan 2019 12:33:38 -0500 Received: by mail-wr1-x443.google.com with SMTP id p4so3915886wrt.7 for ; Tue, 15 Jan 2019 09:33:34 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id n9sm62982018wrx.80.2019.01.15.09.33.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 09:33:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j7ie273QGmpHfjZ3LzNxQXj0HFKAlk5GovzY0WuD1ls=; b=k+CUidEZfCqvSh9LP2Abo1U4bqDncu+40suRCm2y7g3o1fFv9cr+FLQjTcBQGDOQEP FtYiYvTdby+rTVqrSlX2qH1QL38qWDiV7CazXtyMPZ8jYKR8xSZQyzjimw/IPVydojfR ZwnPrlTTCJmVMZ7E5zsbPibU3HjmARBlupJbp4K/MzIqw3FjNF3lGOI+H08VuUUQBip6 qgoEjUwbRLDjxpJv38/uhASe40Hmhx+tH09tIDx5Z1jxSJtdCFYh3HIZJqGXgEfjUHOv jsReeFuqMaw8TfUdG/H3DhCuBQVSlj8o2+9pSzli85hwG0ibbl0ynA6CxCHtOrmPzs03 vGcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=j7ie273QGmpHfjZ3LzNxQXj0HFKAlk5GovzY0WuD1ls=; b=lxWOElcjCHg6jBMQ7uFu/Hnp09TXdSrG6o3N4bGv+60pUyo1nScSXIe05yH5coRvlL HoOJSSysJsPKFi8uD9R4Or8ne1TFwiAbmQSjQDTYRBI/A+DRaGgeJVirNh6Spe8ty8Yg Y5Lu/HUeEma/alEV/8LOaJGO/Vobyh/B08zjQ4wg+5vbbaqITZwkn3yC4U8ri2QaqeCw ds3KCtPxXoLoux0sAg6Xkj5vB6/zDesVRGramgg8oPIKltGkbXMWwXcu1WGqt0d3LwYz QZ3Su2lKfuY8+lEijLofLiOVaUMJlKLJXlZqkuS8XSoyu6sA/ijAoR2fzAXSpSmOPu4j KO1A== X-Gm-Message-State: AJcUukcRnrMzJlMIaom+9cng5tMoyC4dsTv/YUxePC8ky+FRgWYoq2uc P+kwv5AtMZzLy2IRSavjI4B1uWBt X-Google-Smtp-Source: ALg8bN5ROPC2l/wY5Wbp3IoGbbiehjJVU4MvvtRK4MsKGCb0M9bv5PBanE/bx3B8FDBRP2WfaOyy5w== X-Received: by 2002:adf:db51:: with SMTP id f17mr3911135wrj.90.1547573613365; Tue, 15 Jan 2019 09:33:33 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 15 Jan 2019 18:33:25 +0100 Message-Id: <1547573605-25711-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1547573605-25711-1-git-send-email-pbonzini@redhat.com> References: <1547573605-25711-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PATCH 5/5] vhost-net: revamp configure logic X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: philmd@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Detect all invalid configurations (e.g. mingw32 with vhost-user, non-Linux with vhost-kernel). As a collateral benefit, all vhost-kernel backends can be now disabled if one wants to reduce the attack surface. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini Reviewed-by: Thomas Huth Message-Id: <1543851204-41186-6-git-send-email-pbonzini@redhat.com> --- configure | 89 +++++++++++++++++++++++++++++++------------= ---- hw/virtio/Makefile.objs | 4 +-- hw/virtio/vhost-backend.c | 4 +-- 3 files changed, 63 insertions(+), 34 deletions(-) diff --git a/configure b/configure index 87f2d15..3126e20 100755 --- a/configure +++ b/configure @@ -366,10 +366,10 @@ libattr=3D"" xfs=3D"" tcg=3D"yes" membarrier=3D"" -vhost_net=3D"no" -vhost_crypto=3D"no" -vhost_scsi=3D"no" -vhost_vsock=3D"no" +vhost_net=3D"" +vhost_crypto=3D"" +vhost_scsi=3D"" +vhost_vsock=3D"" vhost_user=3D"" kvm=3D"no" hax=3D"no" @@ -781,6 +781,7 @@ case $targetos in MINGW32*) mingw32=3D"yes" hax=3D"yes" + vhost_user=3D"no" audio_possible_drivers=3D"dsound sdl" if check_include dsound.h; then audio_drv_list=3D"dsound" @@ -881,10 +882,6 @@ Linux) linux=3D"yes" linux_user=3D"yes" kvm=3D"yes" - vhost_net=3D"yes" - vhost_crypto=3D"yes" - vhost_scsi=3D"yes" - vhost_vsock=3D"yes" QEMU_INCLUDES=3D"-I\$(SRC_PATH)/linux-headers -I$PWD/linux-headers $QEMU= _INCLUDES" supported_os=3D"yes" libudev=3D"yes" @@ -1262,11 +1259,7 @@ for opt do ;; --disable-vhost-crypto) vhost_crypto=3D"no" ;; - --enable-vhost-crypto) - vhost_crypto=3D"yes" - if test "$mingw32" =3D "yes"; then - error_exit "vhost-crypto isn't available on win32" - fi + --enable-vhost-crypto) vhost_crypto=3D"yes" ;; --disable-vhost-scsi) vhost_scsi=3D"no" ;; @@ -1471,11 +1464,11 @@ for opt do ;; --disable-vhost-user) vhost_user=3D"no" ;; - --enable-vhost-user) - vhost_user=3D"yes" - if test "$mingw32" =3D "yes"; then - error_exit "vhost-user isn't available on win32" - fi + --enable-vhost-user) vhost_user=3D"yes" + ;; + --disable-vhost-kernel) vhost_kernel=3D"no" + ;; + --enable-vhost-kernel) vhost_kernel=3D"yes" ;; --disable-capstone) capstone=3D"no" ;; @@ -1507,14 +1500,6 @@ for opt do esac done =20 -if test "$vhost_user" =3D ""; then - if test "$mingw32" =3D "yes"; then - vhost_user=3D"no" - else - vhost_user=3D"yes" - fi -fi - case "$cpu" in ppc) CPU_CFLAGS=3D"-m32" @@ -1739,8 +1724,12 @@ disabled with --disable-FEATURE, default is enabled = if available: linux-aio Linux AIO support cap-ng libcap-ng support attr attr and xattr support - vhost-net vhost-net acceleration support - vhost-crypto vhost-crypto acceleration support + vhost-net vhost-net kernel acceleration support + vhost-vsock virtio sockets device support + vhost-scsi vhost-scsi kernel target support + vhost-crypto vhost-user-crypto backend support + vhost-kernel vhost kernel backend support + vhost-user vhost-user backend support spice spice rbd rados block device (rbd) libiscsi iscsi support @@ -1766,7 +1755,6 @@ disabled with --disable-FEATURE, default is enabled i= f available: jemalloc jemalloc support avx2 AVX2 optimization support replication replication support - vhost-vsock virtio sockets device support opengl opengl support virglrenderer virgl rendering support xfsctl xfsctl support @@ -1783,7 +1771,6 @@ disabled with --disable-FEATURE, default is enabled i= f available: parallels parallels image format support sheepdog sheepdog block driver support crypto-afalg Linux AF_ALG crypto backend driver - vhost-user vhost-user support capstone capstone disassembler support debug-mutex mutex debugging support libpmem libpmem support @@ -2171,6 +2158,45 @@ else l2tpv3=3Dno fi =20 +######################################### +# vhost interdependencies and host support + +# vhost backends +test "$vhost_user" =3D "" && vhost_user=3Dyes +if test "$vhost_user" =3D "yes" && test "$mingw32" =3D "yes"; then + error_exit "vhost-user isn't available on win32" +fi +test "$vhost_kernel" =3D "" && vhost_kernel=3D$linux +if test "$vhost_kernel" =3D "yes" && test "$linux" !=3D "yes"; then + error_exit "vhost-kernel is only available on Linux" +fi + +# vhost-kernel devices +test "$vhost_scsi" =3D "" && vhost_scsi=3D$vhost_kernel +if test "$vhost_scsi" =3D "yes" && test "$vhost_kernel" !=3D "yes"; then + error_exit "--enable-vhost-scsi requires --enable-vhost-kernel" +fi +test "$vhost_vsock" =3D "" && vhost_vsock=3D$vhost_kernel +if test "$vhost_vsock" =3D "yes" && test "$vhost_kernel" !=3D "yes"; then + error_exit "--enable-vhost-vsock requires --enable-vhost-kernel" +fi + +# vhost-user backends +test "$vhost_net_user" =3D "" && vhost_net_user=3D$vhost_user +if test "$vhost_net_user" =3D "yes" && test "$vhost_user" =3D "no"; then + error_exit "--enable-vhost-net-user requires --enable-vhost-user" +fi +test "$vhost_crypto" =3D "" && vhost_crypto=3D$vhost_user +if test "$vhost_crypto" =3D "yes" && test "$vhost_user" =3D "no"; then + error_exit "--enable-vhost-crypto requires --enable-vhost-user" +fi + +# OR the vhost-kernel and vhost-user values for simplicity +if test "$vhost_net" =3D ""; then + test "$vhost_net_user" =3D "yes" && vhost_net=3Dyes + test "$vhost_kernel" =3D "yes" && vhost_net=3Dyes +fi + ########################################## # MinGW / Mingw-w64 localtime_r/gmtime_r check =20 @@ -6576,6 +6602,9 @@ fi if test "$vhost_vsock" =3D "yes" ; then echo "CONFIG_VHOST_VSOCK=3Dy" >> $config_host_mak fi +if test "$vhost_kernel" =3D "yes" ; then + echo "CONFIG_VHOST_KERNEL=3Dy" >> $config_host_mak +fi if test "$vhost_user" =3D "yes" ; then echo "CONFIG_VHOST_USER=3Dy" >> $config_host_mak fi diff --git a/hw/virtio/Makefile.objs b/hw/virtio/Makefile.objs index e8eff80..87402d1 100644 --- a/hw/virtio/Makefile.objs +++ b/hw/virtio/Makefile.objs @@ -11,8 +11,8 @@ obj-$(call land,$(CONFIG_VIRTIO_CRYPTO),$(CONFIG_VIRTIO_P= CI)) +=3D virtio-crypto-p =20 obj-$(CONFIG_VHOST_USER) +=3D vhost-user.o obj-$(CONFIG_VHOST_VSOCK) +=3D vhost-vsock.o -obj-$(call lor,$(CONFIG_VHOST_USER),$(CONFIG_LINUX)) +=3D vhost.o vhost-ba= ckend.o -common-obj-$(call lnot,$(call lor,$(CONFIG_VHOST_USER),$(CONFIG_LINUX))) += =3D vhost-stub.o +obj-$(call lor,$(CONFIG_VHOST_USER),$(CONFIG_VHOST_KERNEL)) +=3D vhost.o v= host-backend.o +common-obj-$(call lnot,$(call lor,$(CONFIG_VHOST_USER),$(CONFIG_VHOST_KERN= EL))) +=3D vhost-stub.o endif =20 common-obj-$(CONFIG_ALL) +=3D vhost-stub.o diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index e0f0bb7..96b8d3c 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -14,7 +14,7 @@ #include "qemu/error-report.h" #include "standard-headers/linux/vhost_types.h" =20 -#ifdef CONFIG_LINUX +#ifdef CONFIG_VHOST_KERNEL #include #include =20 @@ -275,7 +275,7 @@ int vhost_set_backend_type(struct vhost_dev *dev, Vhost= BackendType backend_type) int r =3D 0; =20 switch (backend_type) { -#ifdef CONFIG_LINUX +#ifdef CONFIG_VHOST_KERNEL case VHOST_BACKEND_TYPE_KERNEL: dev->vhost_ops =3D &kernel_ops; break; --=20 1.8.3.1