From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vq9Je-0001GO-SW for qemu-devel@nongnu.org; Mon, 09 Dec 2013 17:28:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vq9JW-0000EJ-Ff for qemu-devel@nongnu.org; Mon, 09 Dec 2013 17:28:38 -0500 Received: from mail-ea0-x230.google.com ([2a00:1450:4013:c01::230]:60989) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vq9JW-0000E7-9j for qemu-devel@nongnu.org; Mon, 09 Dec 2013 17:28:30 -0500 Received: by mail-ea0-f176.google.com with SMTP id h14so1856961eaj.35 for ; Mon, 09 Dec 2013 14:28:29 -0800 (PST) Sender: Paolo Bonzini Message-ID: <52A64403.5040709@redhat.com> Date: Mon, 09 Dec 2013 23:28:19 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1386349395-5710-1-git-send-email-imammedo@redhat.com> <1386349395-5710-8-git-send-email-imammedo@redhat.com> <52A20996.8020308@redhat.com> <20131209144139.7f9ac562@nial.usersys.redhat.com> <52A5C9D4.7080404@redhat.com> <20131209151431.57d49bd4@nial.usersys.redhat.com> <52A5D573.7010803@redhat.com> <20131209160834.59bfdc98@nial.usersys.redhat.com> <52A5DEE9.9030901@redhat.com> <20131209174856.5609760d@nial.usersys.redhat.com> <52A5FB72.8080307@redhat.com> <20131209221514.18acca99@thinkpad> In-Reply-To: <20131209221514.18acca99@thinkpad> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 7/7] hw/pci: convert PCI bus to use "hotplug-device" interface. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: peter.maydell@linaro.org, ehabkost@redhat.com, marcel.a@redhat.com, mst@redhat.com, qemu-devel@nongnu.org, blauwirbel@gmail.com, alex.williamson@redhat.com, anthony@codemonkey.ws, afaerber@suse.de Il 09/12/2013 22:15, Igor Mammedov ha scritto: >> > Check is idempotent, and can be called before realize makes any change >> > (it could also be called after the device is added to >> > /machine/unattached, it's not a big difference). >> > >> > Plug is called after realize. > PCIE case: "check" before realize will work since code that does check depends > only on hotplug device (i.e. PCIE slot) and do not access not yet realized > device at all. > > however > SHPC case: check code access pci_slot that is derived from PCIDevice.devfn, > which in turn could be initialized in realize() (see pci_qdev_init() devfn > auto allocation). So it's not possible to call check before realize() it > should be called from realize(). > > Perhaps other hotplug buses/devices have similar limitations, where it's not > fine to access device state from outside before calling it's realize(), so it > should be some post_realize() hook then to make it generic which leads to the > following: > if ->plug() called after realize() fails, all we need to do is to > fail "realize" property setter. That should cause > qdev_device_add() -> object_unparent() -> device_unparent() -> unrealize() > doing all necessary cleanup. If you can make it work, that'd be great. Otherwise, let's do it later, but please make a wiki page with a todo list. We already have too many items on the same critical path (hotplug, memdev, NUMA,...). Paolo