From patchwork Thu Feb 28 08:53:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 1049337 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="khJDxpdM"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4495yv4Rhhz9s4Z for ; Thu, 28 Feb 2019 19:57:10 +1100 (AEDT) Received: from localhost ([127.0.0.1]:34533 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzHV6-0001bk-VV for incoming@patchwork.ozlabs.org; Thu, 28 Feb 2019 03:57:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzHT7-0000VJ-7v for qemu-devel@nongnu.org; Thu, 28 Feb 2019 03:55:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzHT5-0004Na-Qt for qemu-devel@nongnu.org; Thu, 28 Feb 2019 03:55:05 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:42525) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzHT3-0004H9-Ae for qemu-devel@nongnu.org; Thu, 28 Feb 2019 03:55:03 -0500 Received: by mail-pl1-x644.google.com with SMTP id v11so4005290plg.9 for ; Thu, 28 Feb 2019 00:54:40 -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; bh=c3XHrdzLdJfdkEc3JFoEXrVhSEdEEAhO7N3/HM2GJbc=; b=khJDxpdMoijRlu3WhY+5W0rJQBn2hoLCAdJormSw1t6gUXKy9H8FmsXky8xRvbIqpy oOxb28r+oPrtKVJyQO5wyclG9Bfk00GZyecGc4pRj5bSTK4PpJELOvKGg3RRcUvFj53b IcnTZArLKps8/dz1NtauGCRqeplW95jF+Yw7uOYk0VP0Whn0of61NHGASEjEkd3ig9MY mfYnqL5Y7ISh8Nm0+Wc92iW/GY3og60mMckQPR0m03SNK0RS9C/pnAyThnq0aqb8cVQJ H/j++BTmq5OUpuqu1nzk0Tz2rJA+96WGvASBvnAhstyp8cg63+ks9aH6uX/jICDtwxPd Yu0A== 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; bh=c3XHrdzLdJfdkEc3JFoEXrVhSEdEEAhO7N3/HM2GJbc=; b=jLolj+PgigCUsgi56RMIczzx6Xp7HtZ2ZrRv4IAsAS0T4hV8gmyiXpmDcHUMEYIVZI teml+AtEZzKCuFFQNNflDsGUAQJszRzGwUjDxRtW7AQNSFk8Ns9X4BDCQ4nkM54S1UCU qW6G0cv0immDNL2X8t2tdbIqsdRKDz8wRAmc+aOhRSRwcIMRgM8q15zmLyBxaUhesC6n 6eosWR1h96fj7hAhZ1IHIhzj/7mh22cMEPKk+nqY1pFMqSOz4CrSjjWDR3CIazkRgTBc H2WiQr7Cg0pX6fa+0IvSWDuMRHdWJZz9lc8RDvz6BHzCkoIStWjEjsTKAPzuzFbugamA ufxQ== X-Gm-Message-State: AHQUAuZ1Zk8EdnKNcBHobIXy9MZaQGMwKqAu4u38pgZTHvfojQ5elA/f 9Eh9IfP3qL/PE45lyRgZrhU= X-Google-Smtp-Source: AHgI3IYp4JCh5ScsIbKi/tiTuXCNxGjJFHE+OuuypkExMVT0APaECCSftmAFS6YxPZOsLbxlS8Kc4A== X-Received: by 2002:a17:902:2e03:: with SMTP id q3mr7015467plb.330.1551344078836; Thu, 28 Feb 2019 00:54:38 -0800 (PST) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id z127sm34904522pfb.80.2019.02.28.00.54.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 00:54:38 -0800 (PST) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, stefanha@gmail.com, marcandre.lureau@redhat.com, berrange@redhat.com, jasowang@redhat.com, maxime.coquelin@redhat.com, yury-kotov@yandex-team.ru, wrfsh@yandex-team.ru Date: Thu, 28 Feb 2019 16:53:48 +0800 Message-Id: <20190228085355.9614-1-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 Subject: [Qemu-devel] [PATCH v7 0/7] vhost-user-blk: Add support for backend reconnecting 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Xie Yongji This patchset is aimed at supporting qemu to reconnect vhost-user-blk backend after vhost-user-blk backend crash or restart. The patch 1 introduces two new messages VHOST_USER_GET_INFLIGHT_FD and VHOST_USER_SET_INFLIGHT_FD to support transferring shared buffer between qemu and backend. The patch 2 deletes some redundant check in contrib/libvhost-user.c. The patch 3,4 are the corresponding libvhost-user patches of patch 1. Make libvhost-user support VHOST_USER_GET_INFLIGHT_FD and VHOST_USER_SET_INFLIGHT_FD. The patch 5 allows vhost-user-blk to use the two new messages to get/set inflight buffer from/to backend. The patch 6 supports vhost-user-blk to reconnect backend when connection closed. The patch 7 introduces VHOST_USER_PROTOCOL_F_SLAVE_SHMFD to vhost-user-blk backend which is used to tell qemu that we support reconnecting now. To use it, we could start qemu with: qemu-system-x86_64 \ -chardev socket,id=char0,path=/path/vhost.socket,reconnect=1, \ -device vhost-user-blk-pci,chardev=char0 \ and start vhost-user-blk backend with: vhost-user-blk -b /path/file -s /path/vhost.socket Then we can restart vhost-user-blk at any time during VM running. V6 to V7: - Introduce a 64-bit counter to struct DescStateSplit/DescStatePacked to preserve the order of fetching available descriptors - Add support to resubmit inflight I/O in order in libvhost-user.c - Rename process_head to last_batch_head in struct DescStateSplit V5 to V6: - Document the layout in inflight buffer for packed virtqueue - Rework the layout in inflight buffer for split virtqueue - Remove version field in VhostUserInflight - Add a patch to remove some redundant check in contrib/libvhost-user.c - Document more details in vhost-user.txt V4 to V5: - Drop patch that enables "nowait" option on client sockets - Support resubmitting inflight I/O in order - Make inflight I/O tracking more robust - Remove align field and add queue size field in VhostUserInflight - Document more details in vhost-user.txt V3 to V4: - Drop messages VHOST_USER_GET_SHM_SIZE and VHOST_USER_SET_SHM_FD - Introduce two new messages VHOST_USER_GET_INFLIGHT_FD and VHOST_USER_SET_INFLIGHT_FD - Allocate inflight buffer in backend rather than in qemu - Document a recommended format for inflight buffer V2 to V3: - Using exisiting wait/nowait options to control connection on client sockets instead of introducing "disconnected" option. - Support the case that vhost-user backend restart during initialzation of vhost-user-blk device. V1 to V2: - Introduce "disconnected" option for chardev instead of reuse "wait" option - Support the case that QEMU starts before vhost-user backend - Drop message VHOST_USER_SET_VRING_INFLIGHT - Introduce two new messages VHOST_USER_GET_SHM_SIZE and VHOST_USER_SET_SHM_FD Xie Yongji (7): vhost-user: Support transferring inflight buffer between qemu and backend libvhost-user: Remove unnecessary FD flag check for event file descriptors libvhost-user: Introduce vu_queue_map_desc() libvhost-user: Support tracking inflight I/O in shared memory vhost-user-blk: Add support to get/set inflight buffer vhost-user-blk: Add support to reconnect backend contrib/vhost-user-blk: enable inflight I/O tracking Makefile | 2 +- contrib/libvhost-user/libvhost-user.c | 449 ++++++++++++++++++++---- contrib/libvhost-user/libvhost-user.h | 70 ++++ contrib/vhost-user-blk/vhost-user-blk.c | 3 +- docs/interop/vhost-user.txt | 285 +++++++++++++++ hw/block/vhost-user-blk.c | 229 +++++++++--- hw/virtio/vhost-user.c | 107 ++++++ hw/virtio/vhost.c | 96 +++++ include/hw/virtio/vhost-backend.h | 10 + include/hw/virtio/vhost-user-blk.h | 5 + include/hw/virtio/vhost.h | 18 + 11 files changed, 1166 insertions(+), 108 deletions(-)