Patchwork [for-next,v2,20/22] virtio: Convert VirtioDevice to QOM realize

login
register
mail settings
Submitter Andreas Färber
Date Aug. 1, 2013, 2:17 a.m.
Message ID <1375323463-32747-21-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/263878/
State New
Headers show

Comments

Andreas Färber - Aug. 1, 2013, 2:17 a.m.
Drop VirtioDevice::init.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 hw/virtio/virtio.c         | 18 +++++-------------
 include/hw/virtio/virtio.h |  6 ++++--
 2 files changed, 9 insertions(+), 15 deletions(-)

Patch

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index c00c224..8f19095 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1139,37 +1139,29 @@  void virtio_device_set_child_bus_name(VirtIODevice *vdev, char *bus_name)
     }
 }
 
-static int virtio_device_init(DeviceState *dev)
+static void virtio_device_realize(DeviceState *dev, Error **errp)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
-    VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(dev);
 
-    if (vdc->init != NULL) {
-        if (vdc->init(vdev) < 0) {
-            return -1;
-        }
-    }
     virtio_bus_plug_device(vdev);
-    return 0;
 }
 
-static int virtio_device_exit(DeviceState *qdev)
+static void virtio_device_unrealize(DeviceState *dev, Error **errp)
 {
-    VirtIODevice *vdev = VIRTIO_DEVICE(qdev);
+    VirtIODevice *vdev = VIRTIO_DEVICE(dev);
 
     if (vdev->bus_name) {
         g_free(vdev->bus_name);
         vdev->bus_name = NULL;
     }
-    return 0;
 }
 
 static void virtio_device_class_init(ObjectClass *klass, void *data)
 {
     /* Set the default value here. */
     DeviceClass *dc = DEVICE_CLASS(klass);
-    dc->init = virtio_device_init;
-    dc->exit = virtio_device_exit;
+    dc->realize = virtio_device_realize;
+    dc->unrealize = virtio_device_unrealize;
     dc->bus_type = TYPE_VIRTIO_BUS;
 }
 
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index d7e9e0f..89b1793 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -124,9 +124,11 @@  struct VirtIODevice
 };
 
 typedef struct VirtioDeviceClass {
-    /* This is what a VirtioDevice must implement */
+    /*< private >*/
     DeviceClass parent;
-    int (*init)(VirtIODevice *vdev);
+    /*< public >*/
+
+    /* This is what a VirtioDevice must implement */
     uint32_t (*get_features)(VirtIODevice *vdev, uint32_t requested_features);
     uint32_t (*bad_features)(VirtIODevice *vdev);
     void (*set_features)(VirtIODevice *vdev, uint32_t val);