9ae3a8
From 9813363c031fd56a536dfafd64dcc9bc430f9bb1 Mon Sep 17 00:00:00 2001
9ae3a8
From: Markus Armbruster <armbru@redhat.com>
9ae3a8
Date: Thu, 23 Jan 2014 14:03:38 +0100
9ae3a8
Subject: [PATCH 11/14] virtio-balloon: switch exit callback to VirtioDeviceClass
9ae3a8
9ae3a8
RH-Author: Markus Armbruster <armbru@redhat.com>
9ae3a8
Message-id: <1390485820-7585-9-git-send-email-armbru@redhat.com>
9ae3a8
Patchwork-id: 56930
9ae3a8
O-Subject: [PATCH 7.0 qemu-kvm 08/10] virtio-balloon: switch exit callback to VirtioDeviceClass
9ae3a8
Bugzilla: 983344
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
9ae3a8
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
9ae3a8
From: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
9ae3a8
This ensures hot-unplug is handled properly by the proxy, and avoids
9ae3a8
leaking bus_name which is freed by virtio_device_exit.
9ae3a8
9ae3a8
Cc: qemu-stable@nongnu.org
9ae3a8
Acked-by: Andreas Faerber <afaerber@suse.de>
9ae3a8
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
(cherry picked from commit baa61b9870dd7e0bb07e0ae61c6ec805db13f699)
9ae3a8
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9ae3a8
---
9ae3a8
 hw/virtio/virtio-balloon.c | 10 ++++------
9ae3a8
 1 file changed, 4 insertions(+), 6 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/virtio/virtio-balloon.c |   10 ++++------
9ae3a8
 1 files changed, 4 insertions(+), 6 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
9ae3a8
index 85661f6..76c607f 100644
9ae3a8
--- a/hw/virtio/virtio-balloon.c
9ae3a8
+++ b/hw/virtio/virtio-balloon.c
9ae3a8
@@ -369,16 +369,14 @@ static int virtio_balloon_device_init(VirtIODevice *vdev)
9ae3a8
     return 0;
9ae3a8
 }
9ae3a8
 
9ae3a8
-static int virtio_balloon_device_exit(DeviceState *qdev)
9ae3a8
+static void virtio_balloon_device_exit(VirtIODevice *vdev)
9ae3a8
 {
9ae3a8
-    VirtIOBalloon *s = VIRTIO_BALLOON(qdev);
9ae3a8
-    VirtIODevice *vdev = VIRTIO_DEVICE(qdev);
9ae3a8
+    VirtIOBalloon *s = VIRTIO_BALLOON(vdev);
9ae3a8
 
9ae3a8
     balloon_stats_destroy_timer(s);
9ae3a8
     qemu_remove_balloon_handler(s);
9ae3a8
-    unregister_savevm(qdev, "virtio-balloon", s);
9ae3a8
+    unregister_savevm(DEVICE(vdev), "virtio-balloon", s);
9ae3a8
     virtio_cleanup(vdev);
9ae3a8
-    return 0;
9ae3a8
 }
9ae3a8
 
9ae3a8
 static Property virtio_balloon_properties[] = {
9ae3a8
@@ -389,10 +387,10 @@ static void virtio_balloon_class_init(ObjectClass *klass, void *data)
9ae3a8
 {
9ae3a8
     DeviceClass *dc = DEVICE_CLASS(klass);
9ae3a8
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
9ae3a8
-    dc->exit = virtio_balloon_device_exit;
9ae3a8
     dc->props = virtio_balloon_properties;
9ae3a8
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
9ae3a8
     vdc->init = virtio_balloon_device_init;
9ae3a8
+    vdc->exit = virtio_balloon_device_exit;
9ae3a8
     vdc->get_config = virtio_balloon_get_config;
9ae3a8
     vdc->set_config = virtio_balloon_set_config;
9ae3a8
     vdc->get_features = virtio_balloon_get_features;
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8