scsi: report unit attention on reset

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Paolo Bonzini 2011-08-03 10:49:18 +02:00 committed by Anthony Liguori
parent 6dc06f08b3
commit c7b488721d
4 changed files with 7 additions and 6 deletions

View File

@ -1099,7 +1099,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;
@ -1107,6 +1107,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)

View File

@ -1087,7 +1087,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;
@ -1101,7 +1101,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);
}

View File

@ -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);
}

View File

@ -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