virtio-scsi: Move BlockBackend back to the main AioContext on unplug

This fixes a crash when attaching a disk to a SCSI device using
iothreads, then detaching it and reattaching it again. Test case
included.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Alberto Garcia 2019-01-22 17:53:21 +02:00 committed by Kevin Wolf
parent 14632122b8
commit a6f230c8d1
4 changed files with 114 additions and 0 deletions

View file

@ -824,6 +824,12 @@ static void virtio_scsi_hotunplug(HotplugHandler *hotplug_dev, DeviceState *dev,
virtio_scsi_release(s);
}
if (s->ctx) {
virtio_scsi_acquire(s);
blk_set_aio_context(sd->conf.blk, qemu_get_aio_context());
virtio_scsi_release(s);
}
qdev_simple_device_unplug_cb(hotplug_dev, dev, errp);
}