|
@@ -260,6 +260,10 @@ static int virtblk_probe(struct virtio_device *vdev)
|
|
|
if (virtio_has_feature(vdev, VIRTIO_BLK_F_BARRIER))
|
|
|
blk_queue_ordered(vblk->disk->queue, QUEUE_ORDERED_TAG, NULL);
|
|
|
|
|
|
+ /* If disk is read-only in the host, the guest should obey */
|
|
|
+ if (virtio_has_feature(vdev, VIRTIO_BLK_F_RO))
|
|
|
+ set_disk_ro(vblk->disk, 1);
|
|
|
+
|
|
|
/* Host must always specify the capacity. */
|
|
|
vdev->config->get(vdev, offsetof(struct virtio_blk_config, capacity),
|
|
|
&cap, sizeof(cap));
|
|
@@ -326,7 +330,7 @@ static struct virtio_device_id id_table[] = {
|
|
|
|
|
|
static unsigned int features[] = {
|
|
|
VIRTIO_BLK_F_BARRIER, VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX,
|
|
|
- VIRTIO_BLK_F_GEOMETRY,
|
|
|
+ VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_RO,
|
|
|
};
|
|
|
|
|
|
static struct virtio_driver virtio_blk = {
|