From nobody Thu Apr 25 21:12:40 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=gmail.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544078331394944.675179236613; Wed, 5 Dec 2018 22:38:51 -0800 (PST) Received: from localhost ([::1]:39093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUnIw-0002Hx-MV for importer@patchew.org; Thu, 06 Dec 2018 01:38:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUnH4-0001Js-IJ for qemu-devel@nongnu.org; Thu, 06 Dec 2018 01:36:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gUnH1-0003Es-PW for qemu-devel@nongnu.org; Thu, 06 Dec 2018 01:36:38 -0500 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:34113) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gUnH1-0003BZ-G7 for qemu-devel@nongnu.org; Thu, 06 Dec 2018 01:36:35 -0500 Received: by mail-pg1-x544.google.com with SMTP id 17so10208605pgg.1 for ; Wed, 05 Dec 2018 22:36:35 -0800 (PST) Received: from yongji-Ubuntu.internal.baidu.com ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id x186sm26175249pfb.59.2018.12.05.22.36.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Dec 2018 22:36:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MV5KnfjMHiDJvr3z6fKJ2mUgqVgBbW4RRnCmmfVxATA=; b=CJnrXU318CUp6y0ZC+hvq8ss9Aga6WUtR9r6AXBPKkd+iSRn2BVdrAhmif0Fa18N4K qXCdh5yL5bDkErW93u3DmDNeWb5p+yO6cEnPQb/eIBi4j8KKxVo+e1wpnGTwnLWFxKqm mVGZKllnbXkKKZkTxdL3W+P4S0NJ8ldZIIo6ngNDOUaf9gJUVf19L7JEc8ux/ACvVwAq Ql0BjRQh9fiD4Hjz91jkG9AH6VC3q7ghwt28U5Syk0QuAdWSUuVzLCgq5mMgyfCkRur5 QrMSX/O8mY2EEvCsR7tidOrg7jRxs6A0KnljFFClybJ3NgRbzFtOxs2QMvKDJJ3x9uLd ndjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MV5KnfjMHiDJvr3z6fKJ2mUgqVgBbW4RRnCmmfVxATA=; b=sztX9AF63GIU6KJi3KQ/x+y5ED9EMYBKawLs4gDIbwb7Yat19rpLx4efQEk0JlJKDm 8s+BILspLjYC+7LDUa/EvmK38DpjRgcuHbPOXn1X7TWBGfXCrWT9I0TDByZYA9GTlVpm VCaHdl+yJnIOUWWy2ZxtGt4vNRZxlPuACsZBxIXWsjpeJTGpY/DNiP7ROFICRZHuDOvr H2n3ooyrT0vJ2wb0TFftxsw/zInmohzKOJlQ7dYR0BgCxyaxAYCOOdo5XwBuaxkX4PI7 gEFS4QHRSODGITEV8NDvYzUXvvQ+ZkYp1QU0sRpmwxK3YQV8Ce4XRBTKg1QbUIWS5IbJ /1fw== X-Gm-Message-State: AA+aEWarBsrvNdDU22ftB/b2ELFHZVZ6f6IqmGx+a/xuQqmfQpmFRURN aEa1wsA7xDqzK+HEg3c8Fi3Rorhd7UA= X-Google-Smtp-Source: AFSGD/UDkPcPsb7IGDBXm0PbJ3A7PxFS+70L9rbp7u1HDobivxiTktnS1fO4StNLTNaFPU7499tFKQ== X-Received: by 2002:a62:7f94:: with SMTP id a142mr27604606pfd.96.1544078194499; Wed, 05 Dec 2018 22:36:34 -0800 (PST) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, marcandre.lureau@redhat.com Date: Thu, 6 Dec 2018 14:35:47 +0800 Message-Id: <20181206063552.6701-2-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181206063552.6701-1-xieyongji@baidu.com> References: <20181206063552.6701-1-xieyongji@baidu.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PATCH for-4.0 1/6] char-socket: Enable "wait" option for client mode 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: nixun@baidu.com, qemu-devel@nongnu.org, lilin24@baidu.com, zhangyu31@baidu.com, chaiwen@baidu.com, Xie Yongji 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" From: Xie Yongji Now we attempt to connect asynchronously for "reconnect socket" during open(). But vhost-user device prefer a connected socket during initialization. That means we may still need to support sync connection during open() for the "reconnect socket". Signed-off-by: Xie Yongji Signed-off-by: Zhang Yu --- chardev/char-socket.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index eaa8e8b68f..f2819d52e7 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -1072,7 +1072,7 @@ static void qmp_chardev_open_socket(Chardev *chr, s->reconnect_time =3D reconnect; } =20 - if (s->reconnect_time) { + if (s->reconnect_time && !is_waitconnect) { tcp_chr_connect_async(chr); } else { if (s->is_listen) { @@ -1120,7 +1120,8 @@ static void qemu_chr_parse_socket(QemuOpts *opts, Cha= rdevBackend *backend, Error **errp) { bool is_listen =3D qemu_opt_get_bool(opts, "server", false); - bool is_waitconnect =3D is_listen && qemu_opt_get_bool(opts, "wait", t= rue); + bool is_waitconnect =3D is_listen ? qemu_opt_get_bool(opts, "wait", tr= ue) : + qemu_opt_get_bool(opts, "wait", false); bool is_telnet =3D qemu_opt_get_bool(opts, "telnet", false); bool is_tn3270 =3D qemu_opt_get_bool(opts, "tn3270", false); bool is_websock =3D qemu_opt_get_bool(opts, "websocket", false); --=20 2.17.1 From nobody Thu Apr 25 21:12:40 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=gmail.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544078487956915.8288655151889; Wed, 5 Dec 2018 22:41:27 -0800 (PST) Received: from localhost ([::1]:39110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUnLb-0004wx-N7 for importer@patchew.org; Thu, 06 Dec 2018 01:41:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52805) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUnHJ-0001Sr-82 for qemu-devel@nongnu.org; Thu, 06 Dec 2018 01:36:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gUnHB-0003Os-LM for qemu-devel@nongnu.org; Thu, 06 Dec 2018 01:36:51 -0500 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:46198) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gUnH9-0003MD-Hw for qemu-devel@nongnu.org; Thu, 06 Dec 2018 01:36:45 -0500 Received: by mail-pg1-x544.google.com with SMTP id w7so10179284pgp.13 for ; Wed, 05 Dec 2018 22:36:42 -0800 (PST) Received: from yongji-Ubuntu.internal.baidu.com ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id x186sm26175249pfb.59.2018.12.05.22.36.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Dec 2018 22:36:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=R8PT06pUE8dn1kFgVY/VcsbF2I2WIcg1CFzPd6hORKs=; b=HYDg3s0ott3FOOANmNqmUBMkE4p7+F9fKma7LNDwrgsz5EncOYFMnvlxNTKE8xxrEu 4m0pvH+NNDCz0iTdmmfCMb3XUZVmVGZgAH/NdMFK8DklQVFzXJNIF/KEYBlYDBt1+i3N qHZhzSMdMCsT1flNfEsIT8/afoqiSbNbGKQ1oosMCRH2scTRyQcxTrcj9heoxAjQYvLE Xul9wQ/KeIHKiDdAVkj5f1MLGHRT57h1CAIVO+V1RlM4Kk+Ls6t5HgEWIEWQMWWgDshW 8Mdfu2KOaug2EAd0mxlBbM0RJ+WbtsNU+wKa6pGPHQd5nrlnHY2FViktc7wZRcERVkf8 oTtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=R8PT06pUE8dn1kFgVY/VcsbF2I2WIcg1CFzPd6hORKs=; b=Sunuft/FOFda1PVXFr1bZwtVWyxTRHuaY8fw+GRsKfxYv37F5xURTAfoIRPs2Dzfh9 8g7dIc0vRI3FUN8AN2MIrnM+7JwICP8GvP9NG6GKVzq5baCHo3wZ0rWfB0QIj+I0TTTU MIfWE42kyJ/YyDkuUUGQ3o0kJCOyxZfVHXDzXrRwpFJbNQPEdLIKz3QIIgRnbjCW6RIi 9+eP26O+mmDE//PMKsSHOuzfTmEBMejDRLyl25UBStMTZ9DWa4ofN4ZKt5lIuBgX+WpQ /D0DixkGCpng/mt5+B4NY6Ton2S5GSyKSuVDRiVkwKtcOAsNLHl9S1Xb51MjOTO/Xbnc WZDA== X-Gm-Message-State: AA+aEWZNVpwbJteOuO5n4wHdhVZvvfEQmDj0Q5bi/YSsqsCdEsGoXdUk +4Vf7WWNKEM6469zxsYZMTM= X-Google-Smtp-Source: AFSGD/VqmpF44YSesIdOVq/5P84B04IiibEwdBKJzlhNlDw/G3Wysms8Vo/wBg8lfphhlpPor6i/2A== X-Received: by 2002:a63:6ecf:: with SMTP id j198mr23484012pgc.3.1544078201664; Wed, 05 Dec 2018 22:36:41 -0800 (PST) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, marcandre.lureau@redhat.com Date: Thu, 6 Dec 2018 14:35:48 +0800 Message-Id: <20181206063552.6701-3-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181206063552.6701-1-xieyongji@baidu.com> References: <20181206063552.6701-1-xieyongji@baidu.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PATCH for-4.0 2/6] vhost-user: Add shared memory to record inflight I/O 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: nixun@baidu.com, qemu-devel@nongnu.org, lilin24@baidu.com, zhangyu31@baidu.com, chaiwen@baidu.com, Xie Yongji 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" From: Xie Yongji This introduces a new message VHOST_USER_SET_VRING_INFLIGHT to support offering shared memory to backend to record its inflight I/O. With this new message, the backend is able to restart without missing I/O which would cause I/O hung for block device. Signed-off-by: Xie Yongji Signed-off-by: Chai Wen Signed-off-by: Zhang Yu --- hw/virtio/vhost-user.c | 69 +++++++++++++++++++++++++++++++ hw/virtio/vhost.c | 8 ++++ include/hw/virtio/vhost-backend.h | 4 ++ include/hw/virtio/vhost-user.h | 8 ++++ 4 files changed, 89 insertions(+) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index e09bed0e4a..4c0e64891d 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -19,6 +19,7 @@ #include "sysemu/kvm.h" #include "qemu/error-report.h" #include "qemu/sockets.h" +#include "qemu/memfd.h" #include "sysemu/cryptodev.h" #include "migration/migration.h" #include "migration/postcopy-ram.h" @@ -52,6 +53,7 @@ enum VhostUserProtocolFeature { VHOST_USER_PROTOCOL_F_CONFIG =3D 9, VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD =3D 10, VHOST_USER_PROTOCOL_F_HOST_NOTIFIER =3D 11, + VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD =3D 12, VHOST_USER_PROTOCOL_F_MAX }; =20 @@ -89,6 +91,7 @@ typedef enum VhostUserRequest { VHOST_USER_POSTCOPY_ADVISE =3D 28, VHOST_USER_POSTCOPY_LISTEN =3D 29, VHOST_USER_POSTCOPY_END =3D 30, + VHOST_USER_SET_VRING_INFLIGHT =3D 31, VHOST_USER_MAX } VhostUserRequest; =20 @@ -147,6 +150,11 @@ typedef struct VhostUserVringArea { uint64_t offset; } VhostUserVringArea; =20 +typedef struct VhostUserVringInflight { + uint32_t size; + uint32_t idx; +} VhostUserVringInflight; + typedef struct { VhostUserRequest request; =20 @@ -169,6 +177,7 @@ typedef union { VhostUserConfig config; VhostUserCryptoSession session; VhostUserVringArea area; + VhostUserVringInflight inflight; } VhostUserPayload; =20 typedef struct VhostUserMsg { @@ -1739,6 +1748,58 @@ static bool vhost_user_mem_section_filter(struct vho= st_dev *dev, return result; } =20 +static int vhost_user_set_vring_inflight(struct vhost_dev *dev, int idx) +{ + struct vhost_user *u =3D dev->opaque; + + if (!virtio_has_feature(dev->protocol_features, + VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) { + return 0; + } + + if (!u->user->inflight[idx].addr) { + Error *err =3D NULL; + + u->user->inflight[idx].size =3D qemu_real_host_page_size; + u->user->inflight[idx].addr =3D qemu_memfd_alloc("vhost-inflight", + u->user->inflight[idx].size, + F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL= _SEAL, + &u->user->inflight[idx].fd, &err); + if (err) { + error_report_err(err); + u->user->inflight[idx].addr =3D NULL; + return -1; + } + } + + VhostUserMsg msg =3D { + .hdr.request =3D VHOST_USER_SET_VRING_INFLIGHT, + .hdr.flags =3D VHOST_USER_VERSION, + .payload.inflight.size =3D u->user->inflight[idx].size, + .payload.inflight.idx =3D idx, + .hdr.size =3D sizeof(msg.payload.inflight), + }; + + if (vhost_user_write(dev, &msg, &u->user->inflight[idx].fd, 1) < 0) { + return -1; + } + + return 0; +} + +void vhost_user_inflight_reset(VhostUserState *user) +{ + int i; + + for (i =3D 0; i < VIRTIO_QUEUE_MAX; i++) { + if (!user->inflight[i].addr) { + continue; + } + + memset(user->inflight[i].addr, 0, user->inflight[i].size); + } +} + VhostUserState *vhost_user_init(void) { VhostUserState *user =3D g_new0(struct VhostUserState, 1); @@ -1756,6 +1817,13 @@ void vhost_user_cleanup(VhostUserState *user) munmap(user->notifier[i].addr, qemu_real_host_page_size); user->notifier[i].addr =3D NULL; } + + if (user->inflight[i].addr) { + munmap(user->inflight[i].addr, user->inflight[i].size); + user->inflight[i].addr =3D NULL; + close(user->inflight[i].fd); + user->inflight[i].fd =3D -1; + } } } =20 @@ -1790,4 +1858,5 @@ const VhostOps user_ops =3D { .vhost_crypto_create_session =3D vhost_user_crypto_create_session, .vhost_crypto_close_session =3D vhost_user_crypto_close_session, .vhost_backend_mem_section_filter =3D vhost_user_mem_section_filte= r, + .vhost_set_vring_inflight =3D vhost_user_set_vring_inflight, }; diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 569c4053ea..2ca7b4e841 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -973,6 +973,14 @@ static int vhost_virtqueue_start(struct vhost_dev *dev, return -errno; } =20 + if (dev->vhost_ops->vhost_set_vring_inflight) { + r =3D dev->vhost_ops->vhost_set_vring_inflight(dev, vhost_vq_index= ); + if (r) { + VHOST_OPS_DEBUG("vhost_set_vring_inflight failed"); + return -errno; + } + } + state.num =3D virtio_queue_get_last_avail_idx(vdev, idx); r =3D dev->vhost_ops->vhost_set_vring_base(dev, &state); if (r) { diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index 81283ec50f..8110e09089 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -104,6 +104,9 @@ typedef int (*vhost_crypto_close_session_op)(struct vho= st_dev *dev, typedef bool (*vhost_backend_mem_section_filter_op)(struct vhost_dev *dev, MemoryRegionSection *secti= on); =20 +typedef int (*vhost_set_vring_inflight_op)(struct vhost_dev *dev, + int idx); + typedef struct VhostOps { VhostBackendType backend_type; vhost_backend_init vhost_backend_init; @@ -142,6 +145,7 @@ typedef struct VhostOps { vhost_crypto_create_session_op vhost_crypto_create_session; vhost_crypto_close_session_op vhost_crypto_close_session; vhost_backend_mem_section_filter_op vhost_backend_mem_section_filter; + vhost_set_vring_inflight_op vhost_set_vring_inflight; } VhostOps; =20 extern const VhostOps user_ops; diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index fd660393a0..ff13433153 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -17,11 +17,19 @@ typedef struct VhostUserHostNotifier { bool set; } VhostUserHostNotifier; =20 +typedef struct VhostUserInflight { + void *addr; + uint32_t size; + int fd; +} VhostUserInflight; + typedef struct VhostUserState { CharBackend *chr; VhostUserHostNotifier notifier[VIRTIO_QUEUE_MAX]; + VhostUserInflight inflight[VIRTIO_QUEUE_MAX]; } VhostUserState; =20 +void vhost_user_inflight_reset(VhostUserState *user); VhostUserState *vhost_user_init(void); void vhost_user_cleanup(VhostUserState *user); =20 --=20 2.17.1 From nobody Thu Apr 25 21:12:40 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=gmail.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544078487405993.874524820338; Wed, 5 Dec 2018 22:41:27 -0800 (PST) Received: from localhost ([::1]:39111 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUnLd-0004yP-7l for importer@patchew.org; Thu, 06 Dec 2018 01:41:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52810) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUnHJ-0001Ss-7z for qemu-devel@nongnu.org; Thu, 06 Dec 2018 01:36:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gUnHF-0003TT-A0 for qemu-devel@nongnu.org; Thu, 06 Dec 2018 01:36:51 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:38351) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gUnHE-0003Pq-Os for qemu-devel@nongnu.org; Thu, 06 Dec 2018 01:36:48 -0500 Received: by mail-pg1-x542.google.com with SMTP id g189so10189250pgc.5 for ; Wed, 05 Dec 2018 22:36:46 -0800 (PST) Received: from yongji-Ubuntu.internal.baidu.com ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id x186sm26175249pfb.59.2018.12.05.22.36.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Dec 2018 22:36:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XKl4V81WAbYlKQdyvx2f7AmT9JieubeQLT/wGHLl3FU=; b=ZwP6bI6ksSCLQbTJdW+LHrq3Mfuiwqeivi/4R4uPYZdFKpbMD4jquJqa5Q7xkxlwSL OEtEcQWVtpTA80r9Trjplc9JzUf4w0x81D+8l7Rf/1J/7qzEU6ZsWPuf8LHlKhtyNbEG x4W3C+LFg13/c4jihEbvhgCWNUpmMv0FNfsPw6BUr1h3gcbqiITllaa3wBKsUViaumTX reSm0ldnDPXHUTs9CiVpxouCRNpqyb6sbfb9tPQELT5xkIGUjs+rmtFBX4qrq0faf6kq tQh3wDytL7XiDFUB9pfyI6ewvBflVE+Tv2vr+VpQ+H1EspUrxwucJazRNtTF2PWdBD6r YCmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XKl4V81WAbYlKQdyvx2f7AmT9JieubeQLT/wGHLl3FU=; b=IsoPx2h9BdAg7OEICJw0Heb6Q+NVz3RZkrVnZX5msMqG8KqEgEhyH3sW4aMhKaCGzD z4BSrKLjrROFeQaxdMP3YdoriGW0xl0DdFAuKTOCl55I1GYBZgiaiidRXxKYXWjOwuhu aEOZQZMnYF6KULyLfNo40RRm+EVt4KWte1w74EZNplbXlBR7FO0/DOR52SE0RNj6cgXj 9cGz2AtZUPr8GFLJkvb8f1Ch5OP96dQNgBcE4O0B0cyAp3AFhVxTnrwSd7lMKnNPXrmz pBEJOrLdTXDEmzgXTKwPvZ3visiZkOkJTl3LmLyv6YnM2CYUn9RaG00ddOhvu9PL4vYZ jPvg== X-Gm-Message-State: AA+aEWbsKzGiiLOfcqrBzsH3HxDePfrKyS5vXmxtnCi9dc+skBnSlvod fRwjcltVq3MK8MU5o4Ti5KfFuBal0D0= X-Google-Smtp-Source: AFSGD/UTvSvU+IpQyd29yuwQhtIUJ3F6LV1Ud7f6guM1uBNDa4QY/yb2JMfVWroUwIrCiWAMlVnWEQ== X-Received: by 2002:a63:b17:: with SMTP id 23mr23290622pgl.423.1544078205596; Wed, 05 Dec 2018 22:36:45 -0800 (PST) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, marcandre.lureau@redhat.com Date: Thu, 6 Dec 2018 14:35:49 +0800 Message-Id: <20181206063552.6701-4-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181206063552.6701-1-xieyongji@baidu.com> References: <20181206063552.6701-1-xieyongji@baidu.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH for-4.0 3/6] libvhost-user: Introduce vu_queue_map_desc() 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: nixun@baidu.com, qemu-devel@nongnu.org, lilin24@baidu.com, zhangyu31@baidu.com, chaiwen@baidu.com, Xie Yongji 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" From: Xie Yongji Introduce vu_queue_map_desc() which should be independent with vu_queue_pop(); Signed-off-by: Xie Yongji Signed-off-by: Zhang Yu Reviewed-by: Marc-Andr=C3=A9 Lureau --- contrib/libvhost-user/libvhost-user.c | 86 +++++++++++++++------------ 1 file changed, 49 insertions(+), 37 deletions(-) diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/= libvhost-user.c index a6b46cdc03..4432bd8bb4 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -1853,49 +1853,20 @@ virtqueue_alloc_element(size_t sz, return elem; } =20 -void * -vu_queue_pop(VuDev *dev, VuVirtq *vq, size_t sz) +static void * +vu_queue_map_desc(VuDev *dev, VuVirtq *vq, unsigned int idx, size_t sz) { - unsigned int i, head, max, desc_len; + struct vring_desc *desc =3D vq->vring.desc; uint64_t desc_addr, read_len; + unsigned int desc_len; + unsigned int max =3D vq->vring.num; + unsigned int i =3D idx; VuVirtqElement *elem; - unsigned out_num, in_num; + unsigned int out_num =3D 0, in_num =3D 0; struct iovec iov[VIRTQUEUE_MAX_SIZE]; struct vring_desc desc_buf[VIRTQUEUE_MAX_SIZE]; - struct vring_desc *desc; int rc; =20 - if (unlikely(dev->broken) || - unlikely(!vq->vring.avail)) { - return NULL; - } - - if (vu_queue_empty(dev, vq)) { - return NULL; - } - /* Needed after virtio_queue_empty(), see comment in - * virtqueue_num_heads(). */ - smp_rmb(); - - /* When we start there are none of either input nor output. */ - out_num =3D in_num =3D 0; - - max =3D vq->vring.num; - if (vq->inuse >=3D vq->vring.num) { - vu_panic(dev, "Virtqueue size exceeded"); - return NULL; - } - - if (!virtqueue_get_head(dev, vq, vq->last_avail_idx++, &head)) { - return NULL; - } - - if (vu_has_feature(dev, VIRTIO_RING_F_EVENT_IDX)) { - vring_set_avail_event(vq, vq->last_avail_idx); - } - - i =3D head; - desc =3D vq->vring.desc; if (desc[i].flags & VRING_DESC_F_INDIRECT) { if (desc[i].len % sizeof(struct vring_desc)) { vu_panic(dev, "Invalid size for indirect buffer table"); @@ -1947,12 +1918,13 @@ vu_queue_pop(VuDev *dev, VuVirtq *vq, size_t sz) } while (rc =3D=3D VIRTQUEUE_READ_DESC_MORE); =20 if (rc =3D=3D VIRTQUEUE_READ_DESC_ERROR) { + vu_panic(dev, "read descriptor error"); return NULL; } =20 /* Now copy what we have collected and mapped */ elem =3D virtqueue_alloc_element(sz, out_num, in_num); - elem->index =3D head; + elem->index =3D idx; for (i =3D 0; i < out_num; i++) { elem->out_sg[i] =3D iov[i]; } @@ -1960,6 +1932,46 @@ vu_queue_pop(VuDev *dev, VuVirtq *vq, size_t sz) elem->in_sg[i] =3D iov[out_num + i]; } =20 + return elem; +} + +void * +vu_queue_pop(VuDev *dev, VuVirtq *vq, size_t sz) +{ + unsigned int head; + VuVirtqElement *elem; + + if (unlikely(dev->broken) || + unlikely(!vq->vring.avail)) { + return NULL; + } + + if (vu_queue_empty(dev, vq)) { + return NULL; + } + /* Needed after virtio_queue_empty(), see comment in + * virtqueue_num_heads(). */ + smp_rmb(); + + if (vq->inuse >=3D vq->vring.num) { + vu_panic(dev, "Virtqueue size exceeded"); + return NULL; + } + + if (!virtqueue_get_head(dev, vq, vq->last_avail_idx++, &head)) { + return NULL; + } + + if (vu_has_feature(dev, VIRTIO_RING_F_EVENT_IDX)) { + vring_set_avail_event(vq, vq->last_avail_idx); + } + + elem =3D vu_queue_map_desc(dev, vq, head, sz); + + if (!elem) { + return NULL; + } + vq->inuse++; =20 return elem; --=20 2.17.1 From nobody Thu Apr 25 21:12:40 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=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 154407835116949.05294029826666; Wed, 5 Dec 2018 22:39:11 -0800 (PST) Received: from localhost ([::1]:39095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUnJV-0002mr-Qn for importer@patchew.org; Thu, 06 Dec 2018 01:39:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52875) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUnHR-0001Xi-8V for qemu-devel@nongnu.org; Thu, 06 Dec 2018 01:37:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gUnHL-0003Yu-5p for qemu-devel@nongnu.org; Thu, 06 Dec 2018 01:36:59 -0500 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:35435) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gUnHH-0003Tm-AU for qemu-devel@nongnu.org; Thu, 06 Dec 2018 01:36:53 -0500 Received: by mail-pg1-x543.google.com with SMTP id s198so10211068pgs.2 for ; Wed, 05 Dec 2018 22:36:50 -0800 (PST) Received: from yongji-Ubuntu.internal.baidu.com ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id x186sm26175249pfb.59.2018.12.05.22.36.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Dec 2018 22:36:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bW+YSFxiflf4ZGeT27q2UEWAxdOJmnquUgmkkLRZ6rk=; b=gW53+VlsYJs10FhaNFXzhW/mG1Ahi/8/BFgffMJ2MVpXGUp0Q6qdOYqifi+7KCA0xN BYYYxD1u+ac4nW+1WoqyPGfr1srzSdW9bm6+CgDSPx6sx+YjaW46d6lVhhuy9KNXC2b1 5wV+AaJ7MTqzN3L3J9cSNSipbrIJU4W9uKR4EAmiNcDmEYz6d2Fx1I4hv/nNvJ+oGzyr BvK/hnFmjbQUhP3c7Iu9OHydmGc7gaNkgbcdDMipOIjHXouX7x765yZTCU4yVp6kYo79 mCZab9LJRAqLhHZM+3gVfGNrdRlL0QkyJquJ0d0JkmJ3Az5l065zHwNW9RR9UyP2er3q crOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bW+YSFxiflf4ZGeT27q2UEWAxdOJmnquUgmkkLRZ6rk=; b=g02acUs4lcFb2TpSs+PVn1kA7qGesSj+OzANZfn85oJz6HuHoBoRFrBiFIryXfmTvR Tp3xJ8eYlIbETHDmBVA/HHtz9mzSp3ayS+dj0RkiHzoeP4NlY8GOXXDhtrQeI/8rAl/I EClFq45FT7u8jXMnhHQeNYGL+vbFS7Rh2vzmllU5h2/lohPTroT/Ac9NtxeWxG1t7vqg iC0NRKlSrzQGG0jBhX+DS0wckNRDDixpKCmcyzZOHjtk5q3zK4HwYktngqYWW8oKGEaU 8pm7tZGdc/q6G5D6nslNOC99/91KzSq1/lEyQPb/k9tOkDX6/6YK/OJa6cnERuAMJ6Mv /Ehg== X-Gm-Message-State: AA+aEWYypT+6z7sL50R/zFbf+XsQlHDU7H8ZqKqys5Dfaycj5aoXL7Ev 9AOmcm82lbEDgGBP4lgR3Ko= X-Google-Smtp-Source: AFSGD/VhKJ5m8ju/yjvgkYtHHImuPmGtQlEBLAjlYzDlzOGqU883nlHRprPA8rvj+ANJF3ApWav06w== X-Received: by 2002:a63:e615:: with SMTP id g21mr23463584pgh.290.1544078209248; Wed, 05 Dec 2018 22:36:49 -0800 (PST) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, marcandre.lureau@redhat.com Date: Thu, 6 Dec 2018 14:35:50 +0800 Message-Id: <20181206063552.6701-5-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181206063552.6701-1-xieyongji@baidu.com> References: <20181206063552.6701-1-xieyongji@baidu.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 Subject: [Qemu-devel] [PATCH for-4.0 4/6] libvhost-user: Support recording inflight I/O in shared memory 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: nixun@baidu.com, qemu-devel@nongnu.org, lilin24@baidu.com, zhangyu31@baidu.com, chaiwen@baidu.com, Xie Yongji 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" From: Xie Yongji This patch adds support for VHOST_USER_SET_VRING_INFLIGHT message. Now we maintain a "bitmap" of all descriptors in the shared memory for each queue. Then set it in vu_queue_pop() and clear it in vu_queue_push(); Signed-off-by: Xie Yongji Signed-off-by: Zhang Yu --- contrib/libvhost-user/libvhost-user.c | 129 ++++++++++++++++++++++++++ contrib/libvhost-user/libvhost-user.h | 19 ++++ 2 files changed, 148 insertions(+) diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/= libvhost-user.c index 4432bd8bb4..38ef1f5898 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -100,6 +100,7 @@ vu_request_to_string(unsigned int req) REQ(VHOST_USER_POSTCOPY_ADVISE), REQ(VHOST_USER_POSTCOPY_LISTEN), REQ(VHOST_USER_POSTCOPY_END), + REQ(VHOST_USER_SET_VRING_INFLIGHT), REQ(VHOST_USER_MAX), }; #undef REQ @@ -890,6 +891,41 @@ vu_check_queue_msg_file(VuDev *dev, VhostUserMsg *vmsg) return true; } =20 +static int +vu_check_queue_inflights(VuDev *dev, VuVirtq *vq) +{ + int i =3D 0; + + if ((dev->protocol_features & + VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD) =3D=3D 0) { + return 0; + } + + if (unlikely(!vq->inflight.addr)) { + return -1; + } + + vq->used_idx =3D vq->vring.used->idx; + vq->inflight_num =3D 0; + for (i =3D 0; i < vq->vring.num; i++) { + if (vq->inflight.addr[i] =3D=3D 0) { + continue; + } + + vq->inflight_desc[vq->inflight_num++] =3D i; + vq->inuse++; + } + vq->shadow_avail_idx =3D vq->last_avail_idx =3D vq->inuse + vq->used_i= dx; + + /* in case of I/O hang after reconnecting */ + if (eventfd_write(vq->kick_fd, 1) || + eventfd_write(vq->call_fd, 1)) { + return -1; + } + + return 0; +} + static bool vu_set_vring_kick_exec(VuDev *dev, VhostUserMsg *vmsg) { @@ -925,6 +961,10 @@ vu_set_vring_kick_exec(VuDev *dev, VhostUserMsg *vmsg) dev->vq[index].kick_fd, index); } =20 + if (vu_check_queue_inflights(dev, &dev->vq[index])) { + vu_panic(dev, "Failed to check inflights for vq: %d\n", index); + } + return false; } =20 @@ -1215,6 +1255,44 @@ vu_set_postcopy_end(VuDev *dev, VhostUserMsg *vmsg) return true; } =20 +static bool +vu_set_vring_inflight(VuDev *dev, VhostUserMsg *vmsg) +{ + int fd; + uint32_t size, idx; + void *rc; + + if (vmsg->fd_num !=3D 1 || + vmsg->size !=3D sizeof(vmsg->payload.inflight)) { + vu_panic(dev, "Invalid vring_inflight message size:%d fds:%d", + vmsg->size, vmsg->fd_num); + return false; + } + + fd =3D vmsg->fds[0]; + idx =3D vmsg->payload.inflight.idx; + size =3D vmsg->payload.inflight.size; + DPRINT("vring_inflight idx: %"PRId32"\n", idx); + DPRINT("vring_inflight size: %"PRId32"\n", size); + + rc =3D mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + + close(fd); + + if (rc =3D=3D MAP_FAILED) { + vu_panic(dev, "vring_inflight mmap error: %s", strerror(errno)); + return false; + } + + if (dev->vq[idx].inflight.addr) { + munmap(dev->vq[idx].inflight.addr, dev->vq[idx].inflight.size); + } + dev->vq[idx].inflight.addr =3D (char *)rc; + dev->vq[idx].inflight.size =3D size; + + return false; +} + static bool vu_process_message(VuDev *dev, VhostUserMsg *vmsg) { @@ -1292,6 +1370,8 @@ vu_process_message(VuDev *dev, VhostUserMsg *vmsg) return vu_set_postcopy_listen(dev, vmsg); case VHOST_USER_POSTCOPY_END: return vu_set_postcopy_end(dev, vmsg); + case VHOST_USER_SET_VRING_INFLIGHT: + return vu_set_vring_inflight(dev, vmsg); default: vmsg_close_fds(vmsg); vu_panic(dev, "Unhandled request: %d", vmsg->request); @@ -1359,6 +1439,11 @@ vu_deinit(VuDev *dev) close(vq->err_fd); vq->err_fd =3D -1; } + + if (vq->inflight.addr) { + munmap(vq->inflight.addr, vq->inflight.size); + vq->inflight.addr =3D NULL; + } } =20 =20 @@ -1935,9 +2020,44 @@ vu_queue_map_desc(VuDev *dev, VuVirtq *vq, unsigned = int idx, size_t sz) return elem; } =20 +static int +vu_queue_inflight_get(VuDev *dev, VuVirtq *vq, int desc_idx) +{ + if ((dev->protocol_features & + VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD) =3D=3D 0) { + return 0; + } + + if (unlikely(!vq->inflight.addr)) { + return -1; + } + + vq->inflight.addr[desc_idx] =3D 1; + + return 0; +} + +static int +vu_queue_inflight_put(VuDev *dev, VuVirtq *vq, int desc_idx) +{ + if ((dev->protocol_features & + VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD) =3D=3D 0) { + return 0; + } + + if (unlikely(!vq->inflight.addr)) { + return -1; + } + + vq->inflight.addr[desc_idx] =3D 0; + + return 0; +} + void * vu_queue_pop(VuDev *dev, VuVirtq *vq, size_t sz) { + int i; unsigned int head; VuVirtqElement *elem; =20 @@ -1946,6 +2066,12 @@ vu_queue_pop(VuDev *dev, VuVirtq *vq, size_t sz) return NULL; } =20 + if (unlikely(vq->inflight_num > 0)) { + i =3D (--vq->inflight_num); + elem =3D vu_queue_map_desc(dev, vq, vq->inflight_desc[i], sz); + return elem; + } + if (vu_queue_empty(dev, vq)) { return NULL; } @@ -1974,6 +2100,8 @@ vu_queue_pop(VuDev *dev, VuVirtq *vq, size_t sz) =20 vq->inuse++; =20 + vu_queue_inflight_get(dev, vq, head); + return elem; } =20 @@ -2119,4 +2247,5 @@ vu_queue_push(VuDev *dev, VuVirtq *vq, { vu_queue_fill(dev, vq, elem, len, 0); vu_queue_flush(dev, vq, 1); + vu_queue_inflight_put(dev, vq, elem->index); } diff --git a/contrib/libvhost-user/libvhost-user.h b/contrib/libvhost-user/= libvhost-user.h index 4aa55b4d2d..2b0d14fd41 100644 --- a/contrib/libvhost-user/libvhost-user.h +++ b/contrib/libvhost-user/libvhost-user.h @@ -53,6 +53,7 @@ enum VhostUserProtocolFeature { VHOST_USER_PROTOCOL_F_CONFIG =3D 9, VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD =3D 10, VHOST_USER_PROTOCOL_F_HOST_NOTIFIER =3D 11, + VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD =3D 12, =20 VHOST_USER_PROTOCOL_F_MAX }; @@ -91,6 +92,7 @@ typedef enum VhostUserRequest { VHOST_USER_POSTCOPY_ADVISE =3D 28, VHOST_USER_POSTCOPY_LISTEN =3D 29, VHOST_USER_POSTCOPY_END =3D 30, + VHOST_USER_SET_VRING_INFLIGHT =3D 31, VHOST_USER_MAX } VhostUserRequest; =20 @@ -138,6 +140,11 @@ typedef struct VhostUserVringArea { uint64_t offset; } VhostUserVringArea; =20 +typedef struct VhostUserVringInflight { + uint32_t size; + uint32_t idx; +} VhostUserVringInflight; + #if defined(_WIN32) # define VU_PACKED __attribute__((gcc_struct, packed)) #else @@ -163,6 +170,7 @@ typedef struct VhostUserMsg { VhostUserLog log; VhostUserConfig config; VhostUserVringArea area; + VhostUserVringInflight inflight; } payload; =20 int fds[VHOST_MEMORY_MAX_NREGIONS]; @@ -234,9 +242,20 @@ typedef struct VuRing { uint32_t flags; } VuRing; =20 +typedef struct VuInflight { + char *addr; + uint32_t size; +} VuInflight; + typedef struct VuVirtq { VuRing vring; =20 + VuInflight inflight; + + uint16_t inflight_desc[VIRTQUEUE_MAX_SIZE]; + + uint16_t inflight_num; + /* Next head to pop */ uint16_t last_avail_idx; =20 --=20 2.17.1 From nobody Thu Apr 25 21:12:40 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=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544078353700470.18574312402495; Wed, 5 Dec 2018 22:39:13 -0800 (PST) Received: from localhost ([::1]:39096 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUnJY-0002pV-AV for importer@patchew.org; Thu, 06 Dec 2018 01:39:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUnHR-0001Xn-Aj for qemu-devel@nongnu.org; Thu, 06 Dec 2018 01:37:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gUnHP-0003bB-9J for qemu-devel@nongnu.org; Thu, 06 Dec 2018 01:37:01 -0500 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:35574) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gUnHL-0003YS-7O for qemu-devel@nongnu.org; Thu, 06 Dec 2018 01:36:57 -0500 Received: by mail-pl1-x641.google.com with SMTP id p8so11325221plo.2 for ; Wed, 05 Dec 2018 22:36:54 -0800 (PST) Received: from yongji-Ubuntu.internal.baidu.com ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id x186sm26175249pfb.59.2018.12.05.22.36.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Dec 2018 22:36:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dU/eUAUX7IkjZsgttuh1Gp6IYyyjhsKSGjoHIekrBvA=; b=VthW2pEyM0HU8hwrtNwVAdGkXDDAHPEjosPZzZHZzGymPlWjr7id4xwOVj7VFRnovJ NuhvpkVnDKfQyzskO5Rc4vXZHt1kPVfcor3XAwbW22I5/DUDRrbfePvGbh9WAGO/FqQN 0jTp8D5KPRZ2dxjUgX+apXkA+Ahq9ymKXDpvTfSAS2ex4MqOogFWpwt6leXjGEXkoGMF 4BTwCU8rGQzzYk2B6jUmBJKpy6wX+M3DKiKrh4i55YQ+PffX2pCHBxOTB08qDOSVpRg7 k7EuKS227C3b9mcy7VBFALj8mSw2Kj0GUU3086LFrY7hTJOtKTdvGgNfwEnWY2CaEa14 3neA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dU/eUAUX7IkjZsgttuh1Gp6IYyyjhsKSGjoHIekrBvA=; b=UYj4mKTCu6nN3q4FGc+jpnDh9+dJ9AvL83pQujOTGaeqNTV+45Wk5vDy/8LZTXF2n+ WnjlcCQPayr90cAj0Q7je1EBY5ph04PijBiVnrfOo4++aZ1m2/Duq4ykhlJo+Q/m6FZL 2yjVTirDGWJumAoCHXPP/Nel7WvheNrunQx5AIdMacI4J2UbCJQYuSLWm/GqLdqLJoB+ VXiSvyJo1cI9OtqyOmIbljEmt21GXbx6ittgDpOLDeS+3iUvukK2PKjW8ZwNy8P4+bHj kQM4i0uaug26VqHuWv1iLw7P9SSc0M24eppVMLsvRp2YpYxYzpLVzV877mPA3q+er663 nS1w== X-Gm-Message-State: AA+aEWbrFUa+v+O8mVi3c4wESUrhCSsaDUDRcvfzQS5WyovT9qgEsKO+ Q24TNzuU2AgRhv1WuZTpwrk= X-Google-Smtp-Source: AFSGD/VE8Q/0UEil6tIKqP0WYh6e/SIvp65U1LF8YpECkLRTCHqDeJJmaQJ0C2/vj95v5SFZQqYweg== X-Received: by 2002:a17:902:724a:: with SMTP id c10mr27826816pll.51.1544078213098; Wed, 05 Dec 2018 22:36:53 -0800 (PST) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, marcandre.lureau@redhat.com Date: Thu, 6 Dec 2018 14:35:51 +0800 Message-Id: <20181206063552.6701-6-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181206063552.6701-1-xieyongji@baidu.com> References: <20181206063552.6701-1-xieyongji@baidu.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH for-4.0 5/6] vhost-user-blk: Add support for reconnecting backend 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: nixun@baidu.com, qemu-devel@nongnu.org, lilin24@baidu.com, zhangyu31@baidu.com, chaiwen@baidu.com, Xie Yongji 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" From: Xie Yongji Since the new message VHOST_USER_SET_VRING_INFLIGHT, the backend is able to restart safely. This patch allow qemu to reconnect the backend after connection closed. Signed-off-by: Xie Yongji Signed-off-by: Ni Xun Signed-off-by: Zhang Yu --- hw/block/vhost-user-blk.c | 169 +++++++++++++++++++++++++++-- include/hw/virtio/vhost-user-blk.h | 4 + 2 files changed, 161 insertions(+), 12 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 1451940845..663e91bcf6 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -101,7 +101,7 @@ const VhostDevConfigOps blk_ops =3D { .vhost_dev_config_notifier =3D vhost_user_blk_handle_config_change, }; =20 -static void vhost_user_blk_start(VirtIODevice *vdev) +static int vhost_user_blk_start(VirtIODevice *vdev) { VHostUserBlk *s =3D VHOST_USER_BLK(vdev); BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); @@ -110,13 +110,13 @@ static void vhost_user_blk_start(VirtIODevice *vdev) =20 if (!k->set_guest_notifiers) { error_report("binding does not support guest notifiers"); - return; + return -ENOSYS; } =20 ret =3D vhost_dev_enable_notifiers(&s->dev, vdev); if (ret < 0) { error_report("Error enabling host notifiers: %d", -ret); - return; + return ret; } =20 ret =3D k->set_guest_notifiers(qbus->parent, s->dev.nvqs, true); @@ -140,12 +140,13 @@ static void vhost_user_blk_start(VirtIODevice *vdev) vhost_virtqueue_mask(&s->dev, vdev, i, false); } =20 - return; + return ret; =20 err_guest_notifiers: k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false); err_host_notifiers: vhost_dev_disable_notifiers(&s->dev, vdev); + return ret; } =20 static void vhost_user_blk_stop(VirtIODevice *vdev) @@ -164,7 +165,6 @@ static void vhost_user_blk_stop(VirtIODevice *vdev) ret =3D k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false); if (ret < 0) { error_report("vhost guest notifier cleanup failed: %d", ret); - return; } =20 vhost_dev_disable_notifiers(&s->dev, vdev); @@ -174,21 +174,39 @@ static void vhost_user_blk_set_status(VirtIODevice *v= dev, uint8_t status) { VHostUserBlk *s =3D VHOST_USER_BLK(vdev); bool should_start =3D status & VIRTIO_CONFIG_S_DRIVER_OK; + int ret; =20 if (!vdev->vm_running) { should_start =3D false; } =20 - if (s->dev.started =3D=3D should_start) { + if (s->should_start =3D=3D should_start) { + return; + } + + if (!s->connected || s->dev.started =3D=3D should_start) { + s->should_start =3D should_start; return; } =20 if (should_start) { - vhost_user_blk_start(vdev); + s->should_start =3D true; + /* make sure we ignore fake guest kick by + * vhost_dev_enable_notifiers() */ + barrier(); + ret =3D vhost_user_blk_start(vdev); + if (ret < 0) { + error_report("vhost-user-blk: vhost start failed: %s", + strerror(-ret)); + qemu_chr_fe_disconnect(&s->chardev); + } } else { vhost_user_blk_stop(vdev); + /* make sure we ignore fake guest kick by + * vhost_dev_disable_notifiers() */ + barrier(); + s->should_start =3D false; } - } =20 static uint64_t vhost_user_blk_get_features(VirtIODevice *vdev, @@ -218,13 +236,22 @@ static uint64_t vhost_user_blk_get_features(VirtIODev= ice *vdev, static void vhost_user_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq) { VHostUserBlk *s =3D VHOST_USER_BLK(vdev); - int i; + int i, ret; =20 if (!(virtio_host_has_feature(vdev, VIRTIO_F_VERSION_1) && !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1))) { return; } =20 + if (s->should_start) { + return; + } + s->should_start =3D true; + + if (!s->connected) { + return; + } + if (s->dev.started) { return; } @@ -232,7 +259,13 @@ static void vhost_user_blk_handle_output(VirtIODevice = *vdev, VirtQueue *vq) /* Some guests kick before setting VIRTIO_CONFIG_S_DRIVER_OK so start * vhost here instead of waiting for .set_status(). */ - vhost_user_blk_start(vdev); + ret =3D vhost_user_blk_start(vdev); + if (ret < 0) { + error_report("vhost-user-blk: vhost start failed: %s", + strerror(-ret)); + qemu_chr_fe_disconnect(&s->chardev); + return; + } =20 /* Kick right away to begin processing requests already in vring */ for (i =3D 0; i < s->dev.nvqs; i++) { @@ -245,6 +278,106 @@ static void vhost_user_blk_handle_output(VirtIODevice= *vdev, VirtQueue *vq) } } =20 +static void vhost_user_blk_reset(VirtIODevice *vdev) +{ + VHostUserBlk *s =3D VHOST_USER_BLK(vdev); + + if (s->vhost_user) { + vhost_user_inflight_reset(s->vhost_user); + } +} + +static int vhost_user_blk_connect(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserBlk *s =3D VHOST_USER_BLK(vdev); + int ret =3D 0; + + if (s->connected) { + return 0; + } + s->connected =3D true; + + s->dev.nvqs =3D s->num_queues; + s->dev.vqs =3D s->vqs; + s->dev.vq_index =3D 0; + s->dev.backend_features =3D 0; + + vhost_dev_set_config_notifier(&s->dev, &blk_ops); + + ret =3D vhost_dev_init(&s->dev, s->vhost_user, VHOST_BACKEND_TYPE_USER= , 0); + if (ret < 0) { + error_report("vhost-user-blk: vhost initialization failed: %s", + strerror(-ret)); + return ret; + } + + if (s->should_start && !s->dev.started) { + ret =3D vhost_user_blk_start(vdev); + if (ret < 0) { + error_report("vhost-user-blk: vhost start failed: %s", + strerror(-ret)); + return ret; + } + } + + return 0; +} + +static void vhost_user_blk_disconnect(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserBlk *s =3D VHOST_USER_BLK(vdev); + + if (!s->connected) { + return; + } + s->connected =3D false; + + if (s->dev.started) { + vhost_user_blk_stop(vdev); + } + + vhost_dev_cleanup(&s->dev); +} + +static gboolean vhost_user_blk_watch(GIOChannel *chan, GIOCondition cond, + void *opaque) +{ + DeviceState *dev =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserBlk *s =3D VHOST_USER_BLK(vdev); + + qemu_chr_fe_disconnect(&s->chardev); + + return true; +} + +static void vhost_user_blk_event(void *opaque, int event) +{ + DeviceState *dev =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserBlk *s =3D VHOST_USER_BLK(vdev); + + switch (event) { + case CHR_EVENT_OPENED: + if (vhost_user_blk_connect(dev) < 0) { + qemu_chr_fe_disconnect(&s->chardev); + return; + } + s->watch =3D qemu_chr_fe_add_watch(&s->chardev, G_IO_HUP, + vhost_user_blk_watch, dev); + break; + case CHR_EVENT_CLOSED: + vhost_user_blk_disconnect(dev); + if (s->watch) { + g_source_remove(s->watch); + s->watch =3D 0; + } + break; + } +} + static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -284,8 +417,13 @@ static void vhost_user_blk_device_realize(DeviceState = *dev, Error **errp) vhost_user_blk_handle_output); } =20 + s->vqs =3D g_new(struct vhost_virtqueue, s->num_queues); + s->watch =3D 0; + s->should_start =3D false; + s->connected =3D true; + s->dev.nvqs =3D s->num_queues; - s->dev.vqs =3D g_new(struct vhost_virtqueue, s->dev.nvqs); + s->dev.vqs =3D s->vqs; s->dev.vq_index =3D 0; s->dev.backend_features =3D 0; =20 @@ -309,6 +447,9 @@ static void vhost_user_blk_device_realize(DeviceState *= dev, Error **errp) s->blkcfg.num_queues =3D s->num_queues; } =20 + qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, vhost_user_blk_even= t, + NULL, (void *)dev, NULL, true); + return; =20 vhost_err: @@ -328,8 +469,11 @@ static void vhost_user_blk_device_unrealize(DeviceStat= e *dev, Error **errp) VHostUserBlk *s =3D VHOST_USER_BLK(dev); =20 vhost_user_blk_set_status(vdev, 0); + qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, NULL, + NULL, NULL, NULL, false); vhost_dev_cleanup(&s->dev); - g_free(s->dev.vqs); + + g_free(s->vqs); virtio_cleanup(vdev); =20 if (s->vhost_user) { @@ -379,6 +523,7 @@ static void vhost_user_blk_class_init(ObjectClass *klas= s, void *data) vdc->set_config =3D vhost_user_blk_set_config; vdc->get_features =3D vhost_user_blk_get_features; vdc->set_status =3D vhost_user_blk_set_status; + vdc->reset =3D vhost_user_blk_reset; } =20 static const TypeInfo vhost_user_blk_info =3D { diff --git a/include/hw/virtio/vhost-user-blk.h b/include/hw/virtio/vhost-u= ser-blk.h index d52944aeeb..560bb21459 100644 --- a/include/hw/virtio/vhost-user-blk.h +++ b/include/hw/virtio/vhost-user-blk.h @@ -37,6 +37,10 @@ typedef struct VHostUserBlk { uint32_t config_wce; struct vhost_dev dev; VhostUserState *vhost_user; + struct vhost_virtqueue *vqs; + guint watch; + bool should_start; + bool connected; } VHostUserBlk; =20 #endif --=20 2.17.1 From nobody Thu Apr 25 21:12:40 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=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544078505357829.1947420464707; Wed, 5 Dec 2018 22:41:45 -0800 (PST) Received: from localhost ([::1]:39112 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUnM0-0005MM-7I for importer@patchew.org; Thu, 06 Dec 2018 01:41:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUnHW-0001cT-Mo for qemu-devel@nongnu.org; Thu, 06 Dec 2018 01:37:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gUnHR-0003di-Iv for qemu-devel@nongnu.org; Thu, 06 Dec 2018 01:37:04 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:40888) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gUnHP-0003ZV-Sg for qemu-devel@nongnu.org; Thu, 06 Dec 2018 01:37:01 -0500 Received: by mail-pl1-x630.google.com with SMTP id u18so11311148plq.7 for ; Wed, 05 Dec 2018 22:36:57 -0800 (PST) Received: from yongji-Ubuntu.internal.baidu.com ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id x186sm26175249pfb.59.2018.12.05.22.36.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Dec 2018 22:36:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fo/iI2H+MPlzFNyjQ45gXFXk6RlXN6p3eD6WGRIUyeY=; b=X7IWaLpwtKfcvyYrMW83JAlyV9LqezQlM5RaS8FF6p/y+KXVAZfWYdbiZgRDsZhMsc KavA9uJlBCybgfi8H+S63uRBR4gvg7z6FumDxQCX/HS2a9GBmTLifZfmwQOmmjgVNGX5 dTJYDxiBd603o+y5nzG7D0zo4BkPvrue2BGpsiA/jrogQhm8Wg2de9OcIZg0oaKSWVKS 37WdOjpseRzUHOIIh//5J/Q1OEbNGKWgs1pdMO5K0jxSerTU1cuvZqJVroquMD18lGl5 zjwgb8qqHKFnqUXB4ehaZmxQ9ZMnFVrcwLlRPamWvigX0BlSViMSkWyBjTnXP7YyvnkG jHMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fo/iI2H+MPlzFNyjQ45gXFXk6RlXN6p3eD6WGRIUyeY=; b=i4VLzaK6TYz7ZCuc8kGsvmgNBmClQDHTBB9sMTrsOogl4QbfIvfZlWJPrrTci9i/51 4XsvW7dLBKpOgscAmooQ9GT3oB3oBxXosLkU8H7KE/mw+9nZlsBWGItJUxECKZi3Vdsk /8atA1MKcnnk2dau298DitEFPCuRZV8KWTC1Btw3ho+qPNsCpNmrJLLB1bs5xN14FrQc Gl4aQNmLK+eA/87j/cyf/UVz7Igr8s3UjcMAYvVgE2XdeEv+86M7biaEKhnA4VJiSLqB LhVa4HlGoLYXkxp1+A2ivXMFnoneOQn2RPtkMYwnLli90AoMt531/j2kk2UqQ0lrJbCS umsg== X-Gm-Message-State: AA+aEWYMzTKD+JI90wmdo8s1kGRzowXOMK9BfnxRV5QBn06AtqDQR7Om l1yOb6XmlB2Kg0A5vvquNxelChd69PA= X-Google-Smtp-Source: AFSGD/X5Fau1hyqHBamG6jPJ5FUhXfJMyGWs19nsKO5Hh6bZp5o1pDWuWPaAAyuOEz63smGvAPKM8A== X-Received: by 2002:a17:902:4c85:: with SMTP id b5mr25937391ple.226.1544078216605; Wed, 05 Dec 2018 22:36:56 -0800 (PST) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, marcandre.lureau@redhat.com Date: Thu, 6 Dec 2018 14:35:52 +0800 Message-Id: <20181206063552.6701-7-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181206063552.6701-1-xieyongji@baidu.com> References: <20181206063552.6701-1-xieyongji@baidu.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::630 Subject: [Qemu-devel] [PATCH for-4.0 6/6] contrib/vhost-user-blk: enable inflight I/O recording 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: nixun@baidu.com, qemu-devel@nongnu.org, lilin24@baidu.com, zhangyu31@baidu.com, chaiwen@baidu.com, Xie Yongji 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" From: Xie Yongji This patch tells qemu that we now support inflight I/O recording so that qemu could offer shared memory to it. Signed-off-by: Xie Yongji Signed-off-by: Zhang Yu --- contrib/vhost-user-blk/vhost-user-blk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-b= lk/vhost-user-blk.c index 571f114a56..f87f9de8cd 100644 --- a/contrib/vhost-user-blk/vhost-user-blk.c +++ b/contrib/vhost-user-blk/vhost-user-blk.c @@ -328,7 +328,8 @@ vub_get_features(VuDev *dev) static uint64_t vub_get_protocol_features(VuDev *dev) { - return 1ull << VHOST_USER_PROTOCOL_F_CONFIG; + return 1ull << VHOST_USER_PROTOCOL_F_CONFIG | + 1uLL << VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD; } =20 static int --=20 2.17.1