From patchwork Wed Mar 20 11:26:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 10861413 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 986FA15AC for ; Wed, 20 Mar 2019 11:28:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7ADEF29B4E for ; Wed, 20 Mar 2019 11:28:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E80A29B50; Wed, 20 Mar 2019 11:28:48 +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 1DAD129B4E for ; Wed, 20 Mar 2019 11:28:47 +0000 (UTC) Received: from localhost ([127.0.0.1]:46403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6ZOp-0000FV-6G for patchwork-qemu-devel@patchwork.kernel.org; Wed, 20 Mar 2019 07:28:47 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6ZNf-0007nN-5R for qemu-devel@nongnu.org; Wed, 20 Mar 2019 07:27:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6ZNe-0003rn-Ap for qemu-devel@nongnu.org; Wed, 20 Mar 2019 07:27:35 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:37534) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6ZNd-0003rf-V6 for qemu-devel@nongnu.org; Wed, 20 Mar 2019 07:27:34 -0400 Received: by mail-pf1-x443.google.com with SMTP id 8so1735254pfr.4 for ; Wed, 20 Mar 2019 04:27:33 -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:in-reply-to:references; bh=V+tk2Ez3eDPbL7SQZx8XRpdn5sQlO+TtF+TNfF2ImnU=; b=VBXDZcBj2r1uL6in6yls+DhgFaQYfIHxy+KKCbI5I9lAo5RlL0fR51B7cbniVC7X+8 hHdyN9lUPCFvzmdgSv8xC61l3ijNRVGe7RpA7pUfMDcPRVtDN9+5xlmabjPUitmkIHTB Jjt2eegb3zYWWE1fMiet60fSTgiA3QAtm2EG0ee+Z1ZAYbITXWlF9T1u2W1+rQsIOhgI yWtcgCPtN4ndP/olR1x2jakdb5AKiGmCSnLxZ+UIuZS8tRcEW+KdurBmQCKRdJ3Dhbbc 5UjEvV2GkUPMybGnWykA2LVeHz496jCcBoGGJqyAgoPX5tvvBKGouIKp1IrDDKPORt5B 2RJg== 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:in-reply-to :references; bh=V+tk2Ez3eDPbL7SQZx8XRpdn5sQlO+TtF+TNfF2ImnU=; b=kePfyimJ58TzB7bwCmOYrfbF3xsWf8HA/Uj2FJKtJgAJSlmYdD1f0YrKNLGv8LWtY4 iyw4/evnF/9OQGJSzmQ6x/qxnF8FEPwH8YfFB8cWWMIeF2tQhA5tbU78Tz/xiMq1+H9O mM0GUSY4xdf0Ra72JQIKnSKvdDq+Wa6Xnrgaae/kZK0ypxN8VN7DjZJIXJfVy+uuI9YD vpYiBjD3mnDNRnEcx3Fg+5LC/sBCLY7lZ7BgCio01PrCLL+z4HFCv5tyRvoso3+bBhgn yD3KK/9r+IakcKPiZ4197Gzo6CHQ9hKNgj8MmY1ba40FzkFPAhk9GW/9LMRaBVn3CbfQ BKJw== X-Gm-Message-State: APjAAAVLU9uQmgYI1nPmAsCnjTS8No885YOzdQMhRr8vo2+1u0ZU5NqY jITemB6jEybyRhyGvVYNVs8= X-Google-Smtp-Source: APXvYqxdeVIZXRaGyBAUyhuCusq89yvfaFVPTVC8A4QDOpyjkGua3sTFvG4TSEpBWRmnfqZ9JwZdGw== X-Received: by 2002:a63:fd12:: with SMTP id d18mr27115045pgh.88.1553081253129; Wed, 20 Mar 2019 04:27:33 -0700 (PDT) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id o5sm6722720pgc.16.2019.03.20.04.27.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Mar 2019 04:27:32 -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:42 +0800 Message-Id: <20190320112646.3712-4-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190320112646.3712-1-xieyongji@baidu.com> References: <20190320112646.3712-1-xieyongji@baidu.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH v8 3/7] vhost-user-blk: Use started flag in vhost_user_blk_set_status() 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 Use started flag in vhost_user_blk_set_status() to decide if starting vhost-user backend or not. Signed-off-by: Xie Yongji Signed-off-by: Zhang Yu --- hw/block/vhost-user-blk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 28b81368f7..700c1dd111 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -190,7 +190,7 @@ static void vhost_user_blk_stop(VirtIODevice *vdev) static void vhost_user_blk_set_status(VirtIODevice *vdev, uint8_t status) { VHostUserBlk *s = VHOST_USER_BLK(vdev); - bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; + bool should_start = vdev->started; if (!vdev->vm_running) { should_start = false; @@ -350,7 +350,7 @@ static void vhost_user_blk_device_unrealize(DeviceState *dev, Error **errp) VHostUserBlk *s = VHOST_USER_BLK(dev); struct vhost_virtqueue *vqs = s->dev.vqs; - vhost_user_blk_set_status(vdev, 0); + virtio_set_status(vdev, 0); vhost_dev_cleanup(&s->dev); vhost_dev_free_inflight(s->inflight); g_free(vqs);