Pass the drive's readonly attribute to the guest OS

Implemented for virtio-blk and for scsi

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Naphtali Sprei 2009-10-29 11:42:11 +02:00 committed by Anthony Liguori
parent 59f2689d90
commit c79662f7f7
2 changed files with 5 additions and 1 deletions

View file

@ -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;

View file

@ -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;
}