On 08/03/2011 03:07 PM, Markus Armbruster wrote:
We already track it in BlockDriverState. Just like tray open/close
state, we should track it in the device models instead, because it's
device state.
Signed-off-by: Markus Armbruster<arm...@redhat.com>
---
hw/scsi-disk.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index db72b86..8ca69f2 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -73,6 +73,7 @@ struct SCSIDiskState
char *serial;
SCSISense sense;
bool tray_open;
+ bool tray_locked;
};
Hmm. Shouldn't we use a more generic 'flags' here and have bits for
the individual tray states?
Feels like a waste to have individual values here.
static int scsi_handle_rw_error(SCSIDiskReq *r, int error, int type);
@@ -678,7 +679,7 @@ static int mode_sense_page(SCSIRequest *req, int page,
uint8_t *p,
p[5] = 0xff; /* CD DA, DA accurate, RW supported,
RW corrected, C2 errors, ISRC,
UPC, Bar code */
- p[6] = 0x2d | (bdrv_is_locked(s->bs)? 2 : 0);
+ p[6] = 0x2d | (s->tray_locked ? 2 : 0);
/* Locking supported, jumper present, eject, tray */
p[7] = 0; /* no volume& mute control, no
changer */
@@ -896,6 +897,7 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r,
uint8_t *outbuf)
scsi_disk_emulate_start_stop(r);
break;
case ALLOW_MEDIUM_REMOVAL:
+ s->tray_locked = req->cmd.buf[4]& 1;
bdrv_set_locked(s->bs, req->cmd.buf[4]& 1);
break;
case READ_CAPACITY_10:
Cheers,
Hannes
--
Dr. Hannes Reinecke zSeries & Storage
h...@suse.de +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)