aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/virtio_blk.c
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2008-02-04 23:50:03 -0500
committerRusty Russell <rusty@rustcorp.com.au>2008-02-04 07:50:03 -0500
commit6e5aa7efb27aec7e55b6463fa2c8db594c4226fa (patch)
tree060a955e711ac224136157a5410e88dcdab965af /drivers/block/virtio_blk.c
parentb3369c1fb410fddeb38a404316c861395f6d6ae8 (diff)
virtio: reset function
A reset function solves three problems: 1) It allows us to renegotiate features, eg. if we want to upgrade a guest driver without rebooting the guest. 2) It gives us a clean way of shutting down virtqueues: after a reset, we know that the buffers won't be used by the host, and 3) It helps the guest recover from messed-up drivers. So we remove the ->shutdown hook, and the only way we now remove feature bits is via reset. We leave it to the driver to do the reset before it deletes queues: the balloon driver, for example, needs to chat to the host in its remove function. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/block/virtio_blk.c')
-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 54a8017ad487..6143337527e7 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -264,12 +264,16 @@ static void virtblk_remove(struct virtio_device *vdev)
264 struct virtio_blk *vblk = vdev->priv; 264 struct virtio_blk *vblk = vdev->priv;
265 int major = vblk->disk->major; 265 int major = vblk->disk->major;
266 266
267 /* Nothing should be pending. */
267 BUG_ON(!list_empty(&vblk->reqs)); 268 BUG_ON(!list_empty(&vblk->reqs));
269
270 /* Stop all the virtqueues. */
271 vdev->config->reset(vdev);
272
268 blk_cleanup_queue(vblk->disk->queue); 273 blk_cleanup_queue(vblk->disk->queue);
269 put_disk(vblk->disk); 274 put_disk(vblk->disk);
270 unregister_blkdev(major, "virtblk"); 275 unregister_blkdev(major, "virtblk");
271 mempool_destroy(vblk->pool); 276 mempool_destroy(vblk->pool);
272 /* There should be nothing in the queue now, so no need to shutdown */
273 vdev->config->del_vq(vblk->vq); 277 vdev->config->del_vq(vblk->vq);
274 kfree(vblk); 278 kfree(vblk);
275} 279}