On 10 December 2012 16:45, <[email protected]> wrote:
> From: KONRAD Frederic <[email protected]>
>
> Create virtio-blk which extends virtio-device, so it can be connected on
> virtio-bus.
> +static int virtio_device_init(DeviceState *qdev)
> +{
This is a not a very well named function. It's blk specific
but the function name implies it is generic virtio.
> + VirtIODevice *vdev = VIRTIO_DEVICE(qdev);
> + VirtIOBlock *s = VIRTIO_BLK(qdev);
> +
> + VirtIOBlkConf *blk = &(s->blk);
> +
> + virtio_blk_common_init(qdev, blk, &s);
> +
> + virtio_bus_plug_device(vdev);
This doesn't look right. A subclass of VirtIODevice
shouldn't have to do anything specific to plug itself in.
You can make the VirtIODevice's DeviceClass::init function
do that. (compare the way PCIDevice's init function
handles registering the device with the bus and hotplugging
it if the bus does hotplug.)
-- PMM