From 0ba94b6f94a5b0bed9f125ce4c3348adc83db5de Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andreas=20F=C3=A4rber?= Date: Tue, 30 Jul 2013 04:05:02 +0200 Subject: [PATCH] virtio: Complete converting VirtioDevice to QOM realize MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Drop VirtioDeviceClass::init. Signed-off-by: Andreas Färber Signed-off-by: Paolo Bonzini --- hw/scsi/virtio-scsi.c | 3 +-- hw/virtio/virtio.c | 6 ------ include/hw/virtio/virtio.h | 5 +++-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 0a41ddb6c1..a208cf3d89 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -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); diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 4070b37d64..1dba284e4a 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -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); } diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 54c5efe4d0..6da88c0f41 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -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); -- 2.11.4.GIT