diff options
Diffstat (limited to 'drivers/virtio/virtio_balloon.c')
-rw-r--r-- | drivers/virtio/virtio_balloon.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 3368cb6ef193..95aeedf198f8 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c | |||
@@ -364,6 +364,48 @@ static void __devexit virtballoon_remove(struct virtio_device *vdev) | |||
364 | kfree(vb); | 364 | kfree(vb); |
365 | } | 365 | } |
366 | 366 | ||
367 | #ifdef CONFIG_PM | ||
368 | static int virtballoon_freeze(struct virtio_device *vdev) | ||
369 | { | ||
370 | /* | ||
371 | * The kthread is already frozen by the PM core before this | ||
372 | * function is called. | ||
373 | */ | ||
374 | |||
375 | /* Ensure we don't get any more requests from the host */ | ||
376 | vdev->config->reset(vdev); | ||
377 | vdev->config->del_vqs(vdev); | ||
378 | return 0; | ||
379 | } | ||
380 | |||
381 | static int virtballoon_thaw(struct virtio_device *vdev) | ||
382 | { | ||
383 | return init_vqs(vdev->priv); | ||
384 | } | ||
385 | |||
386 | static int virtballoon_restore(struct virtio_device *vdev) | ||
387 | { | ||
388 | struct virtio_balloon *vb = vdev->priv; | ||
389 | struct page *page, *page2; | ||
390 | |||
391 | /* We're starting from a clean slate */ | ||
392 | vb->num_pages = 0; | ||
393 | |||
394 | /* | ||
395 | * If a request wasn't complete at the time of freezing, this | ||
396 | * could have been set. | ||
397 | */ | ||
398 | vb->need_stats_update = 0; | ||
399 | |||
400 | /* We don't have these pages in the balloon anymore! */ | ||
401 | list_for_each_entry_safe(page, page2, &vb->pages, lru) { | ||
402 | list_del(&page->lru); | ||
403 | totalram_pages++; | ||
404 | } | ||
405 | return init_vqs(vdev->priv); | ||
406 | } | ||
407 | #endif | ||
408 | |||
367 | static unsigned int features[] = { | 409 | static unsigned int features[] = { |
368 | VIRTIO_BALLOON_F_MUST_TELL_HOST, | 410 | VIRTIO_BALLOON_F_MUST_TELL_HOST, |
369 | VIRTIO_BALLOON_F_STATS_VQ, | 411 | VIRTIO_BALLOON_F_STATS_VQ, |
@@ -378,6 +420,11 @@ static struct virtio_driver virtio_balloon_driver = { | |||
378 | .probe = virtballoon_probe, | 420 | .probe = virtballoon_probe, |
379 | .remove = __devexit_p(virtballoon_remove), | 421 | .remove = __devexit_p(virtballoon_remove), |
380 | .config_changed = virtballoon_changed, | 422 | .config_changed = virtballoon_changed, |
423 | #ifdef CONFIG_PM | ||
424 | .freeze = virtballoon_freeze, | ||
425 | .restore = virtballoon_restore, | ||
426 | .thaw = virtballoon_thaw, | ||
427 | #endif | ||
381 | }; | 428 | }; |
382 | 429 | ||
383 | static int __init init(void) | 430 | static int __init init(void) |