Pass the drive's readonly attribute to the guest OS
PATCH 1/1 Pass the drive's readonly attribute to the guest OS
Hi,
I've seen my patch (http://repo.or.cz/w/qemu/aliguori-queue.git?a=commit;h=2286b94c7458cd6d72883990b53500194975c2ff)
in the staging tree, but the patch relies on a previous patch (http://lists.gnu.org/archive/html/qemu-devel/2009-10/msg01316.html)
I sent that I cannot find in the staging tree, nor committed.
So here is the missing patch again, against current head.
Naphtali
Subject: [PATCH] Pass the drive's readonly attribute to the guest OS
Implemented for virtio-blk and for scsi
Signed-off-by Naphtali Sprei <[email protected]>
--- hw/scsi-disk.c | 3 ++- hw/virtio-blk.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletions(-)
hw/scsi-disk.c +2 -1
@@ -633,7 +633,8 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag,memset (p,0 ,4 ); outbuf[1 ] =0 ;/* Default media type. */ outbuf[3 ] =0 ;/* Block descriptor length. */ -if (bdrv_get_type_hint (s->dinfo->bdrv) ==BDRV_TYPE_CDROM ) { +if (bdrv_get_type_hint (s->dinfo->bdrv) ==BDRV_TYPE_CDROM || +bdrv_is_read_only (s->dinfo->bdrv)) { outbuf[2 ] =0x80 ;/* Readonly. */ } p +=4 ;
hw/virtio-blk.c +3 -0
@@ -444,6 +444,9 @@ static uint32_t virtio_blk_get_features(VirtIODevice *vdev)#endif if (strcmp (s->serial_str,"0" )) features |=1 <<VIRTIO_BLK_F_IDENTIFY ; + +if (bdrv_is_read_only (s->bs)) + features |=1 <<VIRTIO_BLK_F_RO ;return features; }
Signature · 1 line
1.6.3.3