qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH for-next v2 20/22] virtio: Convert VirtioDevice to Q


From: Andreas Färber
Subject: [Qemu-devel] [PATCH for-next v2 20/22] virtio: Convert VirtioDevice to QOM realize
Date: Thu, 1 Aug 2013 04:17:41 +0200

Drop VirtioDevice::init.

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

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);
-- 
1.8.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]