@@ -2278,6 +2278,22 @@ static int32_t scsi_disk_emulate_command(SCSIRequest *req, uint8_t *buf)
transition_allowed = false;
unavailable_allowed = false;
break;
+ case SERVICE_ACTION_IN_16:
+ /*
+ * READ CAPACITY is not required by SPC,
+ * but Linux (currently) relies on a
+ * valid capacity, otherwise requests will
+ * be retried from sd.c:sd_prep_dn() and
+ * optimized-standby failover won't work.
+ */
+ if ((req->cmd.buf[1] & 0x31) != SAI_READ_CAPACITY_16) {
+ standby_allowed = false;
+ }
+ /* Fallthrough */
+ case READ_CAPACITY_10:
+ transition_allowed = false;
+ unavailable_allowed = false;
+ break;
default:
transition_allowed = false;
unavailable_allowed = false;
SPC does not mandate to allow READ CAPACITY when in standby, but linux currently relies on a valid capacity. Otherwise requests will be retried from sd_prep_fn() and I/O will never complete. Signed-off-by: Hannes Reinecke <hare@suse.de> --- hw/scsi/scsi-disk.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)