From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:38435) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R37Jn-0001HA-UN for qemu-devel@nongnu.org; Mon, 12 Sep 2011 10:17:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R37Jg-0006s8-4M for qemu-devel@nongnu.org; Mon, 12 Sep 2011 10:17:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52580) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R37Jf-0006rv-L5 for qemu-devel@nongnu.org; Mon, 12 Sep 2011 10:16:55 -0400 From: Kevin Wolf Date: Mon, 12 Sep 2011 16:19:11 +0200 Message-Id: <1315837174-15327-13-git-send-email-kwolf@redhat.com> In-Reply-To: <1315837174-15327-1-git-send-email-kwolf@redhat.com> References: <1315837174-15327-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 12/35] scsi-disk: Track tray locked state List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Markus Armbruster 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 Signed-off-by: Kevin Wolf --- 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 f35ada4..e7358e3 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -73,6 +73,7 @@ struct SCSIDiskState char *version; char *serial; bool tray_open; + bool tray_locked; }; static int scsi_handle_rw_error(SCSIDiskReq *r, int error, int type); @@ -671,7 +672,7 @@ static int mode_sense_page(SCSIDiskState *s, int page, uint8_t **p_outbuf, 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 */ @@ -882,6 +883,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: -- 1.7.6