From patchwork Tue Jun 5 13:56:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 10448409 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D33EB600CA for ; Tue, 5 Jun 2018 14:00:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B080129515 for ; Tue, 5 Jun 2018 14:00:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD4A329573; Tue, 5 Jun 2018 14:00:23 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DCE932955D for ; Tue, 5 Jun 2018 14:00:20 +0000 (UTC) Received: from localhost ([::1]:46959 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQCVX-0008RG-Sw for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Jun 2018 10:00:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35644) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQCUj-0007pj-J3 for qemu-devel@nongnu.org; Tue, 05 Jun 2018 09:59:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQCUe-0001W8-8i for qemu-devel@nongnu.org; Tue, 05 Jun 2018 09:59:29 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:36866) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQCUe-0001Vk-2G for qemu-devel@nongnu.org; Tue, 05 Jun 2018 09:59:24 -0400 Received: by mail-pg0-x243.google.com with SMTP id r21-v6so946183pgv.4 for ; Tue, 05 Jun 2018 06:59:23 -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=AytO19bXgKyXRNMLnGwdLEp4orjMUWUrdCc/+wO7+KM=; b=HTjaCRxSKbdfsMPrqoM27IojefrRtnA1nhwFkf97EJqm1QlXiPgCYVOBY/WysddAjz Q5P07IaWkty2Sbwa64851oIrKXJ3iSPIWFI4DMfCqj25OJKRyIZ/RcOvd4CE0nPlxqAG AYV/wFOYhw+wGkKLl8GuBuSX1ad3B61rq8vz4VMTXITpVif6+ZBACD06nPzyT4AuCCYD iv6MRiddA7ib4IuaG0fUVPOo/44hMULuK0VI8jLqo/nLyBkju4+5Bbga0qQ+HGx+NyQi dKjPXpSuNd0UGHX5jYbB+8oYwhRqMLC2py4IQCWjeA+oxYc93l+KngYVA+bByXZMZMCs 394Q== 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=AytO19bXgKyXRNMLnGwdLEp4orjMUWUrdCc/+wO7+KM=; b=cV/fvQ6Gg0D/4BUdw5IjAFul6D0K4m24/JOj/xRzgxapMXgnK0YQGjAQhP3PH4MSW5 eP3PD+B9B+JT+0ja/iR6r+q2KBqLyyaoFCxnlpCfn3EySv0GuNPu2Z5ZSJ4OJujJgDGB 6T/q2hrtgt0XbIGwt0Wa6K1y++I3VyK5JM1ef3m1/TFhbvE8i/4Q4flbhH2Bw3RO/BYq 4c9Sc6fZTL443adtyZsujSAr99vSUvDISdr2UC/YPu2c1CkXD8ek4a8z3rDpVMlTmRjE Fnz/yZn42iHJl0npDH9wcmDF8kO5BU5i/U92ED7GKKFWxn1gHHx30sXGvAboO2hWcPH7 yXOQ== X-Gm-Message-State: ALKqPwcJMWWkD4y0bpKgRPY27lHUuTBIwx43JmyK7SLCZLUK030eWnsW JODlq4UDAimJv3RqQyl7gDE= X-Google-Smtp-Source: ADUXVKLbleZ2Z2rCEjfj2dN0PvrQ5MqsfHepuEX075k+y1Q6JHfuHeyfph4seNSUL9rIAbNSPbD02g== X-Received: by 2002:a63:a119:: with SMTP id b25-v6mr15900240pgf.279.1528207162963; Tue, 05 Jun 2018 06:59:22 -0700 (PDT) Received: from localhost ([61.171.230.176]) by smtp.gmail.com with ESMTPSA id k84-v6sm66711759pfh.110.2018.06.05.06.59.21 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 05 Jun 2018 06:59:22 -0700 (PDT) From: Yongji Xie X-Google-Original-From: Yongji Xie To: mst@redhat.com, stefanha@redhat.com, changpeng.liu@intel.com Date: Tue, 5 Jun 2018 21:56:10 +0800 Message-Id: <1528206970-4815-1-git-send-email-xieyongji@baidu.com> X-Mailer: git-send-email 1.7.9.5 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH] vhost-user-blk: start vhost when guest kicks 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: elohimes@gmail.com, nixun@baidu.com, qemu-devel@nongnu.org, chaiwen@baidu.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Some old guests (before commit 7a11370e5: "virtio_blk: enable VQs early") kick virtqueue before setting VIRTIO_CONFIG_S_DRIVER_OK. This would cause that those old guests fail to boot with vhost-user-blk device. To fix it, start vhost when guest kicks instead of waiting for .set_status(). Signed-off-by: Yongji Xie Signed-off-by: Chai Wen Signed-off-by: Ni Xun --- hw/block/vhost-user-blk.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index d755223..8fd0e6f 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -217,7 +217,27 @@ static uint64_t vhost_user_blk_get_features(VirtIODevice *vdev, static void vhost_user_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq) { + VHostUserBlk *s = VHOST_USER_BLK(vdev); + int i; + if (s->dev.started) { + return; + } + + /* 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); + + /* Kick right away to begin processing requests already in vring */ + for (i = 0; i < s->dev.nvqs; i++) { + VirtQueue *kick_vq = virtio_get_queue(vdev, i); + + if (!virtio_queue_get_desc_addr(vdev, i)) { + continue; + } + event_notifier_set(virtio_queue_get_host_notifier(kick_vq)); + } } static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)