summary refs log tree commit diff stats
path: root/util/qemu-option.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2018-07-16 09:37:32 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2018-07-16 16:58:16 +0200
commit8449bcf94986156a1476d6647c75ec1ce3db64d0 (patch)
tree4a1155bb5c15b0646af568b5c47457d54202555d /util/qemu-option.c
parent25e8978817a54745c44d956d8303e6be6f2c4047 (diff)
downloadfocaccia-qemu-8449bcf94986156a1476d6647c75ec1ce3db64d0.tar.gz
focaccia-qemu-8449bcf94986156a1476d6647c75ec1ce3db64d0.zip
virtio-scsi: fix hotplug ->reset() vs event race
There is a race condition during hotplug when iothread is used.  It
occurs because virtio-scsi may be processing command queues in the
iothread while the monitor performs SCSI device hotplug.

When a SCSI device is hotplugged the HotplugHandler->plug() callback is
invoked and virtio-scsi emits a rescan event to the guest.

If the guest submits a SCSI command at this point then it may be
cancelled before hotplug completes.  This happens because ->reset() is
called by hw/core/qdev.c:device_set_realized() after
HotplugHandler->plug() has been called and
hw/scsi/scsi-disk.c:scsi_disk_reset() purges all requests.

This patch uses the new HotplugHandler->post_plug() callback to emit the
rescan event after ->reset().  This eliminates the race conditions where
requests could be cancelled.

Reported-by: l00284672 <lizhengui@huawei.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20180716083732.3347-3-stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'util/qemu-option.c')
0 files changed, 0 insertions, 0 deletions