virtio: Complete converting VirtioDevice to QOM realize
authorAndreas Färber <afaerber@suse.de>
Tue, 30 Jul 2013 02:05:02 +0000 (04:05 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 9 Dec 2013 20:46:49 +0000 (21:46 +0100)
Drop VirtioDeviceClass::init.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/scsi/virtio-scsi.c
hw/virtio/virtio.c
include/hw/virtio/virtio.h

index 0a41ddb..a208cf3 100644 (file)
@@ -642,8 +642,7 @@ static void virtio_scsi_device_realize(DeviceState *dev, Error **errp)
 
 void virtio_scsi_common_exit(VirtIOSCSICommon *vs)
 {
-    VirtIODevice *vdev = VIRTIO_DEVICE(dev);
-    VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev);
+    VirtIODevice *vdev = VIRTIO_DEVICE(vs);
 
     g_free(vs->cmd_vqs);
     virtio_cleanup(vdev);
index 4070b37..1dba284 100644 (file)
@@ -1156,18 +1156,12 @@ static void virtio_device_realize(DeviceState *dev, Error **errp)
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(dev);
     Error *err = NULL;
 
-    assert(vdc->init != NULL || vdc->realize != NULL);
     if (vdc->realize != NULL) {
         vdc->realize(dev, &err);
         if (err != NULL) {
             error_propagate(errp, err);
             return;
         }
-    } else {
-        if (vdc->init(vdev) < 0) {
-            error_setg(errp, "Device initialization failed.");
-            return;
-        }
     }
     virtio_bus_device_plugged(vdev);
 }
index 54c5efe..6da88c0 100644 (file)
@@ -124,12 +124,13 @@ struct VirtIODevice
 };
 
 typedef struct VirtioDeviceClass {
+    /*< private >*/
     DeviceClass parent;
+    /*< public >*/
 
     /* This is what a VirtioDevice must implement */
-    int (*init)(VirtIODevice *vdev);
-    void (*exit)(VirtIODevice *vdev);
     DeviceRealize realize;
+    void (*exit)(VirtIODevice *vdev);
     uint32_t (*get_features)(VirtIODevice *vdev, uint32_t requested_features);
     uint32_t (*bad_features)(VirtIODevice *vdev);
     void (*set_features)(VirtIODevice *vdev, uint32_t val);