From mboxrd@z Thu Jan 1 00:00:00 1970 From: Amit Shah Subject: [RFC PATCH 7/8] virtio: block: Add freeze, restore handlers to support S4 Date: Thu, 28 Jul 2011 20:05:12 +0530 Message-ID: <0a018de7cac2a27bf28287da64850729ec62e1e5.1311863438.git.amit.shah@redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: In-Reply-To: References: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org To: Virtualization List Cc: Amit Shah , "Michael S. Tsirkin" List-Id: virtualization@lists.linuxfoundation.org Delete the vq on the freeze callback to prepare for hibernation. Re-create the vq in the restore callback to resume normal function. Signed-off-by: Amit Shah --- drivers/block/virtio_blk.c | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 079c088..700ad76 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -540,6 +540,26 @@ static void __devexit virtblk_remove(struct virtio_device *vdev) kfree(vblk); } +#ifdef CONFIG_PM +static int virtblk_freeze(struct virtio_device *vdev) +{ + vdev->config->del_vqs(vdev); + return 0; +} + +static int virtblk_restore(struct virtio_device *vdev) +{ + struct virtio_blk *vblk = vdev->priv; + int err = 0; + + vblk->vq = virtio_find_single_vq(vdev, blk_done, "requests"); + if (IS_ERR(vblk->vq)) + err = PTR_ERR(vblk->vq); + + return err; +} +#endif + static const struct virtio_device_id id_table[] = { { VIRTIO_ID_BLOCK, VIRTIO_DEV_ANY_ID }, { 0 }, @@ -565,6 +585,10 @@ static struct virtio_driver __refdata virtio_blk = { .probe = virtblk_probe, .remove = __devexit_p(virtblk_remove), .config_changed = virtblk_config_changed, +#ifdef CONFIG_PM + .freeze = virtblk_freeze, + .restore = virtblk_restore, +#endif }; static int __init init(void) -- 1.7.6