virtio_blk: enable VQs early on restore
authorMichael S. Tsirkin <mst@redhat.com>
Tue, 14 Oct 2014 23:52:32 +0000 (10:22 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 14 Oct 2014 23:55:07 +0000 (10:25 +1030)
virtio spec requires drivers to set DRIVER_OK before using VQs.
This is set automatically after restore returns, virtio block violated
this rule on restore by restarting queues, which might in theory
cause the VQ to be used directly within restore.

To fix, call virtio_device_ready before using starting queues.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
drivers/block/virtio_blk.c

index 34ec273b1d4698d51f15240dc4ee09ee13bb1af1..930fee886917364eba53b35fa8c25079fcda25ff 100644 (file)
@@ -804,10 +804,13 @@ static int virtblk_restore(struct virtio_device *vdev)
        int ret;
 
        ret = init_vq(vdev->priv);
-       if (!ret)
-               blk_mq_start_stopped_hw_queues(vblk->disk->queue, true);
+       if (ret)
+               return ret;
+
+       virtio_device_ready(vdev);
 
-       return ret;
+       blk_mq_start_stopped_hw_queues(vblk->disk->queue, true);
+       return 0;
 }
 #endif