From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:35254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGNga-00064O-7E for qemu-devel@nongnu.org; Tue, 16 Apr 2019 08:59:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGNgY-00022c-3s for qemu-devel@nongnu.org; Tue, 16 Apr 2019 08:59:40 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37994) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGNgX-00021t-Pf for qemu-devel@nongnu.org; Tue, 16 Apr 2019 08:59:38 -0400 From: Liran Alon Date: Tue, 16 Apr 2019 15:59:10 +0300 Message-Id: <20190416125912.44001-2-liran.alon@oracle.com> In-Reply-To: <20190416125912.44001-1-liran.alon@oracle.com> References: <20190416125912.44001-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v2 1/3] vhost-scsi: The vhost backend should be stopped when the VM is not running List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, mtosatti@redhat.com, rth@twiddle.net, ehabkost@redhat.com, stefanha@gmail.com, nir.weiner@oracle.com, bijan.mottahedeh@oracle.com, Liran Alon From: Nir Weiner vhost-scsi doesn=E2=80=99t takes into account whether the VM is running o= r not in order to decide if it should start/stop vhost backend. This would lead to vhost backend still being active when VM's RunState suddenly change to stopped. An example of when this issue is encountered is when Live-Migration Pre-C= opy phase completes. As in this case, VM state will be changed to stopped (wh= ile vhost backend is still active), which will result in virtio_vmstate_change() -> virtio_set_status() -> vhost_scsi_set_status() executed but vhost_scsi_set_status() will just return without stopping vhost backend. To handle this, change code to consider that vhost processing should be stopped when VM is not running. Similar to how it is done in vhost-vsock device at vhost_vsock_set_status(). Fixes: 5e9be92d7752 ("vhost-scsi: new device supporting the tcm_vhost Lin= ux kernel module=E2=80=9D) Reviewed-by: Bijan Mottahedeh Reviewed-by: Liran Alon Signed-off-by: Nir Weiner --- hw/scsi/vhost-scsi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 61e2e57da9d5..ca42cff1b907 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -114,6 +114,10 @@ static void vhost_scsi_set_status(VirtIODevice *vdev= , uint8_t val) VHostSCSICommon *vsc =3D VHOST_SCSI_COMMON(s); bool start =3D (val & VIRTIO_CONFIG_S_DRIVER_OK); =20 + if (!vdev->vm_running) { + start =3D false; + } + if (vsc->dev.started =3D=3D start) { return; } --=20 2.20.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.7 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0A13C10F13 for ; Tue, 16 Apr 2019 13:24:02 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 97DB92064A for ; Tue, 16 Apr 2019 13:24:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="IxTpEU+1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 97DB92064A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([127.0.0.1]:36733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGO49-0008NC-M9 for qemu-devel@archiver.kernel.org; Tue, 16 Apr 2019 09:24:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGNga-00064O-7E for qemu-devel@nongnu.org; Tue, 16 Apr 2019 08:59:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGNgY-00022c-3s for qemu-devel@nongnu.org; Tue, 16 Apr 2019 08:59:40 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37994) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGNgX-00021t-Pf for qemu-devel@nongnu.org; Tue, 16 Apr 2019 08:59:38 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x3GCxTmU055626; Tue, 16 Apr 2019 12:59:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=/f6Vn0qOWjqIheyoMHr5MtfUPS8Upb1rVgZ3o5Gcs3s=; b=IxTpEU+1oXtFTLCfD7pqlb4x7sT+xoRA+0kK62O2EZ84BetkPkosnMK2Gu0w8EKI5QyC 7w47ffzqdJEDOgSJ7wp/XAqyNXUTk9tXKUNOeq2YtMU4P0NtjaYqiOjii3IGCWOZCQgs Cz1IIXVHD8cLkxuzQAFpBwywhaQSA4KsKmdysYV3qzQ9Xb2UAq7/nJi7D0awK6yWJSGg qGrpUfj1guRYBF6OL8ICdeMrn1OH9BEiYO9wpZr8/7TpB6O/1uxRkKxxk4+5OPah+ZB5 UZE/xf7ECOYSa3aiNu3CrB/MX40V6dpB8oH8fDYhnbKrM7uYNCunnQWXZGaGfqpsqZ2/ 9A== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2rusnetf76-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Apr 2019 12:59:36 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x3GCwAUL185417; Tue, 16 Apr 2019 12:59:35 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2rwe79s8ag-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Apr 2019 12:59:35 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x3GCxXGX020497; Tue, 16 Apr 2019 12:59:34 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 16 Apr 2019 05:59:33 -0700 From: Liran Alon To: qemu-devel@nongnu.org Date: Tue, 16 Apr 2019 15:59:10 +0300 Message-Id: <20190416125912.44001-2-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190416125912.44001-1-liran.alon@oracle.com> References: <20190416125912.44001-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9228 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904160088 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9228 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904160088 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp2120.oracle.com id x3GCxTmU055626 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [PATCH v2 1/3] vhost-scsi: The vhost backend should be stopped when the VM is not running 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: ehabkost@redhat.com, stefanha@gmail.com, mtosatti@redhat.com, bijan.mottahedeh@oracle.com, Liran Alon , pbonzini@redhat.com, nir.weiner@oracle.com, rth@twiddle.net Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Message-ID: <20190416125910.Z5pH0C6O37JTmH7yR1XOoNMIS-0XLfojIxGpri654ck@z> From: Nir Weiner vhost-scsi doesn=E2=80=99t takes into account whether the VM is running o= r not in order to decide if it should start/stop vhost backend. This would lead to vhost backend still being active when VM's RunState suddenly change to stopped. An example of when this issue is encountered is when Live-Migration Pre-C= opy phase completes. As in this case, VM state will be changed to stopped (wh= ile vhost backend is still active), which will result in virtio_vmstate_change() -> virtio_set_status() -> vhost_scsi_set_status() executed but vhost_scsi_set_status() will just return without stopping vhost backend. To handle this, change code to consider that vhost processing should be stopped when VM is not running. Similar to how it is done in vhost-vsock device at vhost_vsock_set_status(). Fixes: 5e9be92d7752 ("vhost-scsi: new device supporting the tcm_vhost Lin= ux kernel module=E2=80=9D) Reviewed-by: Bijan Mottahedeh Reviewed-by: Liran Alon Signed-off-by: Nir Weiner --- hw/scsi/vhost-scsi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 61e2e57da9d5..ca42cff1b907 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -114,6 +114,10 @@ static void vhost_scsi_set_status(VirtIODevice *vdev= , uint8_t val) VHostSCSICommon *vsc =3D VHOST_SCSI_COMMON(s); bool start =3D (val & VIRTIO_CONFIG_S_DRIVER_OK); =20 + if (!vdev->vm_running) { + start =3D false; + } + if (vsc->dev.started =3D=3D start) { return; } --=20 2.20.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C988BC04AB5 for ; Mon, 3 Jun 2019 18:19:44 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id A4509273C0 for ; Mon, 3 Jun 2019 18:19:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4509273C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([127.0.0.1]:39093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXrYd-0002He-T3 for qemu-devel@archiver.kernel.org; Mon, 03 Jun 2019 14:19:43 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXrOM-0002Ay-BD for qemu-devel@nongnu.org; Mon, 03 Jun 2019 14:09:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXrOL-0000ht-CE for qemu-devel@nongnu.org; Mon, 03 Jun 2019 14:09:06 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:33144) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hXrOL-0000gD-6s for qemu-devel@nongnu.org; Mon, 03 Jun 2019 14:09:05 -0400 Received: by mail-qt1-f195.google.com with SMTP id 14so10576183qtf.0 for ; Mon, 03 Jun 2019 11:09:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=k+AJ3Fh6N8GnLwjJBflOCLdYcgacwSZPHZMjqBixblY=; b=KO6XDxz8XdxW/2adhlgmNV8ZYDz+BjNo9Q2bKC93BX84yw/qWsaX09CZYoZs4Me+vQ 7UrCRqKFj+1EGH+7PEeYjdV1okD1KaXmjNGuC7bODxzuMYBNQeuA+rbwtthtbgzIMoSN yeuW8mXcjAufod9C8ve/fp1k14CJ+uFKTjHbOFNCMq15UHAooK8SXeqdKAAKVaToAsSA lpzZJ0odXt0FQ/Mz+A7gvpyNCfzWFSeAZbONsfGJW3vMcvDOOOC2T751Mi73GhT7DnTF Q1liTRicegju4NgBnGH0nmjt38BITVcB0nz28Q6Hc3YcVg2WR6lSdQm2DUpfVYA5I6W7 amyQ== X-Gm-Message-State: APjAAAV8hXeyDMPz7jZSt40oVCm70tyJAQItOyl645PBGgeGQdHnkxxi NIa7i3LkrL3zEQylzJiyVX+t+sodnMg= X-Google-Smtp-Source: APXvYqw+XN4ZF2F/Ewh1dI/G4XvRdKLy/CKJ1M+Y3aozjRIniCHYuTw0UknqB6DrfdPocV++ge7yNQ== X-Received: by 2002:ac8:30a4:: with SMTP id v33mr24832090qta.249.1559585344275; Mon, 03 Jun 2019 11:09:04 -0700 (PDT) Received: from redhat.com (pool-100-0-197-103.bstnma.fios.verizon.net. [100.0.197.103]) by smtp.gmail.com with ESMTPSA id j125sm3969059qkd.59.2019.06.03.11.09.02 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 03 Jun 2019 11:09:03 -0700 (PDT) Date: Mon, 3 Jun 2019 14:09:01 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <20190416125912.44001-2-liran.alon@oracle.com> References: <20190603180807.16140-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190603180807.16140-1-mst@redhat.com> X-Mailer: git-send-email 2.17.1.1206.gb667731e2e.dirty X-Mutt-Fcc: =sent X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.160.195 Subject: [Qemu-devel] [PULL v2 11/14] vhost-scsi: The vhost backend should be stopped when the VM is not running 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: Fam Zheng , Peter Maydell , Bijan Mottahedeh , Liran Alon , Stefan Hajnoczi , Paolo Bonzini , Nir Weiner Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Message-ID: <20190603180901.Cd6iwXSrq06HYGau7q61UoHpnF9cjIbWsNGzZzQxobw@z> From: Nir Weiner vhost-scsi doesn’t takes into account whether the VM is running or not in order to decide if it should start/stop vhost backend. This would lead to vhost backend still being active when VM's RunState suddenly change to stopped. An example of when this issue is encountered is when Live-Migration Pre-Copy phase completes. As in this case, VM state will be changed to stopped (while vhost backend is still active), which will result in virtio_vmstate_change() -> virtio_set_status() -> vhost_scsi_set_status() executed but vhost_scsi_set_status() will just return without stopping vhost backend. To handle this, change code to consider that vhost processing should be stopped when VM is not running. Similar to how it is done in vhost-vsock device at vhost_vsock_set_status(). Fixes: 5e9be92d7752 ("vhost-scsi: new device supporting the tcm_vhost Linux kernel module”) Reviewed-by: Bijan Mottahedeh Reviewed-by: Liran Alon Signed-off-by: Nir Weiner Message-Id: <20190416125912.44001-2-liran.alon@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi --- hw/scsi/vhost-scsi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 61e2e57da9..ca42cff1b9 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -114,6 +114,10 @@ static void vhost_scsi_set_status(VirtIODevice *vdev, uint8_t val) VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s); bool start = (val & VIRTIO_CONFIG_S_DRIVER_OK); + if (!vdev->vm_running) { + start = false; + } + if (vsc->dev.started == start) { return; } -- MST From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE8ECC28D18 for ; Wed, 5 Jun 2019 20:09:51 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id ACF5D206BB for ; Wed, 5 Jun 2019 20:09:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ACF5D206BB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([127.0.0.1]:49175 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYcEI-0001Zc-SR for qemu-devel@archiver.kernel.org; Wed, 05 Jun 2019 16:09:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYc5Y-0003EM-Kw for qemu-devel@nongnu.org; Wed, 05 Jun 2019 16:00:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYc5R-0005ml-UG for qemu-devel@nongnu.org; Wed, 05 Jun 2019 16:00:46 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:40858) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hYc5O-0005aI-VT for qemu-devel@nongnu.org; Wed, 05 Jun 2019 16:00:39 -0400 Received: by mail-qt1-f194.google.com with SMTP id a15so5013586qtn.7 for ; Wed, 05 Jun 2019 13:00:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=k+AJ3Fh6N8GnLwjJBflOCLdYcgacwSZPHZMjqBixblY=; b=Rsg0qorcKj51NYBfGC/5e+wJq5mLZz0U7nb2+odIYcbEtFF7XFoejBawdz0WE3nXUD mOCDf5pz1YvXBo1c/KVqtGNpiQCxFencvx6wSuMOTaEmbMvYYm+zM6t4e5DJXT/UNi2D WTjNNuK4myRjkWXdjq4TtjMvMMfyblyz41LdAE/54puBXWrGGHmAt6F79WfNrWmd4ecD ThEZ4AS/wxGznCpNdgm97OsoGMJdPVajX63f54sglPWL/By94frtcF7RuzMCvRFVa6NV U8OjNAT9rLa8dspdHRVaXlh9Eh28y1BQwMuiv+6Lz9OvY0R/INdJntXSUpj/SlaK9kpT L5YQ== X-Gm-Message-State: APjAAAWTD5FGRgQQaoWEIwmgCmDsCN2DQmIO3fYAjiqE4cO1ahFAai5C +EvVSEtwNMG/9j8mhfWyI04rkWcgY6Y= X-Google-Smtp-Source: APXvYqyOAgyshQ55J1J8QyAccDWTZ+hUQHLet398MUFVcUNHa/WjhQy9s4lDFABEYm7uhVB4juh+mw== X-Received: by 2002:ac8:87d:: with SMTP id x58mr36566795qth.368.1559764835011; Wed, 05 Jun 2019 13:00:35 -0700 (PDT) Received: from redhat.com (pool-100-0-197-103.bstnma.fios.verizon.net. [100.0.197.103]) by smtp.gmail.com with ESMTPSA id f9sm13488264qkb.97.2019.06.05.13.00.33 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 05 Jun 2019 13:00:34 -0700 (PDT) Date: Wed, 5 Jun 2019 16:00:33 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <20190416125912.44001-2-liran.alon@oracle.com> References: <20190605195913.12243-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190605195913.12243-1-mst@redhat.com> X-Mailer: git-send-email 2.17.1.1206.gb667731e2e.dirty X-Mutt-Fcc: =sent X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.160.194 Subject: [Qemu-devel] [PULL v3 11/17] vhost-scsi: The vhost backend should be stopped when the VM is not running 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: Fam Zheng , Peter Maydell , Bijan Mottahedeh , Liran Alon , Stefan Hajnoczi , Paolo Bonzini , Nir Weiner Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Message-ID: <20190605200033.gyppgpfZ8Ug_3xv-dlRaFQ8tlNNy_WYdiGFdzmG22ys@z> From: Nir Weiner vhost-scsi doesn’t takes into account whether the VM is running or not in order to decide if it should start/stop vhost backend. This would lead to vhost backend still being active when VM's RunState suddenly change to stopped. An example of when this issue is encountered is when Live-Migration Pre-Copy phase completes. As in this case, VM state will be changed to stopped (while vhost backend is still active), which will result in virtio_vmstate_change() -> virtio_set_status() -> vhost_scsi_set_status() executed but vhost_scsi_set_status() will just return without stopping vhost backend. To handle this, change code to consider that vhost processing should be stopped when VM is not running. Similar to how it is done in vhost-vsock device at vhost_vsock_set_status(). Fixes: 5e9be92d7752 ("vhost-scsi: new device supporting the tcm_vhost Linux kernel module”) Reviewed-by: Bijan Mottahedeh Reviewed-by: Liran Alon Signed-off-by: Nir Weiner Message-Id: <20190416125912.44001-2-liran.alon@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi --- hw/scsi/vhost-scsi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 61e2e57da9..ca42cff1b9 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -114,6 +114,10 @@ static void vhost_scsi_set_status(VirtIODevice *vdev, uint8_t val) VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s); bool start = (val & VIRTIO_CONFIG_S_DRIVER_OK); + if (!vdev->vm_running) { + start = false; + } + if (vsc->dev.started == start) { return; } -- MST