qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 1/3] virtio: add bus_plugged() callback to Virti


From: Frederic Konrad
Subject: Re: [Qemu-devel] [PATCH 1/3] virtio: add bus_plugged() callback to VirtioDeviceClass
Date: Wed, 05 Jun 2013 17:09:01 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4

On 04/06/2013 19:35, Andreas Färber wrote:
Hi,

Am 04.06.2013 18:22, schrieb Jesse Larrew:
Virtio devices are initialized prior to plugging them into a bus. However,
other initializations (such as host_features) don't occur until after the
device is plugged into the bus. If a device needs to modify it's
configuration based on host_features, then it needs to be notified when the
bus is attached and host_features is available for use.

This patch extends struct VirtioDeviceClass to add a bus_plugged() method.
If implemented by a device, it will be called after the device is attached
to a bus.

Signed-off-by: Jesse Larrew <address@hidden>
I think this is backwards...

First of all, why is host_features not available before?

Hi Andreas,

The major issue here is that host_features is modified after virtio devices are inited.

in virtio_pci_device_plugged:
    proxy->host_features |= 0x1 << VIRTIO_F_NOTIFY_ON_EMPTY;
    proxy->host_features |= 0x1 << VIRTIO_F_BAD_FEATURE;
    proxy->host_features = virtio_bus_get_vdev_features(bus,
proxy->host_features);

and virtio_pci_device_plugged must be called after the virtio device is inited.

A hook on the bus makes sense because it allows central handling for any
devices on that bus.
However for a device, first TypeInfo::instance_init is run, then
qdev_set_parent_bus() connects the bus and finally DeviceClass::realize
is run - and we want to postpone realize further in the future.

So why can't this be in VirtioDevice's or VirtIONet's realize method? At
realize time we should definitely be on the bus in this case. I.e.,

Is that possible with hotplugging virtio device on virtio-mmio?
create vdev->config only after we know how large it needs to be rather
than creating and later resizing it, which might fail.

Regards,
Andreas

Fred



reply via email to

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