From 6a8a685c4d022d4edee57b0fb78c0ae1b4876478 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Mon, 16 Jul 2012 08:53:28 +0200 Subject: scsi-disk: Fail medium writes with proper sense for readonly LUNs Add sense code for DATA_PROTECT/WRITE_PROTECTED and return this error for any WRITE*/WRITE_VERIFY* calls if the device is readonly=on, i.e. write-protected Signed-off-by: Ronnie Sahlberg Signed-off-by: Paolo Bonzini --- hw/scsi-bus.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'hw/scsi-bus.c') diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index efbda6f..dd0cdd0 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -1182,6 +1182,11 @@ const struct SCSISense sense_code_DEVICE_INTERNAL_RESET = { .key = UNIT_ATTENTION, .asc = 0x29, .ascq = 0x04 }; +/* Data Protection, Write Protected */ +const struct SCSISense sense_code_WRITE_PROTECTED = { + .key = DATA_PROTECT, .asc = 0x27, .ascq = 0x00 +}; + /* * scsi_build_sense * -- cgit v1.1