[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 01/13] virtio-scsi: avoid race between unplug and transport event
- To: Stefan Hajnoczi <stefanha@xxxxxxxxxx>, qemu-devel@xxxxxxxxxx
- From: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
- Date: Mon, 3 Apr 2023 22:47:11 +0200
- Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>, Julia Suvorova <jusual@xxxxxxxxxx>, Kevin Wolf <kwolf@xxxxxxxxxx>, Peter Lieven <pl@xxxxxxx>, Coiby Xu <Coiby.Xu@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Richard Henderson <richard.henderson@xxxxxxxxxx>, Stefano Garzarella <sgarzare@xxxxxxxxxx>, qemu-block@xxxxxxxxxx, Eduardo Habkost <eduardo@xxxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, "Richard W.M. Jones" <rjones@xxxxxxxxxx>, "Dr. David Alan Gilbert" <dgilbert@xxxxxxxxxx>, Marcel Apfelbaum <marcel.apfelbaum@xxxxxxxxx>, Aarushi Mehta <mehta.aaru20@xxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Fam Zheng <fam@xxxxxxxxxx>, David Woodhouse <dwmw2@xxxxxxxxxxxxx>, Stefan Weil <sw@xxxxxxxxxxx>, Juan Quintela <quintela@xxxxxxxxxx>, Xie Yongji <xieyongji@xxxxxxxxxxxxx>, Hanna Reitz <hreitz@xxxxxxxxxx>, Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx>, eesposit@xxxxxxxxxx, "Michael S. Tsirkin" <mst@xxxxxxxxxx>, Daniel P. Berrangé <berrange@xxxxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>
- Delivery-date: Mon, 03 Apr 2023 20:47:28 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 3/4/23 20:29, Stefan Hajnoczi wrote:
Only report a transport reset event to the guest after the SCSIDevice
has been unrealized by qdev_simple_device_unplug_cb().
qdev_simple_device_unplug_cb() sets the SCSIDevice's qdev.realized field
to false so that scsi_device_find/get() no longer see it.
scsi_target_emulate_report_luns() also needs to be updated to filter out
SCSIDevices that are unrealized.
These changes ensure that the guest driver does not see the SCSIDevice
that's being unplugged if it responds very quickly to the transport
reset event.
Signed-off-by: Stefan Hajnoczi <stefanha@xxxxxxxxxx>
---
hw/scsi/scsi-bus.c | 3 ++-
hw/scsi/virtio-scsi.c | 18 +++++++++---------
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index c97176110c..f9bd064833 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -487,7 +487,8 @@ static bool scsi_target_emulate_report_luns(SCSITargetReq
*r)
DeviceState *qdev = kid->child;
SCSIDevice *dev = SCSI_DEVICE(qdev);
- if (dev->channel == channel && dev->id == id && dev->lun != 0) {
+ if (dev->channel == channel && dev->id == id && dev->lun != 0 &&
+ qatomic_load_acquire(&dev->qdev.realized)) {
Would this be more useful as a qdev_is_realized() helper?
|