From patchwork Wed Mar 20 11:26:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 10861409 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 2E36815AC for ; Wed, 20 Mar 2019 11:28:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D0FA29B4E for ; Wed, 20 Mar 2019 11:28:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F26E029B50; Wed, 20 Mar 2019 11:28:28 +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 8CAF029B4E for ; Wed, 20 Mar 2019 11:28:28 +0000 (UTC) Received: from localhost ([127.0.0.1]:46399 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6ZOV-0008R7-7T for patchwork-qemu-devel@patchwork.kernel.org; Wed, 20 Mar 2019 07:28:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6ZNT-0007hF-F6 for qemu-devel@nongnu.org; Wed, 20 Mar 2019 07:27:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6ZNS-0003la-Bv for qemu-devel@nongnu.org; Wed, 20 Mar 2019 07:27:23 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:42410) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6ZNR-0003kD-Vb for qemu-devel@nongnu.org; Wed, 20 Mar 2019 07:27:22 -0400 Received: by mail-pf1-x442.google.com with SMTP id r15so1715740pfn.9 for ; Wed, 20 Mar 2019 04:27:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=gLhI16M39erL8EB2bMqrFCidFOhi5LvDnG4hZwXnvzY=; b=L1O5XxCaRRj1AZZHMxKfQm98bIMmjbmTnLusUr6JD7U7iE2TITg8ziSrd+skG5I8oO 3233JMX3IW1a0L8d8qnsV+vD71SBqlZNsQojB8xPRQx6aNweyxi/o6mL04nL3pPD/xbN k9vSs/b5QhcSVJ819/j6Fa+eoqQJpYexvuGoI9k+EHNp3eQV/uKIbRKxWzkrkBrQ487T Kdyh61imyTmU3Nc/kFETiRKLVDn0SH+OZbZpw853adOCrA1JnjGvxo4Chj+Sx9zfLHiz EIuiTCgalAuYCNJoYZnQ0Fk/qaekTkuytrbWlZHH0z+ctRitM5HAy8A1e45eVD5MZ+SS H7sg== 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=gLhI16M39erL8EB2bMqrFCidFOhi5LvDnG4hZwXnvzY=; b=shoDTuSNmh4sNebBFGAxzXLUI4YGbIf4DQl/bD6xnA1ypQO37h6PEq6OqctWsjYBAt FCgXoXcuFFfAw3km3B0MfIm6IXb9fJNDiDJUgI/7o8RjocX+EufwDA5hwEkObgYpB8WE ksUhxgOq6Ur0AM8ziznWfO+xTbDXXhvr9dQcJ0ZF/5R9RSHSOJgbNLAqY17nNGIOUxH3 wpjF3CjZuuxaILUwUxfALQXslGK6s4qghuSg5b6jYf09rhvRGmb/NPbFfSFIYkaM2QDU GWXR2dPnM72jmNBvjskSrxeWIj6PFT4n2lT6Hlee6FPtDj0y2cEp1ktUtU8fiPyEQVvK R67g== X-Gm-Message-State: APjAAAUHbZ4UzB5zHUKCOnLgDUs+MgwG9gR3lFk5E/MrDDldmFduR0Wk tvA8ckddVgVSLOFIV05Bn6A= X-Google-Smtp-Source: APXvYqyrfS3d3LyA8M6idTDLok19cUQ+KUMad6rZf4RDmWWatzP5iDePqmirWKpmbMRfAd+PTXn/MQ== X-Received: by 2002:a63:6605:: with SMTP id a5mr7327420pgc.372.1553081240324; Wed, 20 Mar 2019 04:27:20 -0700 (PDT) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id d11sm4586284pfh.29.2019.03.20.04.27.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Mar 2019 04:27:19 -0700 (PDT) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, kwolf@redhat.com, mreitz@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, changpeng.liu@intel.com Date: Wed, 20 Mar 2019 19:26:39 +0800 Message-Id: <20190320112646.3712-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::442 Subject: [Qemu-devel] [PATCH v8 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,2,3 introduce started flag to VirtioDevice to fix possible guest hung after migration for virtio 1.0 transitional devices. The patch 4,5,6 support 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. v8: - Remove merged vhost-user part - Introduce started flag to VirtioDevice to fix some bugs - Rework reconnect logic in vhost_user_blk_device_realize() 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 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 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 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 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. 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): virtio: Introduce started flag to VirtioDevice virtio: Use started flag in virtio_vmstate_change() vhost-user-blk: Use started flag in vhost_user_blk_set_status() vhost-user-blk: Only start vhost-user backend with the first kick vhost-user-blk: Add return value for vhost_user_blk_start() vhost-user-blk: Add support to reconnect backend contrib/vhost-user-blk: enable inflight I/O tracking contrib/vhost-user-blk/vhost-user-blk.c | 3 +- hw/block/vhost-user-blk.c | 175 +++++++++++++++++++----- hw/virtio/virtio.c | 54 +++++++- include/hw/virtio/vhost-user-blk.h | 3 + include/hw/virtio/virtio.h | 2 + 5 files changed, 202 insertions(+), 35 deletions(-)