qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC PATCH v7 6/8] virtio-blk : Add the virtio-blk devi


From: Peter Maydell
Subject: Re: [Qemu-devel] [RFC PATCH v7 6/8] virtio-blk : Add the virtio-blk device.
Date: Tue, 11 Dec 2012 17:33:32 +0000

On 10 December 2012 16:45,  <address@hidden> wrote:
> From: KONRAD Frederic <address@hidden>
>
> 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



reply via email to

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