From patchwork Tue Jan 22 08:31:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 10775065 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 589C01390 for ; Tue, 22 Jan 2019 08:34:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 480A3205F8 for ; Tue, 22 Jan 2019 08:34:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3ACB526BE9; Tue, 22 Jan 2019 08:34:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AD027205F8 for ; Tue, 22 Jan 2019 08:34:04 +0000 (UTC) Received: from localhost ([127.0.0.1]:40662 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1glrVT-00016e-W0 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 22 Jan 2019 03:34:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46544) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1glrU4-0000EU-UN for qemu-devel@nongnu.org; Tue, 22 Jan 2019 03:32:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1glrTv-0002bK-Nc for qemu-devel@nongnu.org; Tue, 22 Jan 2019 03:32:34 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:36021) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1glrTv-0002Zl-GY for qemu-devel@nongnu.org; Tue, 22 Jan 2019 03:32:27 -0500 Received: by mail-pl1-x644.google.com with SMTP id g9so11124594plo.3 for ; Tue, 22 Jan 2019 00:32:24 -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:mime-version :content-transfer-encoding; bh=AUMaVkOp+Ffd7DLC1DU5SAbMi3SxvGUr4CMVF3FPgBc=; b=nM/iKgzYv7f3IO0KLlWVbUVw0d2uoV/pBahwLsU+k59N5r3eIvn10kCJsPME1LZkvc ZA2dEWjnencJyksD5JktouRnVkKbbquWeMyXA03w/8k/cLFRgJ9DKVGfqTIGrQDhOgZu 2WzX5O938Y2c7zZoD0qaGFw2FXbSrF03uzR9sh/cJGyer6ZzP4Zsc3IzlWn/gWspbe85 jWQyRldK7Y4qgXw3SP5nR0Fg62K1Sk0CTL3wVm/Vy1f4iYbbkuLqIpN2KKkiYyiqoAla C39OmRy5D/ffEc1tZnfM61W/yko7yBz6FzxJ8dnZRBWy0cDfCrQj0/NDc5V9WL+azUKa Lt6Q== 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:mime-version :content-transfer-encoding; bh=AUMaVkOp+Ffd7DLC1DU5SAbMi3SxvGUr4CMVF3FPgBc=; b=giDHVOfjpOhc5/YeCpyi386ZWAeG7ZydTcfunQwI3UIqp+e4M7p/rxXvZLnXOT3xZN GMAudgA7b/3gUceCYBJd63SeLX6z7zvEd1CXePSeYLrd0Gj/Uvd5v2alTf1yvE9agZqf E70375U/TANAqtq7vsfO+ok5G1yG0I3FABrNPxEuLOA+nLSYSjcQ0ii3tvoML5x3I13a 8PTolM+XdRDd6DGfkDkV8/Fj9JMz8oFNhnQP55B7RlAL1qIJMuDjwB5doKyxPKMXunb2 CsHtT1tS2CT04MBtF96/mydbLIZN5tj+GEcbbyxV5ZgrWGAsCUlc9WLt/DfAabxw8jfy /Wow== X-Gm-Message-State: AJcUukd+JcmqGJlJ48w7CE7rWS/v/eJ3bpPkX0Pi8I2obE0qMzd1p0Yl 5yFaQThKwwSE39Ry2Y2fVFo= X-Google-Smtp-Source: ALg8bN7l581mzo7PzXtX77/CvM7OrW5dA1qulawWqjqKo91Uv5rh52Ncl2UMTwI00T9NUPSxbFqabg== X-Received: by 2002:a17:902:4d46:: with SMTP id o6mr31973763plh.302.1548145943631; Tue, 22 Jan 2019 00:32:23 -0800 (PST) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id b5sm29863886pfc.150.2019.01.22.00.32.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Jan 2019 00:32:23 -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: Tue, 22 Jan 2019 16:31:46 +0800 Message-Id: <20190122083152.10705-1-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 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 v5 0/6] 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 support transferring shared buffer between qemu and backend. The patch 2,3 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 4 allows vhost-user-blk to use the two new messages to get/set inflight buffer from/to backend. The patch 5 supports vhost-user-blk to reconnect backend when connection closed. The patch 6 introduces VHOST_USER_PROTOCOL_F_SLAVE_SHMFD to vhost-user-blk backend which is used to tell qemu that we support reconnecting now. This series is based on Daniel P. Berrangé's patchset: https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg03344.html 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. 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 (6): vhost-user: Support transferring inflight buffer between qemu and backend 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 | 402 ++++++++++++++++++++---- contrib/libvhost-user/libvhost-user.h | 40 +++ contrib/vhost-user-blk/vhost-user-blk.c | 3 +- docs/interop/vhost-user.txt | 101 ++++++ hw/block/vhost-user-blk.c | 227 ++++++++++--- hw/virtio/vhost-user.c | 110 +++++++ hw/virtio/vhost.c | 105 +++++++ include/hw/virtio/vhost-backend.h | 10 + include/hw/virtio/vhost-user-blk.h | 5 + include/hw/virtio/vhost.h | 19 ++ 11 files changed, 925 insertions(+), 99 deletions(-)