Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> --- hw/scsi-bus.c | 3 ++- hw/scsi-disk.c | 4 ++-- hw/scsi-generic.c | 4 ++-- hw/scsi.h | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index a5bb517..f6fb4f0 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -1089,7 +1089,7 @@ void scsi_req_abort(SCSIRequest *req, int status) scsi_req_complete(req, status); } -void scsi_device_purge_requests(SCSIDevice *sdev) +void scsi_device_purge_requests(SCSIDevice *sdev, SCSISense sense) { SCSIRequest *req; @@ -1097,6 +1097,7 @@ void scsi_device_purge_requests(SCSIDevice *sdev) req = QTAILQ_FIRST(&sdev->requests); scsi_req_cancel(req); } + sdev->unit_attention = sense; } static char *scsibus_get_fw_dev_path(DeviceState *dev) diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 5f21d68..655fcda 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -1098,7 +1098,7 @@ static void scsi_disk_reset(DeviceState *dev) SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev.qdev, dev); uint64_t nb_sectors; - scsi_device_purge_requests(&s->qdev); + scsi_device_purge_requests(&s->qdev, SENSE_CODE(RESET)); bdrv_get_geometry(s->bs, &nb_sectors); nb_sectors /= s->cluster_size; @@ -1112,7 +1112,7 @@ static void scsi_destroy(SCSIDevice *dev) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev); - scsi_device_purge_requests(&s->qdev); + scsi_device_purge_requests(&s->qdev, SENSE_CODE(NO_SENSE)); blockdev_mark_auto_del(s->qdev.conf.bs); } diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c index c122ad3..e8053da 100644 --- a/hw/scsi-generic.c +++ b/hw/scsi-generic.c @@ -381,14 +381,14 @@ static void scsi_generic_reset(DeviceState *dev) { SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev.qdev, dev); - scsi_device_purge_requests(&s->qdev); + scsi_device_purge_requests(&s->qdev, SENSE_CODE(RESET)); } static void scsi_destroy(SCSIDevice *d) { SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, d); - scsi_device_purge_requests(&s->qdev); + scsi_device_purge_requests(&s->qdev, SENSE_CODE(NO_SENSE)); blockdev_mark_auto_del(s->qdev.conf.bs); } diff --git a/hw/scsi.h b/hw/scsi.h index 09c3606..98fd689 100644 --- a/hw/scsi.h +++ b/hw/scsi.h @@ -187,7 +187,7 @@ uint8_t *scsi_req_get_buf(SCSIRequest *req); int scsi_req_get_sense(SCSIRequest *req, uint8_t *buf, int len); void scsi_req_abort(SCSIRequest *req, int status); void scsi_req_cancel(SCSIRequest *req); -void scsi_device_purge_requests(SCSIDevice *sdev); +void scsi_device_purge_requests(SCSIDevice *sdev, SCSISense sense); int scsi_device_get_sense(SCSIDevice *dev, uint8_t *buf, int len, bool fixed); #endif -- 1.7.6