]> git.proxmox.com Git - mirror_qemu.git/commitdiff
virtio-scsi: restart DMA after iothread
authorStefan Hajnoczi <stefanha@redhat.com>
Thu, 20 Jun 2019 17:37:09 +0000 (18:37 +0100)
committerKevin Wolf <kwolf@redhat.com>
Mon, 8 Jul 2019 14:00:26 +0000 (16:00 +0200)
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 <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
hw/scsi/scsi-bus.c
hw/virtio/virtio.c

index 196136a307ea31771542cc5f888b3e9c9a13c950..fdc3a0e4e03732f4b72cb45f1b771a2b1e2f1945 100644 (file)
@@ -207,8 +207,8 @@ static void scsi_qdev_realize(DeviceState *qdev, Error **errp)
         error_propagate(errp, local_err);
         return;
     }
-    dev->vmsentry = qemu_add_vm_change_state_handler(scsi_dma_restart_cb,
-                                                     dev);
+    dev->vmsentry = qdev_add_vm_change_state_handler(DEVICE(dev),
+            scsi_dma_restart_cb, dev);
 }
 
 static void scsi_qdev_unrealize(DeviceState *qdev, Error **errp)
index 18f9f4c372b781551d5f6fb46a11e1891670c5a6..a94ea18a9c82cdae1de7e54108f0d25fe042a7ba 100644 (file)
@@ -2362,8 +2362,8 @@ void virtio_init(VirtIODevice *vdev, const char *name,
     } else {
         vdev->config = NULL;
     }
-    vdev->vmstate = qemu_add_vm_change_state_handler(virtio_vmstate_change,
-                                                     vdev);
+    vdev->vmstate = qdev_add_vm_change_state_handler(DEVICE(vdev),
+            virtio_vmstate_change, vdev);
     vdev->device_endian = virtio_default_endian();
     vdev->use_guest_notifier_mask = true;
 }