diff options
Diffstat (limited to 'drivers/block/virtio_blk.c')
-rw-r--r-- | drivers/block/virtio_blk.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 84e064ffee52..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)); |
@@ -311,6 +315,7 @@ static void virtblk_remove(struct virtio_device *vdev) | |||
311 | /* Stop all the virtqueues. */ | 315 | /* Stop all the virtqueues. */ |
312 | vdev->config->reset(vdev); | 316 | vdev->config->reset(vdev); |
313 | 317 | ||
318 | del_gendisk(vblk->disk); | ||
314 | blk_cleanup_queue(vblk->disk->queue); | 319 | blk_cleanup_queue(vblk->disk->queue); |
315 | put_disk(vblk->disk); | 320 | put_disk(vblk->disk); |
316 | mempool_destroy(vblk->pool); | 321 | mempool_destroy(vblk->pool); |
@@ -325,7 +330,7 @@ static struct virtio_device_id id_table[] = { | |||
325 | 330 | ||
326 | static unsigned int features[] = { | 331 | static unsigned int features[] = { |
327 | 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, |
328 | VIRTIO_BLK_F_GEOMETRY, | 333 | VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_RO, |
329 | }; | 334 | }; |
330 | 335 | ||
331 | static struct virtio_driver virtio_blk = { | 336 | static struct virtio_driver virtio_blk = { |