From patchwork Thu Mar 21 07:55:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nir Weiner X-Patchwork-Id: 1059862 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="wpGSH+wE"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44Pzyk5nLcz9sPl for ; Thu, 21 Mar 2019 19:11:42 +1100 (AEDT) Received: from localhost ([127.0.0.1]:32941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6snc-0002n0-MB for incoming@patchwork.ozlabs.org; Thu, 21 Mar 2019 04:11:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6sjy-0000Ix-Pu for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:07:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6sYh-0005pP-15 for qemu-devel@nongnu.org; Thu, 21 Mar 2019 03:56:16 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:55740) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6sYg-0005nW-L5 for qemu-devel@nongnu.org; Thu, 21 Mar 2019 03:56:14 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2L7rfu3085191 for ; Thu, 21 Mar 2019 07:56:13 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=fkaAwLz7/cPV2A97NnnySqtCtwJGZbvwKU1mbFhonSI=; b=wpGSH+wEG6lPN8uq9ztG77Rs6PkYwU0b9opU1ySwIS995ddqAPxY2UtJzw+2hcSijH1D IcSvbMNBclqJ1lHuqsTp4gPAmcBhQiGrYUbRsbJqIe3Pgks+JnjkTTf1K9h3YNgJB1ay 4oqk1vRHJG4Rd75qbE8yf1oNjzv34XCHEPKFx0NR0jMM5s2EPweqIimC9vluDT6XYLFu 38rxgWhoGzQrPGlxH4XhbINlgB161XW0JHIp2pL05yFcUm7vxDmp/d+jtqQX9uHlay45 w8DWYGtha1g3nwhLZlT5CcDcxxWVsT4foG2Dn9iCq+ZI4kTKW0kKZsoW7EXw88/OAMIb Pw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2r8pney4ms-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 21 Mar 2019 07:56:13 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x2L7u8E0015128 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 21 Mar 2019 07:56:08 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x2L7u8hT006597 for ; Thu, 21 Mar 2019 07:56:08 GMT Received: from nir-ThinkPad-T470.oracle.com (/10.74.125.62) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 21 Mar 2019 00:56:07 -0700 From: Nir Weiner To: qemu-devel@nongnu.org Date: Thu, 21 Mar 2019 09:55:43 +0200 Message-Id: <20190321075545.14929-2-nir.weiner@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190321075545.14929-1-nir.weiner@oracle.com> References: <20190321075545.14929-1-nir.weiner@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9201 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=1015 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-1903210058 X-MIME-Autoconverted: from 8bit to quoted-printable by aserp2130.oracle.com id x2L7rfu3085191 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.79 Subject: [Qemu-devel] [PATCH 1/3] vhost-scsi: The vhost device 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: nir.weiner@oracle.com, liran.alon@oracle.com, bijan.mottahedeh@oracle.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" vhost-scsi doesn’t takes into account whether the vm is running or not in order to decide if it should start/stop vhost processing. This would lead to vhost processing still being active when VM the 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 processing 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 processing. 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 --- 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 = VHOST_SCSI_COMMON(s); bool start = (val & VIRTIO_CONFIG_S_DRIVER_OK); + if (!vdev->vm_running) { + start = false; + } + if (vsc->dev.started == start) { return; } From patchwork Thu Mar 21 07:55:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nir Weiner X-Patchwork-Id: 1059859 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="i7uuk+FW"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44PzvY2PmXz9sPl for ; Thu, 21 Mar 2019 19:08:57 +1100 (AEDT) Received: from localhost ([127.0.0.1]:32880 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6skw-0000O5-HK for incoming@patchwork.ozlabs.org; Thu, 21 Mar 2019 04:08:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6sjy-0000CQ-PM for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:07:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6sYh-0005rk-Vu for qemu-devel@nongnu.org; Thu, 21 Mar 2019 03:56:16 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:55756) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6sYh-0005pF-Ib for qemu-devel@nongnu.org; Thu, 21 Mar 2019 03:56:15 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2L7rpOM085254 for ; Thu, 21 Mar 2019 07:56:14 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=WPPJy7fvwih2eM9B+zWZX4k5C6LTwWQQsrGeQAKuYKg=; b=i7uuk+FWSDktEV3itTQvb9tu2dpujJgzrzIl4v/eEvG6eGC7Z9noetrcVAXpfryHKC97 zhuzyUkcnhGBLtvKrc2qmV5MDbyt9InpNyfW641kzKnADimWawUkXav/Y9UKPKVR8bCO FpYmYsDB6R0fVtFv7QrZiMZjs0O8pQckwvaQ9Hs8oP0a+3hyNcHr6d4dUfges4HLrWGX 7utWC10R1nmtZfk5RbTM8a2HjFvkkpRuKY5sb1YhwpEpnDAgDCGcLtVi9I0kIsyNbsGm ar6UEJIHncP9Pku4qMjJpd1kQdNLrH44ohXpA9Iee0OY2SIG/NplhBfyPF86S1EFnP76 cQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2r8pney4mw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 21 Mar 2019 07:56:14 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x2L7uD1O015299 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 21 Mar 2019 07:56:14 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x2L7uDCu005278 for ; Thu, 21 Mar 2019 07:56:13 GMT Received: from nir-ThinkPad-T470.oracle.com (/10.74.125.62) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 21 Mar 2019 00:56:13 -0700 From: Nir Weiner To: qemu-devel@nongnu.org Date: Thu, 21 Mar 2019 09:55:44 +0200 Message-Id: <20190321075545.14929-3-nir.weiner@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190321075545.14929-1-nir.weiner@oracle.com> References: <20190321075545.14929-1-nir.weiner@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9201 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=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=973 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903210058 X-MIME-Autoconverted: from 8bit to quoted-printable by aserp2130.oracle.com id x2L7rpOM085254 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.79 Subject: [Qemu-devel] [PATCH 2/3] vhost-scsi: Add vmstate descriptor 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: nir.weiner@oracle.com, liran.alon@oracle.com, bijan.mottahedeh@oracle.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" As preparation of enabling migration of vhost-scsi device, define it’s VMState. Note, we keep the convention of verifying in the pre_save() method that the vhost backend must be stopped before attempting to save the device state. Similar to how it is done for vhost-vsock. Reviewed-by: Bijan Mottahedeh Reviewed-by: Liran Alon Signed-off-by: Nir Weiner --- hw/scsi/vhost-scsi.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index ca42cff1b907..eb0cf9e1312f 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -139,6 +139,28 @@ static void vhost_dummy_handle_output(VirtIODevice *vdev, VirtQueue *vq) { } +static int vhost_scsi_pre_save(void *opaque) +{ + VHostSCSICommon *vsc = opaque; + + /* At this point, backend must be stopped, otherwise + * it might keep writing to memory. */ + assert(!vsc->dev.started); + + return 0; +} + +static const VMStateDescription vmstate_virtio_vhost_scsi = { + .name = "virtio-vhost_scsi", + .minimum_version_id = 1, + .version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_VIRTIO_DEVICE, + VMSTATE_END_OF_LIST() + }, + .pre_save = vhost_scsi_pre_save, +}; + static void vhost_scsi_realize(DeviceState *dev, Error **errp) { VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev); @@ -256,6 +278,7 @@ static void vhost_scsi_class_init(ObjectClass *klass, void *data) FWPathProviderClass *fwc = FW_PATH_PROVIDER_CLASS(klass); dc->props = vhost_scsi_properties; + dc->vmsd = &vmstate_virtio_vhost_scsi; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); vdc->realize = vhost_scsi_realize; vdc->unrealize = vhost_scsi_unrealize; From patchwork Thu Mar 21 07:55:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nir Weiner X-Patchwork-Id: 1059861 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="cEAio+JL"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44PzyD4lQ0z9sPl for ; Thu, 21 Mar 2019 19:11:16 +1100 (AEDT) Received: from localhost ([127.0.0.1]:32933 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6snC-0002N0-Gs for incoming@patchwork.ozlabs.org; Thu, 21 Mar 2019 04:11:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40862) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6sjp-0000Es-GY for qemu-devel@nongnu.org; Thu, 21 Mar 2019 04:07:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6sYl-00063R-Ua for qemu-devel@nongnu.org; Thu, 21 Mar 2019 03:56:21 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:40416) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6sYl-00060D-GW for qemu-devel@nongnu.org; Thu, 21 Mar 2019 03:56:19 -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 x2L7reN6054896 for ; Thu, 21 Mar 2019 07:56:18 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; s=corp-2018-07-02; bh=PzhinLCSuiJbXlnJ4CO2bzO5V8Iie3fHk0v4mgM2CIM=; b=cEAio+JLI0krFF2ifDMnB15SUT/nD+Osn5Xza/Oefsq/xvfwiW1LqUi/xNkH9BREWFRX EFt0xQu8nXK2FVRdGReD2JCrHQqX1gXvT9ehN01gGA/H/8yuCXCxyCeiCFjEa0XBpZRV SYx9Z8jbwEWOl/az3QVxHjI7xlucB7qi8ePaFEM/E9RvrnpTXYkF+OA32Ga3j4m00GGA UXWMtnQDw9PdloTcSr4rkivSOvfLi1HJSSn0/6fWKZqM9ImHZPbUexKTjvgBpUcals8d lL0xMc7lrRwzjwelPgO/G80pncRbNz95/eV4Nk5+yEfcNxwWxFey0pqEFAtU5nSDUJI7 7g== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2r8ssrpsdk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 21 Mar 2019 07:56:18 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x2L7uH2D032522 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 21 Mar 2019 07:56:17 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x2L7uHY2005289 for ; Thu, 21 Mar 2019 07:56:17 GMT Received: from nir-ThinkPad-T470.oracle.com (/10.74.125.62) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 21 Mar 2019 00:56:17 -0700 From: Nir Weiner To: qemu-devel@nongnu.org Date: Thu, 21 Mar 2019 09:55:45 +0200 Message-Id: <20190321075545.14929-4-nir.weiner@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190321075545.14929-1-nir.weiner@oracle.com> References: <20190321075545.14929-1-nir.weiner@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9201 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 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-1903210058 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [PATCH 3/3] vhost-scsi: Allow user to enable migration 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: nir.weiner@oracle.com, liran.alon@oracle.com, bijan.mottahedeh@oracle.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Liran Alon Originally migration was not possible with vhost-scsi because as part of migration, the source host target SCSI device state needs to be saved and loaded into the destination host target SCSI device. This cannot be done by QEMU. As this can be handled either by external orchestrator or by having shared-storage (i.e. iSCSI), there is no reason to limit the orchestrator from being able to explictly specify it wish to enable migration even when VM have a vhost-scsi device. Reviewed-by: Nir Weiner Reviewed-by: Bijan Mottahedeh Signed-off-by: Liran Alon --- hw/scsi/vhost-scsi.c | 30 ++++++++++++++++++--------- include/hw/virtio/vhost-scsi-common.h | 1 + 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index eb0cf9e1312f..52d46a788e6c 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -199,13 +199,18 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp) goto close_fd; } - error_setg(&vsc->migration_blocker, - "vhost-scsi does not support migration"); - migrate_add_blocker(vsc->migration_blocker, &err); - if (err) { - error_propagate(errp, err); - error_free(vsc->migration_blocker); - goto close_fd; + if (!vsc->migratable) { + error_setg(&vsc->migration_blocker, + "vhost-scsi does not support migration in all cases." + "When external environment is supports it (Orchestrator migrates" + "target SCSI device state or use shared storage over network)," + "set 'migratable' property to true to enable migration."); + migrate_add_blocker(vsc->migration_blocker, &err); + if (err) { + error_propagate(errp, err); + error_free(vsc->migration_blocker); + goto close_fd; + } } vsc->dev.nvqs = VHOST_SCSI_VQ_NUM_FIXED + vs->conf.num_queues; @@ -230,7 +235,9 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp) return; free_vqs: - migrate_del_blocker(vsc->migration_blocker); + if (!vsc->migratable) { + migrate_del_blocker(vsc->migration_blocker); + } g_free(vsc->dev.vqs); close_fd: close(vhostfd); @@ -243,8 +250,10 @@ static void vhost_scsi_unrealize(DeviceState *dev, Error **errp) VHostSCSICommon *vsc = VHOST_SCSI_COMMON(dev); struct vhost_virtqueue *vqs = vsc->dev.vqs; - migrate_del_blocker(vsc->migration_blocker); - error_free(vsc->migration_blocker); + if (!vsc->migratable) { + migrate_del_blocker(vsc->migration_blocker); + error_free(vsc->migration_blocker); + } /* This will stop vhost backend. */ vhost_scsi_set_status(vdev, 0); @@ -268,6 +277,7 @@ static Property vhost_scsi_properties[] = { DEFINE_PROP_BIT64("t10_pi", VHostSCSICommon, host_features, VIRTIO_SCSI_F_T10_PI, false), + DEFINE_PROP_BOOL("migratable", VHostSCSICommon, migratable, false), DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/hw/virtio/vhost-scsi-common.h b/include/hw/virtio/vhost-scsi-common.h index 57fb1d87b51d..4eab767ee89f 100644 --- a/include/hw/virtio/vhost-scsi-common.h +++ b/include/hw/virtio/vhost-scsi-common.h @@ -36,6 +36,7 @@ typedef struct VHostSCSICommon { int target; int lun; uint64_t host_features; + bool migratable; } VHostSCSICommon; int vhost_scsi_common_start(VHostSCSICommon *vsc);