qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Frederic Konrad <fred.konrad@greensocs.com>
To: "Andreas Färber" <afaerber@suse.de>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	Stefan Hajnoczi <stefanha@gmail.com>,
	jasowang@redhat.com, Jesse Larrew <jlarrew@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com,
	Anthony Liguori <anthony@codemonkey.ws>
Subject: Re: [Qemu-devel] [PATCH 1/3] virtio: add bus_plugged() callback to VirtioDeviceClass
Date: Wed, 05 Jun 2013 17:09:01 +0200	[thread overview]
Message-ID: <51AF548D.70007@greensocs.com> (raw)
In-Reply-To: <51AE2564.4080705@suse.de>

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 <jlarrew@linux.vnet.ibm.com>
> 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

  parent reply	other threads:[~2013-06-05 15:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-04 16:22 [Qemu-devel] [PATCH 0/3] Notify devices when a bus is attached Jesse Larrew
2013-06-04 16:22 ` [Qemu-devel] [PATCH 1/3] virtio: add bus_plugged() callback to VirtioDeviceClass Jesse Larrew
2013-06-04 17:35   ` Andreas Färber
2013-06-04 20:02     ` Jesse Larrew
2013-06-05 15:18       ` Frederic Konrad
2013-06-05 15:09     ` Frederic Konrad [this message]
2013-06-04 16:22 ` [Qemu-devel] [PATCH 2/3] virtio-net: implement bus_plugged() Jesse Larrew
2013-06-04 16:22 ` [Qemu-devel] [PATCH 3/3] virtio-net: revert MAC address workaround Jesse Larrew

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51AF548D.70007@greensocs.com \
    --to=fred.konrad@greensocs.com \
    --cc=afaerber@suse.de \
    --cc=anthony@codemonkey.ws \
    --cc=jasowang@redhat.com \
    --cc=jlarrew@linux.vnet.ibm.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).