From patchwork Wed Jan 9 11:27:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 10753877 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 5899614E5 for ; Wed, 9 Jan 2019 11:28:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3911B27F90 for ; Wed, 9 Jan 2019 11:28:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 271CC2852D; Wed, 9 Jan 2019 11:28:59 +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 B459527F90 for ; Wed, 9 Jan 2019 11:28:58 +0000 (UTC) Received: from localhost ([127.0.0.1]:34733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghC2c-0001gW-2J for patchwork-qemu-devel@patchwork.kernel.org; Wed, 09 Jan 2019 06:28:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghC1T-0000hV-Gb for qemu-devel@nongnu.org; Wed, 09 Jan 2019 06:27:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghC1S-0004CG-Nc for qemu-devel@nongnu.org; Wed, 09 Jan 2019 06:27:47 -0500 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:44004) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ghC1S-0004Am-Hf for qemu-devel@nongnu.org; Wed, 09 Jan 2019 06:27:46 -0500 Received: by mail-pf1-x444.google.com with SMTP id w73so3515904pfk.10 for ; Wed, 09 Jan 2019 03:27: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; bh=hqHHWrfMlyOm+n5U1xJpaJlB4k2VggO75NW38erPuSo=; b=XyT/aWIGwS3iGw+OzwS0LK71H5GTDn4Ms2GCTjSI1P6QQygihTrbyT12aQ5jKMlfJo BTNNc5zEchp12UPnIRAdB6ADpXOodaNkx5NNnNG0E3Y8Pg2lPz6GbjX+KHJsqMaK6PoR sWaXulLmRwtITDGNmykNpGMONGLSXFtbw5IYOK8l4pnO93ZmqUThs9R0sS15DOa/rkaQ FZxFP1xLWDl8Gn5Q1cjmQT9rel1EzhwNUFKnagmlZxDW4hMer1avdUeZ23N237eLxpab x4SI8+CYOLIFqAlGul74kFc0ZFuQ0/+ImeeG/LYAhRm/jpDZerZ6sglcdGyIjcWPPMno 9fPg== 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=hqHHWrfMlyOm+n5U1xJpaJlB4k2VggO75NW38erPuSo=; b=i5bw/bAxRIdfL7/B7VnTdiSu2hWsy/4KZoZi1zvhYPmt0ZD1GJCJbR6EI4incqICRQ LLUHi33wz9RWR0Gh9CHPbMEEcec/SzscR/sQQFeOL92vYAjjZBU5jwM42c5UYGyMsXEA jKHGB+bMBCnO2e30RYnbN4tWbdPB1c8XbLGvJLpGmHi4pyOdVwqug83gh88gTr5jDek7 wPOBvRc4hmndQ4Qx8krDM0kLWnZvuba4pkYwVeu6JPY2cNXtvR5AawagthuRDIWfaj0W Rx85fnw5aM7k2vLxFeumabsePVOIQY60BKQLYSIwS0r69Xj3N5a7Btgkf3epuu+4wLhL tRhA== X-Gm-Message-State: AJcUukfElJAOZaarcIy3wANV2SPvZye/o8859/MsEd2Xc9M4pDStfwLi nevoJL8jAPdCvCfcVbkxEfs= X-Google-Smtp-Source: ALg8bN4iwnvBewgLzd9E97s4L2or7bjupV5Agt0fNkYnSYVhMYErfECyD/vlNA1nCaWfbrlN3ETZRA== X-Received: by 2002:a63:2643:: with SMTP id m64mr4932470pgm.35.1547033264892; Wed, 09 Jan 2019 03:27:44 -0800 (PST) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id e123sm88829092pgc.58.2019.01.09.03.27.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 Jan 2019 03:27:44 -0800 (PST) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.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: Wed, 9 Jan 2019 19:27:21 +0800 Message-Id: <20190109112728.9214-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::444 Subject: [Qemu-devel] [PATCH v4 for-4.0 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+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 uses exisiting wait/nowait options to make QEMU not do a connect on client sockets during initialization of the chardev. The patch 2 introduces two new messages VHOST_USER_GET_INFLIGHT_FD and VHOST_USER_SET_INFLIGHT_FD to support providing shared memory to backend. The patch 3,4 are the corresponding libvhost-user patches of patch 2. 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,nowait,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. 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): char-socket: Enable "nowait" option on client sockets 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 +- chardev/char-socket.c | 56 ++-- contrib/libvhost-user/libvhost-user.c | 346 ++++++++++++++++++++---- contrib/libvhost-user/libvhost-user.h | 29 ++ contrib/vhost-user-blk/vhost-user-blk.c | 3 +- docs/interop/vhost-user.txt | 60 ++++ hw/block/vhost-user-blk.c | 223 ++++++++++++--- hw/virtio/vhost-user.c | 108 ++++++++ hw/virtio/vhost.c | 108 ++++++++ include/hw/virtio/vhost-backend.h | 9 + include/hw/virtio/vhost-user-blk.h | 5 + include/hw/virtio/vhost.h | 19 ++ qapi/char.json | 3 +- qemu-options.hx | 9 +- 14 files changed, 851 insertions(+), 129 deletions(-)