提交 c79662f7 编写于 作者: N Naphtali Sprei 提交者: Anthony Liguori

Pass the drive's readonly attribute to the guest OS

Implemented for virtio-blk and for scsi
Signed-off-by: NNaphtali Sprei <nsprei@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 59f2689d
......@@ -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;
......
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册