aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorChristian Borntraeger <borntraeger@de.ibm.com>2008-05-16 05:17:03 -0400
committerRusty Russell <rusty@rustcorp.com.au>2008-05-30 01:09:44 -0400
commit3ef536095446552823fc488fec1c5451aab1260d (patch)
tree9d525f24f2bd07ce1b82f8b60673062e05c41c2e /drivers/block
parenta16ffe93c46dfca211434d00453ebb695025978b (diff)
virtio_blk: allow read-only disks
Hello Rusty, sometimes it is useful to share a disk (e.g. usr). To avoid file system corruption, the disk should be mounted read-only in that case. This patch adds a new feature flag, that allows the host to specify, if the disk should be considered read-only. Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/virtio_blk.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index c4804f3465db..dd7ea203f940 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -260,6 +260,10 @@ static int virtblk_probe(struct virtio_device *vdev)
260 if (virtio_has_feature(vdev, VIRTIO_BLK_F_BARRIER)) 260 if (virtio_has_feature(vdev, VIRTIO_BLK_F_BARRIER))
261 blk_queue_ordered(vblk->disk->queue, QUEUE_ORDERED_TAG, NULL); 261 blk_queue_ordered(vblk->disk->queue, QUEUE_ORDERED_TAG, NULL);
262 262
263 /* If disk is read-only in the host, the guest should obey */
264 if (virtio_has_feature(vdev, VIRTIO_BLK_F_RO))
265 set_disk_ro(vblk->disk, 1);
266
263 /* Host must always specify the capacity. */ 267 /* Host must always specify the capacity. */
264 vdev->config->get(vdev, offsetof(struct virtio_blk_config, capacity), 268 vdev->config->get(vdev, offsetof(struct virtio_blk_config, capacity),
265 &cap, sizeof(cap)); 269 &cap, sizeof(cap));
@@ -326,7 +330,7 @@ static struct virtio_device_id id_table[] = {
326 330
327static unsigned int features[] = { 331static unsigned int features[] = {
328 VIRTIO_BLK_F_BARRIER, VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX, 332 VIRTIO_BLK_F_BARRIER, VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX,
329 VIRTIO_BLK_F_GEOMETRY, 333 VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_RO,
330}; 334};
331 335
332static struct virtio_driver virtio_blk = { 336static struct virtio_driver virtio_blk = {