From nobody Mon Feb 9 08:10:22 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; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561053240; cv=none; d=zoho.com; s=zohoarc; b=NXAB5K3iy56KOrjVVQWmHdR/QlMZx5SVNHPypqAc+OfVaGnjk957vMkGfRZt6tYGyLn/U6FZ36f0PfBB/97CEyEX0qb/LEvdCzREzXINgs8q0NvlSAYBFB3jaEoXj5l7rokawrzJkvQvkcBCt6PSEf3ZHhL/a4qd2Z1RB5DMZBA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561053240; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=lVb+KNkZb4Mf4RanskrSClg1Iu4fvY/yVFGUTsnM/oU=; b=d4TZRmZmThPxQjf+j3im+VI7ub4GcwjjrHo3bKpJTLJ8p7szo7BqQKtWaOETc1BdOCrxxi86xqx4WCBhEb7DSRpdjbCy/tm88c+Sg8jYb1JfGEcybm9u9gga3ant3/EnsOLlizgY+m/7zBP2Pim3HaMH43Ve7idI+FL3+1jeCbg= ARC-Authentication-Results: i=1; mx.zoho.com; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561053240350672.4271336593158; Thu, 20 Jun 2019 10:54:00 -0700 (PDT) Received: from localhost ([::1]:51934 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he1Fy-0004bG-04 for importer@patchew.org; Thu, 20 Jun 2019 13:53:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34919) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he19O-0007IG-Ou for qemu-devel@nongnu.org; Thu, 20 Jun 2019 13:47:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1he10I-0004rK-1Z for qemu-devel@nongnu.org; Thu, 20 Jun 2019 13:37:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44948) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1he10H-0004qM-RC for qemu-devel@nongnu.org; Thu, 20 Jun 2019 13:37:41 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EFD1B90C77; Thu, 20 Jun 2019 17:37:40 +0000 (UTC) Received: from localhost (ovpn-116-108.ams2.redhat.com [10.36.116.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83E6B5C1A1; Thu, 20 Jun 2019 17:37:40 +0000 (UTC) From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Thu, 20 Jun 2019 18:37:09 +0100 Message-Id: <20190620173709.14753-4-stefanha@redhat.com> In-Reply-To: <20190620173709.14753-1-stefanha@redhat.com> References: <20190620173709.14753-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 20 Jun 2019 17:37:41 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v5 3/3] virtio-scsi: restart DMA after iothread X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" When the 'cont' command resumes guest execution the vm change state handlers are invoked. Unfortunately there is no explicit ordering between classic qemu_add_vm_change_state_handler() callbacks. When two layers of code both use vm change state handlers, we don't control which handler runs first. virtio-scsi with iothreads hits a deadlock when a failed SCSI command is restarted and completes before the iothread is re-initialized. This patch uses the new qdev_add_vm_change_state_handler() API to guarantee that virtio-scsi's virtio change state handler executes before the SCSI bus children. This way DMA is restarted after the iothread has re-initialized. Signed-off-by: Stefan Hajnoczi --- hw/scsi/scsi-bus.c | 4 ++-- hw/virtio/virtio.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 196136a307..fdc3a0e4e0 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -207,8 +207,8 @@ static void scsi_qdev_realize(DeviceState *qdev, Error = **errp) error_propagate(errp, local_err); return; } - dev->vmsentry =3D qemu_add_vm_change_state_handler(scsi_dma_restart_cb, - dev); + dev->vmsentry =3D qdev_add_vm_change_state_handler(DEVICE(dev), + scsi_dma_restart_cb, dev); } =20 static void scsi_qdev_unrealize(DeviceState *qdev, Error **errp) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index e1e90fcfd6..e42e6710d2 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2354,8 +2354,8 @@ void virtio_init(VirtIODevice *vdev, const char *name, } else { vdev->config =3D NULL; } - vdev->vmstate =3D qemu_add_vm_change_state_handler(virtio_vmstate_chan= ge, - vdev); + vdev->vmstate =3D qdev_add_vm_change_state_handler(DEVICE(vdev), + virtio_vmstate_change, vdev); vdev->device_endian =3D virtio_default_endian(); vdev->use_guest_notifier_mask =3D true; } --=20 2.21.0