From nobody Sun Feb 8 21:47:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1553155810229731.8245499422197; Thu, 21 Mar 2019 01:10:10 -0700 (PDT) Received: from localhost ([127.0.0.1]:32896 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6sm6-0001Yh-TV for importer@patchew.org; Thu, 21 Mar 2019 04:10:06 -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 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 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== 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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" As preparation of enabling migration of vhost-scsi device, define it=E2=80=99s 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 *vd= ev, VirtQueue *vq) { } =20 +static int vhost_scsi_pre_save(void *opaque) +{ + VHostSCSICommon *vsc =3D 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 =3D { + .name =3D "virtio-vhost_scsi", + .minimum_version_id =3D 1, + .version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_VIRTIO_DEVICE, + VMSTATE_END_OF_LIST() + }, + .pre_save =3D vhost_scsi_pre_save, +}; + static void vhost_scsi_realize(DeviceState *dev, Error **errp) { VirtIOSCSICommon *vs =3D VIRTIO_SCSI_COMMON(dev); @@ -256,6 +278,7 @@ static void vhost_scsi_class_init(ObjectClass *klass, v= oid *data) FWPathProviderClass *fwc =3D FW_PATH_PROVIDER_CLASS(klass); =20 dc->props =3D vhost_scsi_properties; + dc->vmsd =3D &vmstate_virtio_vhost_scsi; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); vdc->realize =3D vhost_scsi_realize; vdc->unrealize =3D vhost_scsi_unrealize; --=20 2.17.1