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:
parent
59f2689d90
commit
c79662f7f7
@ -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;
|
||||
|
@ -445,6 +445,9 @@ static uint32_t virtio_blk_get_features(VirtIODevice *vdev)
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user