From nobody Sun May 5 18:34:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543238774368872.309841998843; Mon, 26 Nov 2018 05:26:14 -0800 (PST) Received: from localhost ([::1]:35934 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRGto-00019y-0Y for importer@patchew.org; Mon, 26 Nov 2018 08:26:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRGom-00051i-S8 for qemu-devel@nongnu.org; Mon, 26 Nov 2018 08:20:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRGoi-0007qt-7i for qemu-devel@nongnu.org; Mon, 26 Nov 2018 08:20:52 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:35531) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRGoi-0007os-1B for qemu-devel@nongnu.org; Mon, 26 Nov 2018 08:20:48 -0500 Received: by mail-wm1-x341.google.com with SMTP id c126so18362517wmh.0 for ; Mon, 26 Nov 2018 05:20:47 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i16sm951672wmd.28.2018.11.26.05.20.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Nov 2018 05:20:46 -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; bh=to5wQOuVoDFPRFzqVg8bHDRI7dOPuy4M29WMpXFCtbk=; b=PbRspZmjDU69P3RT2VirNvhTEjxwWyY8Gr3secpsdmBmuCfN3n7uOJPvHiHI5O2uLD 5F3wMaNnh5z0RRuJmHT3g6cB9mLa3S2zq+Ds5fhXcMR/lIxAuKJ7/Wa3PTKrba6zNQAR 67XQwTAhSTjZ8mn4YW1ikfljTGQd5eHx5I/23+iIiAjWiHXGRwQdF+7HfXgn9BQOk+IM KmnGebRbNmSbKSkfs7+8NPxzCJWSvsLnXA57gc+a30jUEgmMmSPjifUM7Jul+r1TSKta apzDO0exTomgfxjVnfKkpleyLU373xL1ypwffwUr/Kv163wggqxFZkreN0izo5xMhiYH 1hDQ== 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; bh=to5wQOuVoDFPRFzqVg8bHDRI7dOPuy4M29WMpXFCtbk=; b=Q5ZQHM/H77Ain5jWMoZnHdO3RkIWd70Lt0vquUOJ8xcQ+HAmB8lkIvBs6G+zSrwP+2 hwPGPenNLdKUSkH39DCrNVWYOzGcmGcH0hsHUj+enqr2/tG443KmsG/8Hjtva4beB8U3 M/2/h2Rx8RlYyxsWWHwMlhUwS/LQUcaNk/3zo7J6IXZeeyx/8V4L0+oNOxFDx0VS5j0f YcipZh8hpxQaRzaFC80VbuW0+FIJPROXM32h4MdzFOCK1LDsHehdxJcbs3A83GVgsh7m JDtSkEgMSKnzZjvoTBpyIo3HaYHaSoVZnEnUwEbK9dFWmX+KLqeFhnK00RtFNG3DIOfi vGxQ== X-Gm-Message-State: AGRZ1gJ0qbAMMRiWrmQE1shYW0TOztwf3Y6o+WBfuxdT1ZFyvrHHLfb8 WNL68Gv2WkjKQJ1e75hIkP1dBgZl X-Google-Smtp-Source: AFSGD/VC2eQ4PswtTSb74OVOD0e91WeK6MrsIRd7k38BTln7jT3J2njTbvOZpGbTUSCXP/q88ey3lQ== X-Received: by 2002:a1c:5448:: with SMTP id p8mr24150668wmi.124.1543238446599; Mon, 26 Nov 2018 05:20:46 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 26 Nov 2018 14:20:39 +0100 Message-Id: <1543238443-4993-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1543238443-4993-1-git-send-email-pbonzini@redhat.com> References: <1543238443-4993-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Paolo Bonzini --- hw/net/Makefile.objs | 4 ++- hw/net/vhost_net-stub.c | 95 +++++++++++++++++++++++++++++++++++++++++++++= ++++ hw/net/vhost_net.c | 74 -------------------------------------- 3 files changed, 98 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..4de1dfb --- /dev/null +++ b/hw/net/vhost_net-stub.c @@ -0,0 +1,95 @@ +/* + * 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. See + * the COPYING file in the top-level directory. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. + */ + +#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 Sun May 5 18:34:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543238584985358.8005222159153; Mon, 26 Nov 2018 05:23:04 -0800 (PST) Received: from localhost ([::1]:35915 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRGqt-0006A2-51 for importer@patchew.org; Mon, 26 Nov 2018 08:23:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRGom-00051e-RQ for qemu-devel@nongnu.org; Mon, 26 Nov 2018 08:20:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRGoj-0007rt-Bq for qemu-devel@nongnu.org; Mon, 26 Nov 2018 08:20:52 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:36593) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRGoj-0007rB-59 for qemu-devel@nongnu.org; Mon, 26 Nov 2018 08:20:49 -0500 Received: by mail-wm1-x342.google.com with SMTP id s11so18471405wmh.1 for ; Mon, 26 Nov 2018 05:20:49 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i16sm951672wmd.28.2018.11.26.05.20.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Nov 2018 05:20:46 -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; bh=eRlopp2hmUMN8jerwd0rO0c3BktaPEvZUEG1uOB1Hsg=; b=XMPX4ld6xOndjP+atDT+DypjtrqJjNj/1qSAt3UZMcEaMKwJBsQvqjIt8sWDvpHBDG /d04G2aGDHavatjGA7MTo26TYO1eQmYQlDSO4G7bmCbwopgYhJbzmU5raM5yUPMsIE4U dPF0mNRTWtnnUDkegM7HjRhX+jZKlRVC3AW/dvEC0SxTBfVWh/IF4rbNuMs6kUBr38N4 U/RoR8upG3vo9+EJA82sO3idbp6lbKw0opTTBSAt3ICLeOLdzRXVjJXTPfIITsBEUcyA U2Diq54QR87fRPjN+nq2py4zpWB3atGDCcLSiED3RuHtGK+Dz0oYyiVVfimZJTJO/9bs DrTg== 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; bh=eRlopp2hmUMN8jerwd0rO0c3BktaPEvZUEG1uOB1Hsg=; b=E9sKvOhREXhQazmS6RtaAiNuEBs7TbBC2hmEHIAe95fx8BeHNZgaues1ctEWoWSa+M VGT1b6MEvF0H5tjTSN+jzSd36aLp1m4SU3hZnMbmBZFtB0kb1DMhqoHhUfNQ6JJBIBq/ 7LxG0pmN4y/6CKOspg9TwGHhbOa4q3Wg1+yBOmUa6nzgvh/2zei9nm9i3yxW/aTe4/27 F0eBEKcEz0/fzV8REzdPE+kKp+jQPLHg0DgOvFOnVBxScmLKpoKxJ7UNM2KkBLt81f8W 2t/X0WJqHGKCXNt7/W09WpLTcdenfX88lMwBwCRzvzwwbXUPS6amsykk4svOcGZieemU egRA== X-Gm-Message-State: AGRZ1gJmAcA6i4Qlmy0+UWONHtawuweDhxiXizom4flDj6B2DFYbHPrE BDcklIkSSwl+tSaTqPAFrudxdytI X-Google-Smtp-Source: AJdET5c1Y1ZRQB8/5vzFuBbqsIR1+1g3euVP+gD7xEYnaPX+xnOpgqij/5CeV9mdFQKeRpNDhnXZGA== X-Received: by 2002:a1c:947:: with SMTP id 68mr23511051wmj.35.1543238447746; Mon, 26 Nov 2018 05:20:47 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 26 Nov 2018 14:20:40 +0100 Message-Id: <1543238443-4993-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1543238443-4993-1-git-send-email-pbonzini@redhat.com> References: <1543238443-4993-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- 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 0a3c6a7..cda17ef 100755 --- a/configure +++ b/configure @@ -6513,7 +6513,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..fe6202a 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_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 07c194a..95a74ad 100644 --- a/net/net.c +++ b/net/net.c @@ -955,7 +955,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 Sun May 5 18:34:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543238584887494.30906242235403; Mon, 26 Nov 2018 05:23:04 -0800 (PST) Received: from localhost ([::1]:35914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRGqp-00069e-LL for importer@patchew.org; Mon, 26 Nov 2018 08:22:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRGom-00051h-S6 for qemu-devel@nongnu.org; Mon, 26 Nov 2018 08:20:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRGok-0007tn-AQ for qemu-devel@nongnu.org; Mon, 26 Nov 2018 08:20:52 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:35808) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRGok-0007s3-4n for qemu-devel@nongnu.org; Mon, 26 Nov 2018 08:20:50 -0500 Received: by mail-wr1-x444.google.com with SMTP id 96so18907424wrb.2 for ; Mon, 26 Nov 2018 05:20:50 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i16sm951672wmd.28.2018.11.26.05.20.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Nov 2018 05:20:48 -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; bh=suNUS8fc7iqR+MsyjiLDuXRmHQIF4u2ZV45SKrYnE5Y=; b=HAp7KwMqHeKc9RL6JAA7jZdyJhEflExoh0a1/lm5f4vxJDNLx23tXV+MdXtpQFUQow FOjk6K8rokwgC94Se5uInsKiRv1nzi+vLaeRANJiSa1yFnwdJ8vqq9wRFG6iLlqw/3+Q A7rhwbfCBV2NwFb+cwYWp9A5yOPD5UXgS4KhvG75dJ6Ntqv8gZrEgqgZP29hmze7s3CY RdP3riL82iA74NpFctJ1F9KALCorAQXq3N3i8YmGn4kzowLSxeSJyBwKsPjzJoS9nYNS WVnqV8JjagkHZS5hrNbxbgOef/kOEjASrmi515DSqL78b8t51TgRXuu4ERWqjmLHXSWP r5Vg== 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; bh=suNUS8fc7iqR+MsyjiLDuXRmHQIF4u2ZV45SKrYnE5Y=; b=XyyUiSYNKYYsp032L1UN8BAdddsHsnwSuGJqYS0kStdC3QJku3/uqiwYT1KnhhPkXT 4uj6pcYXIxXm+QsikLwuvD3xZ+lnno5dd6PVfjlB/PVGOdrlBJjzxbq13q9zS8MKg6di OnSHPmkREIaDbkU+vnEXwoJXCckQ80IuexrB7Gii03nUREtpCtuo5BVwlFDSeKpgYw4l uB0c1m7GFAJMnIAEpNGo3OXht+SOmerwMZGv6sfWgI0OGoc0FIeBxfR0RwuPBlh6/0jL 0t4DBf24k7nGpDK27BjxYXYm+Gg/tsM84DSbAS6eSUG/BLbIPPiSYHsyie79bXDXy3RH 9Kag== X-Gm-Message-State: AA+aEWY/mVHrxhS8h2NcqWjt3hQu3bzVsumRfgsA8KpIylHCilKDM8td HfSaKlDBWWi9VwbfsrmVSeYBELnG X-Google-Smtp-Source: AFSGD/VLMX5HCTZQ6bJWLqqpEJxQh1W059dBxptyiiaep/HsIFaoFqf4z6IjzDznz3ptZh+mat1R/Q== X-Received: by 2002:a5d:4202:: with SMTP id n2mr860821wrq.260.1543238448839; Mon, 26 Nov 2018 05:20:48 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 26 Nov 2018 14:20:41 +0100 Message-Id: <1543238443-4993-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1543238443-4993-1-git-send-email-pbonzini@redhat.com> References: <1543238443-4993-1-git-send-email-pbonzini@redhat.com> 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- backends/Makefile.objs | 5 ++--- default-configs/virtio.mak | 4 ++-- hw/net/vhost_net.c | 2 +- hw/virtio/Makefile.objs | 5 +++-- hw/virtio/vhost-backend.c | 11 +++++++++-- 5 files changed, 17 insertions(+), 10 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 fe6202a..2a300ee 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -193,7 +193,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *optio= ns) } =20 /* Set sane init value. Override when guest acks. */ -#ifdef CONFIG_VHOST_USER +#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) { 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..b5d2e30 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -9,12 +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" =20 +#ifdef CONFIG_LINUX +#include +#include + static int vhost_kernel_call(struct vhost_dev *dev, unsigned long int requ= est, void *arg) { @@ -265,18 +267,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; --=20 1.8.3.1 From nobody Sun May 5 18:34:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543238595457786.0079190103281; Mon, 26 Nov 2018 05:23:15 -0800 (PST) Received: from localhost ([::1]:35917 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRGr4-0006KS-8q for importer@patchew.org; Mon, 26 Nov 2018 08:23:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRGot-00055y-NJ for qemu-devel@nongnu.org; Mon, 26 Nov 2018 08:21:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRGol-0007wh-PN for qemu-devel@nongnu.org; Mon, 26 Nov 2018 08:20:59 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:43151) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRGol-0007vs-J7 for qemu-devel@nongnu.org; Mon, 26 Nov 2018 08:20:51 -0500 Received: by mail-wr1-x441.google.com with SMTP id r10so18854828wrs.10 for ; Mon, 26 Nov 2018 05:20:51 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i16sm951672wmd.28.2018.11.26.05.20.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Nov 2018 05:20:49 -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; bh=NK5z4gw/ErISJPP3IewAVQ5dOaifFWWr95WppkzXJx4=; b=lvJXwBYxjUA8Fb+01gWH8EfJkcerfjLf8kPnv1zFYzBDcKY/4sslk3STftUfTK3V0c XigVFc1/gZgi6kP6GYJJKBt+5FBSuba/pvYc1RMFiNpWc5uuvxBr4t+V95hILWHWg6Xo X8FVUGvEu4SVmNi9fDqbOhyr3dx7+kb4tPNLVLW2Skfxan8LUsyT+moBfQNlznon93y6 HAj+xZbazocPJTbr1+LCDYAhigVQoVTxsXAQ8UPOKEipSS/T3UkLyOuokpsv5ScJJsYq 3kJwS5I2NP77oiFQr2fW7dQXGWRyd0Tk7myWonJEct+qYkcCZgQi1uf4aWWD8za9xUZ3 LY7w== 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; bh=NK5z4gw/ErISJPP3IewAVQ5dOaifFWWr95WppkzXJx4=; b=RV7VLHSw3KbOAaF4hSPU/eXf0yMQgpBFl5kBO4/IBf5b28eilO8x5RAZ7hwbfBn1ob gLggKuV78AkiSmhAvHY1omPHr0gPhOHBiE/cfSjFyOOzTHNM9QEBRSoNQr2rYfHLNUX2 aiTqwLSDshWKeW/ZljlpsdnDeP7v4Rd8JtfSlt0kIEtUSYuYRp2Sq7iZPYtCyaRaR7wQ ug+cQqTF/BkxAXtGpRckr7NZq6cbRr8Ei9SwCswKGgwUvqO54nTQiGJcCu7F2XKq2JZS st+/Hbl9kNdWZuPeS/GCFTuMR6IfKwSBscwn1fcP/X4Hi9+qABdwu9jgm/yl96LZInLk RyNA== X-Gm-Message-State: AA+aEWYEki5D7B3HteCypMNoLIzpuya1xxXyGwX6y56P3QU1Ww5q443r 1gacQCUJw7xlueuO4Nl0m/g4nbTZ X-Google-Smtp-Source: AFSGD/USEsVmxj5csGnRK+LTpqe4o4gJTtntnS07R4yeBHp6dG1ew9jdcFjck6sdNEZn5elhJ1D0QA== X-Received: by 2002:a5d:4492:: with SMTP id j18mr23308535wrq.236.1543238450015; Mon, 26 Nov 2018 05:20:50 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 26 Nov 2018 14:20:42 +0100 Message-Id: <1543238443-4993-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1543238443-4993-1-git-send-email-pbonzini@redhat.com> References: <1543238443-4993-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- configure | 11 ++++------- hw/net/Makefile.objs | 4 ++-- include/exec/poison.h | 1 - tests/Makefile.include | 5 +---- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/configure b/configure index cda17ef..b3b4464 100755 --- a/configure +++ b/configure @@ -6512,7 +6512,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 @@ -7275,12 +7278,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/include/exec/poison.h b/include/exec/poison.h index 32d5378..b158632 100644 --- a/include/exec/poison.h +++ b/include/exec/poison.h @@ -85,7 +85,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 fb0b449..03a64ce 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) --=20 1.8.3.1 From nobody Sun May 5 18:34:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543238779627185.52480172299533; Mon, 26 Nov 2018 05:26:19 -0800 (PST) Received: from localhost ([::1]:35935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRGts-0001D6-4R for importer@patchew.org; Mon, 26 Nov 2018 08:26:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRGoo-00052Z-4S for qemu-devel@nongnu.org; Mon, 26 Nov 2018 08:20:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRGom-0007xK-LE for qemu-devel@nongnu.org; Mon, 26 Nov 2018 08:20:54 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:54881) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRGom-0007wn-Ec for qemu-devel@nongnu.org; Mon, 26 Nov 2018 08:20:52 -0500 Received: by mail-wm1-x344.google.com with SMTP id z18so3534229wmc.4 for ; Mon, 26 Nov 2018 05:20:52 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i16sm951672wmd.28.2018.11.26.05.20.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Nov 2018 05:20:50 -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; bh=1IFgIpSkswWvriWkEMlRoOKFpKYgtcQr3w/mqndg8mI=; b=t2Ci9R2mueL6+CPmriFyl4LaHW4pEXXd1EbWgxT6FewtUIU9YCycxYqV+ScyNHhdvd Qsjk4hWVYfVOkCpkhrXFRfbvSP7gVFFYVBxCMarrCERyiRjLrlmxZIrqKGZWZVc51E1w CMu47NH42nrWKx50V8KfgM6f9VuvjvUhRCuRBZMzc+7NCavhSQy/+8Yb04qqOTxvFCAD /8DZLWgrx18/wLTzHok2h2VJgn0V0A7UtUIzMcS1XjTlhUFWM0ROYo02If56I4umaOZi BjMrL2BF13gcAkSFWHKnqWvOwG9HAqgV+OFhtozUPYgAm+5G8ZDwLbY62B/FO0wdMV1N 24ag== 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; bh=1IFgIpSkswWvriWkEMlRoOKFpKYgtcQr3w/mqndg8mI=; b=VQm6J0iiKqLm/SaIfoBP09dygf2HaWb+1DL6Tq3FmewpaUWyuMB2FupI1frIjHfaVj 9FaS5Pr2o9HGUrr7ZnzZnEkemspoY2E4NAbvjEc+AMPRtvmNZyrgqfqOTiJ/Gjrjjqgb xOqv97toj+k5koC67FxlCxI6MEEZA0ixidV4uMyMIDYxiwIeEMOMB1xGVfqYhMqqCDdr CmxSLstRq/KpqfXuRBne12BnxmbHky1oZVrJg+b2VfzxtMmjyxe56aUMDgh/N+tvhTc1 AQxZwTDjelFpmJ58JhIlZIF/7ahtWHIZs2Kd8wZlYkLJMTgc1flg9UTML1pI5Vgl6pEq fr4w== X-Gm-Message-State: AA+aEWaLdtv4XbzuAPQdl5qlTqx8k5aGqKVLQSbuniHn33r11lK9irRr hajDtujO/OOKZRF7+UjoOei5Gadz X-Google-Smtp-Source: AFSGD/Ugnu3aazhWyLYpeJ+79i2fUKeP/hnEUk7yWD/rQhz6juHvo1jAJM7/pDiSULXbxZD1cRsTVQ== X-Received: by 2002:a1c:164a:: with SMTP id 71mr1991950wmw.126.1543238451026; Mon, 26 Nov 2018 05:20:51 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 26 Nov 2018 14:20:43 +0100 Message-Id: <1543238443-4993-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1543238443-4993-1-git-send-email-pbonzini@redhat.com> References: <1543238443-4993-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- configure | 88 +++++++++++++++++++++++++++++++------------= ---- hw/virtio/Makefile.objs | 4 +-- hw/virtio/vhost-backend.c | 4 +-- 3 files changed, 62 insertions(+), 34 deletions(-) diff --git a/configure b/configure index b3b4464..a15f143 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" @@ -774,6 +774,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" @@ -874,10 +875,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" @@ -1258,11 +1255,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" ;; @@ -1463,11 +1456,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" ;; @@ -1499,14 +1492,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" @@ -1731,8 +1716,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 @@ -1756,7 +1744,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 @@ -1773,7 +1760,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 @@ -2150,6 +2136,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 @@ -6524,6 +6549,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 b5d2e30..46d388b 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -13,7 +13,7 @@ #include "hw/virtio/vhost-backend.h" #include "qemu/error-report.h" =20 -#ifdef CONFIG_LINUX +#ifdef CONFIG_VHOST_KERNEL #include #include =20 @@ -274,7 +274,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