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: Andreas Färber
Subject: Re: [Qemu-devel] [PATCH 1/3] virtio: add bus_plugged() callback to VirtioDeviceClass
Date: Tue, 04 Jun 2013 19:35:32 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6

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?

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.,
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

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



reply via email to

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