virtio: Complete converting VirtioDevice to QOM realize
Drop VirtioDeviceClass::init. Signed-off-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
71a6520b83
commit
0ba94b6f94
@ -642,8 +642,7 @@ static void virtio_scsi_device_realize(DeviceState *dev, Error **errp)
|
|||||||
|
|
||||||
void virtio_scsi_common_exit(VirtIOSCSICommon *vs)
|
void virtio_scsi_common_exit(VirtIOSCSICommon *vs)
|
||||||
{
|
{
|
||||||
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
|
VirtIODevice *vdev = VIRTIO_DEVICE(vs);
|
||||||
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev);
|
|
||||||
|
|
||||||
g_free(vs->cmd_vqs);
|
g_free(vs->cmd_vqs);
|
||||||
virtio_cleanup(vdev);
|
virtio_cleanup(vdev);
|
||||||
|
@ -1156,18 +1156,12 @@ static void virtio_device_realize(DeviceState *dev, Error **errp)
|
|||||||
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(dev);
|
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(dev);
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
|
|
||||||
assert(vdc->init != NULL || vdc->realize != NULL);
|
|
||||||
if (vdc->realize != NULL) {
|
if (vdc->realize != NULL) {
|
||||||
vdc->realize(dev, &err);
|
vdc->realize(dev, &err);
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
error_propagate(errp, err);
|
error_propagate(errp, err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (vdc->init(vdev) < 0) {
|
|
||||||
error_setg(errp, "Device initialization failed.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
virtio_bus_device_plugged(vdev);
|
virtio_bus_device_plugged(vdev);
|
||||||
}
|
}
|
||||||
|
@ -124,12 +124,13 @@ struct VirtIODevice
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef struct VirtioDeviceClass {
|
typedef struct VirtioDeviceClass {
|
||||||
|
/*< private >*/
|
||||||
DeviceClass parent;
|
DeviceClass parent;
|
||||||
|
/*< public >*/
|
||||||
|
|
||||||
/* This is what a VirtioDevice must implement */
|
/* This is what a VirtioDevice must implement */
|
||||||
int (*init)(VirtIODevice *vdev);
|
|
||||||
void (*exit)(VirtIODevice *vdev);
|
|
||||||
DeviceRealize realize;
|
DeviceRealize realize;
|
||||||
|
void (*exit)(VirtIODevice *vdev);
|
||||||
uint32_t (*get_features)(VirtIODevice *vdev, uint32_t requested_features);
|
uint32_t (*get_features)(VirtIODevice *vdev, uint32_t requested_features);
|
||||||
uint32_t (*bad_features)(VirtIODevice *vdev);
|
uint32_t (*bad_features)(VirtIODevice *vdev);
|
||||||
void (*set_features)(VirtIODevice *vdev, uint32_t val);
|
void (*set_features)(VirtIODevice *vdev, uint32_t val);
|
||||||
|
Loading…
Reference in New Issue
Block a user