From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ujv96-0000Rp-1j for qemu-devel@nongnu.org; Tue, 04 Jun 2013 13:35:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ujv8y-0007IL-Tk for qemu-devel@nongnu.org; Tue, 04 Jun 2013 13:35:43 -0400 Received: from cantor2.suse.de ([195.135.220.15]:42535 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ujv8y-0007I2-Ms for qemu-devel@nongnu.org; Tue, 04 Jun 2013 13:35:36 -0400 Message-ID: <51AE2564.4080705@suse.de> Date: Tue, 04 Jun 2013 19:35:32 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1370362965-3937-1-git-send-email-jlarrew@linux.vnet.ibm.com> <1370362965-3937-2-git-send-email-jlarrew@linux.vnet.ibm.com> In-Reply-To: <1370362965-3937-2-git-send-email-jlarrew@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/3] virtio: add bus_plugged() callback to VirtioDeviceClass List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jesse Larrew Cc: "Michael S. Tsirkin" , Stefan Hajnoczi , jasowang@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, Anthony Liguori , fred.konrad@greensocs.com Hi, Am 04.06.2013 18:22, schrieb Jesse Larrew: > Virtio devices are initialized prior to plugging them into a bus. Howev= er, > other initializations (such as host_features) don't occur until after t= he > 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. >=20 > This patch extends struct VirtioDeviceClass to add a bus_plugged() meth= od. > If implemented by a device, it will be called after the device is attac= hed > to a bus. >=20 > Signed-off-by: Jesse Larrew 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 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg