From nobody Sun Oct 26 00:03:05 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151627864065071.23856177483196; Thu, 18 Jan 2018 04:30:40 -0800 (PST) Received: from localhost ([::1]:55953 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ec9L5-0006OY-Cr for importer@patchew.org; Thu, 18 Jan 2018 07:30:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34833) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ec9I6-0004II-6V for qemu-devel@nongnu.org; Thu, 18 Jan 2018 07:27:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ec9I1-0003tb-GY for qemu-devel@nongnu.org; Thu, 18 Jan 2018 07:27:34 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2151 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ec9I0-0003qY-Sf for qemu-devel@nongnu.org; Thu, 18 Jan 2018 07:27:29 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 9B7604981EC86; Thu, 18 Jan 2018 20:27:14 +0800 (CST) Received: from localhost (10.177.19.14) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.361.1; Thu, 18 Jan 2018 20:27:10 +0800 From: Jay Zhou To: Date: Thu, 18 Jan 2018 20:25:36 +0800 Message-ID: <97c7a886a8569b785d9fec7d4d6b7c182a6b8421.1516277913.git.arei.gonglei@huawei.com> X-Mailer: git-send-email 2.6.1.windows.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.177.19.14] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 45.249.212.190 Subject: [Qemu-devel] [PATCH v4 5/5] cryptodev-vhost-user: depend on CONFIG_VHOST_CRYPTO and CONFIG_VHOST_USER 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: pasic@linux.vnet.ibm.com, weidong.huang@huawei.com, mst@redhat.com, wangxinxin.wang@huawei.com, xin.zeng@intel.com, arei.gonglei@huawei.com, roy.fan.zhang@intel.com, stefanha@redhat.com, jianjay.zhou@huawei.com, pbonzini@redhat.com, longpeng2@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Gonglei Signed-off-by: Jay Zhou --- backends/Makefile.objs | 4 +++- backends/cryptodev-vhost.c | 57 ++++++++++++++++++++++++++++++++++++++++++= +--- configure | 15 ++++++++++++ vl.c | 2 ++ 4 files changed, 74 insertions(+), 4 deletions(-) diff --git a/backends/Makefile.objs b/backends/Makefile.objs index 9e1fb76..ea4f630 100644 --- a/backends/Makefile.objs +++ b/backends/Makefile.objs @@ -10,5 +10,7 @@ common-obj-y +=3D cryptodev.o common-obj-y +=3D cryptodev-builtin.o =20 ifeq ($(CONFIG_VIRTIO),y) -common-obj-$(CONFIG_LINUX) +=3D cryptodev-vhost.o cryptodev-vhost-user.o +common-obj-$(CONFIG_LINUX) +=3D cryptodev-vhost.o +common-obj-$(call land,$(CONFIG_VHOST_CRYPTO),$(CONFIG_VHOST_USER)) +=3D \ + cryptodev-vhost-user.o endif diff --git a/backends/cryptodev-vhost.c b/backends/cryptodev-vhost.c index 830fb53..ad1f415 100644 --- a/backends/cryptodev-vhost.c +++ b/backends/cryptodev-vhost.c @@ -23,14 +23,18 @@ */ =20 #include "qemu/osdep.h" +#include "hw/virtio/virtio-bus.h" +#include "sysemu/cryptodev-vhost.h" + +#ifdef CONFIG_VHOST_CRYPTO #include "qapi/error.h" #include "qapi/qmp/qerror.h" #include "qemu/error-report.h" -#include "sysemu/cryptodev-vhost.h" #include "hw/virtio/virtio-crypto.h" -#include "hw/virtio/virtio-bus.h" -#include "sysemu/cryptodev-vhost-user.h" =20 +#ifdef CONFIG_VHOST_USER +#include "sysemu/cryptodev-vhost-user.h" +#endif =20 uint64_t cryptodev_vhost_get_max_queues( @@ -123,9 +127,11 @@ cryptodev_get_vhost(CryptoDevBackendClient *cc, } =20 switch (cc->type) { +#ifdef CONFIG_VHOST_USER case CRYPTODEV_BACKEND_TYPE_VHOST_USER: vhost_crypto =3D cryptodev_vhost_user_get_vhost(cc, b, queue); break; +#endif default: break; } @@ -295,3 +301,48 @@ bool cryptodev_vhost_virtqueue_pending(VirtIODevice *d= ev, =20 return vhost_virtqueue_pending(&vhost_crypto->dev, idx); } + +#else +uint64_t +cryptodev_vhost_get_max_queues(CryptoDevBackendVhost *crypto) +{ + return 0; +} + +void cryptodev_vhost_cleanup(CryptoDevBackendVhost *crypto) +{ +} + +struct CryptoDevBackendVhost * +cryptodev_vhost_init(CryptoDevBackendVhostOptions *options) +{ + return NULL; +} + +CryptoDevBackendVhost * +cryptodev_get_vhost(CryptoDevBackendClient *cc, CryptoDevBackend *b, + uint16_t queue) +{ + return NULL; +} + +int cryptodev_vhost_start(VirtIODevice *dev, int total_queues) +{ + return -1; +} + +void cryptodev_vhost_stop(VirtIODevice *dev, int total_queues) +{ +} + +void cryptodev_vhost_virtqueue_mask(VirtIODevice *dev, int queue, + int idx, bool mask) +{ +} + +bool cryptodev_vhost_virtqueue_pending(VirtIODevice *dev, + int queue, int idx) +{ + return false; +} +#endif diff --git a/configure b/configure index b272a03..e4cece3 100755 --- a/configure +++ b/configure @@ -332,6 +332,7 @@ xfs=3D"" tcg=3D"yes" =20 vhost_net=3D"no" +vhost_crypto=3D"no" vhost_scsi=3D"no" vhost_vsock=3D"no" vhost_user=3D"" @@ -801,6 +802,7 @@ Linux) 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 $QE= MU_INCLUDES" @@ -1163,6 +1165,14 @@ for opt do ;; --enable-vhost-net) vhost_net=3D"yes" ;; + --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 + ;; --disable-vhost-scsi) vhost_scsi=3D"no" ;; --enable-vhost-scsi) vhost_scsi=3D"yes" @@ -1555,6 +1565,7 @@ disabled with --disable-FEATURE, default is enabled i= f available: cap-ng libcap-ng support attr attr and xattr support vhost-net vhost-net acceleration support + vhost-crypto vhost-crypto acceleration support spice spice rbd rados block device (rbd) libiscsi iscsi support @@ -5579,6 +5590,7 @@ echo "madvise $madvise" echo "posix_madvise $posix_madvise" echo "libcap-ng support $cap_ng" echo "vhost-net support $vhost_net" +echo "vhost-crypto support $vhost_crypto" echo "vhost-scsi support $vhost_scsi" echo "vhost-vsock support $vhost_vsock" echo "vhost-user support $vhost_user" @@ -6640,6 +6652,9 @@ if supported_kvm_target $target; then echo "CONFIG_VHOST_USER_NET_TEST_$target_name=3Dy" >> $config_= host_mak fi fi + if test "$vhost_crypto" =3D "yes"; then + echo "CONFIG_VHOST_CRYPTO=3Dy" >> $config_target_mak + fi fi if supported_hax_target $target; then echo "CONFIG_HAX=3Dy" >> $config_target_mak diff --git a/vl.c b/vl.c index 3e9d86f..9f9727d 100644 --- a/vl.c +++ b/vl.c @@ -2867,9 +2867,11 @@ static bool object_create_initial(const char *type) return false; } =20 +#if defined(CONFIG_VHOST_CRYPTO) && defined(CONFIG_VHOST_USER) if (g_str_equal(type, "cryptodev-vhost-user")) { return false; } +#endif =20 /* * return false for concrete netfilters since --=20 1.8.3.1