From nobody Fri Nov 7 00:42:40 2025 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 154463039538750.01961653064916; Wed, 12 Dec 2018 07:59:55 -0800 (PST) Received: from localhost ([::1]:45743 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX6vS-0005ho-6E for importer@patchew.org; Wed, 12 Dec 2018 10:59:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX6N8-0001ND-9A for qemu-devel@nongnu.org; Wed, 12 Dec 2018 10:24:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gX6N5-0000g7-OU for qemu-devel@nongnu.org; Wed, 12 Dec 2018 10:24:26 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:32991) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gX6N5-0000Vq-Du for qemu-devel@nongnu.org; Wed, 12 Dec 2018 10:24:23 -0500 Received: by mail-wr1-x430.google.com with SMTP id c14so18140375wrr.0 for ; Wed, 12 Dec 2018 07:24:05 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id u10sm15878859wrr.33.2018.12.12.07.24.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 07:24:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iz2cTrQ8mIfFHVYmYbwOLVbG0evK9NMaJklxa+5nmH8=; b=oCVhvUdboKHiK6qGBaiof9JRiREKOwjZ7u16EeTB2Ga7vsDXz23/146z0hGYyGuSFu OEQ0CkCVS9fRkcrL68UxIeB1q83aIryZGla+i4TzZprGuqmOd5O9Ou4+wn2boiNSCb4K YJI7mHjruFfbzWVrCY97A07lGhzH8ik4ge95B1sNhee5Xb++zaNkljtZC7UM9dgy/Hja 102PLRE12dde+q/CKrKzxKagfF9KPi3ScqUT6nIP3dE78KhlQXB7cjZNKVJsPz343GE5 odiy5Ce77oo2NT+xdmk3dbc3aNZKFUD9wfSoYyt6qkNv1PHLgcfMuhAW3awvdejSpYfy ZQMQ== 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:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=iz2cTrQ8mIfFHVYmYbwOLVbG0evK9NMaJklxa+5nmH8=; b=fV9EywjFoTc20O4eHu50gDXq1YZWk/M9j2gZR0H4jjtcI5dQyd+mpLk6/Ib53V1PMy TbP+w/yRAbgFByvYDkjQSTmRdV52lsWnV0jysMp8726SpPEUmn8pUmbI8nQUS/zwA4Zw V4DjI1lQCjMfQczXw0CkTHNxMU+dJmuDpNAS1BnliaNM6HJtIBgjtkYhcaP7lyhDp/rL ISD59ipFNve/N83wPy/h+oMLE0FJOnA9k9Wy+ndway4jSiQ2dQgAsLbmfb1kBDZEzGP/ OH5PKH8CEQpIWFy+u2qiArSJB0Z29mjFPlq0B/DlgQG0YbVcT0yXZsTy27ZMnLDRBRp0 xqtw== X-Gm-Message-State: AA+aEWZS+6D3UJ9aGmBmsT0Jtr6fDzVyMviHBSKBgd4+VDoCU3zToIMc JmstWcJ0Jve736WJ+0zZMCkz17eS X-Google-Smtp-Source: AFSGD/WSzmZ9zHKd/+A8BEMOVaYSTI/2JkKjxfdVzkBDBs9CqVy1kiWyjOTxXEa29iLBdxbHCZrztA== X-Received: by 2002:adf:8b4d:: with SMTP id v13mr17135428wra.282.1544628244378; Wed, 12 Dec 2018 07:24:04 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 12 Dec 2018 16:23:04 +0100 Message-Id: <1544628195-37728-44-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1544628195-37728-1-git-send-email-pbonzini@redhat.com> References: <1544628195-37728-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::430 Subject: [Qemu-devel] [PULL 43/54] 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: , 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/virtio/Makefile.objs | 5 +++-- hw/virtio/vhost-backend.c | 11 +++++++++-- 4 files changed, 16 insertions(+), 9 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/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