Received: from eggs.gnu.org ([2001:4830:134:3::10]:56427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnNxy-0006KR-Mp for qemu-devel@nongnu.org; Mon, 02 Dec 2013 02:30:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VnNxt-0003HQ-QL for qemu-devel@nongnu.org; Mon, 02 Dec 2013 02:30:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:7840) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnNxt-0003HL-IL for qemu-devel@nongnu.org; Mon, 02 Dec 2013 02:30:45 -0500 From: Markus Armbruster References: <1385718225-26379-1-git-send-email-armbru@redhat.com> <1385903630.23603.7.camel@localhost.localdomain> <529B526C.9020502@suse.de> Date: Mon, 02 Dec 2013 08:30:35 +0100 In-Reply-To: <529B526C.9020502@suse.de> ("Andreas =?utf-8?Q?F=C3=A4rber=22?= =?utf-8?Q?'s?= message of "Sun, 01 Dec 2013 16:14:52 +0100") Message-ID: <87eh5vzp44.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 0/2] Pointer properties and device_add List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?utf-8?Q?F=C3=A4rber?= Cc: peter.maydell@linaro.org, Marcel Apfelbaum , qemu-devel@nongnu.org, chouteau@adacore.com, blauwirbel@gmail.com, kraxel@redhat.com, aliguori@amazon.com, Paolo Bonzini , edgar.iglesias@gmail.com Andreas F=C3=A4rber writes: > Am 01.12.2013 14:13, schrieb Marcel Apfelbaum: >> On Fri, 2013-11-29 at 10:43 +0100, armbru@redhat.com wrote: >>> From: Markus Armbruster >>> >>> Pointer properties can be set only by code, not by device_add. A >>> device with a pointer property can't work with device_add only unless >>> the property may remain null. cannot_instantiate_with_device_add_yet >>> needs to be set then. PATCH 1/2 sets it when needed and else >>> documents why not. PATCH 2/2 documents this for future users of >>> pointer properties. >>> >>> This applies on top of my "[PATCH v4 00/10] Clean up and fix no_user" >>> series. >>=20 >> Even that I am not familiar with this code, I've checked all the changes >> and I agree with them. >>=20 >> Reviewed-by: Marcel Apfelbaum >>=20 >> Anyway, I do have a question: >> Why not asserting on qdev_device_add if we have a pointer property? This is a really good thought. In fact, it occurred to me, too. However, see "unless the property may remain null" above: there are uses of pointer properties that do *not* make the device unusable with device_add. We even have an example: etraxfs,pic; see PATCH 1/1. It's a sysbus device, so it's unavailable anyway. But there certainly could be a device with an optional property that does not and should not have cannot_instantiate_with_device_add_yet set. > When we do device_add / device-add, the guest is usually running and we > shouldn't kill a running guest just because the user is trying something > stupid that we can easily prevent. ;) You have a point on assert(bad_input), but this would be assert(programming_error), where the error is "device doesn't have cannot_instantiate_with_device_add_yet set". I'm advocating to be ruthless with programming error asserts. > The alternative BTW is dropping all those pointer properties and > replacing them with link<> properties. Paolo tried that for the OMAP > timers once but I fear that series was never picked up...? /* FIXME: Remove opaque pointer properties. */ /* Not a proper property, just for dirty hacks. TODO Remove it! */ :) >> Instead of checking only cannot_instantiate_with_device_add_yet, >> we can go over properties and if we have a pointer property, assert or >> return... > > Raising an error for certain property types may be an option. Although > theoretically the existence of an incompatible property would not > necessarily indicate incompatibility to instantiate the device, in > practice I believe we don't have such excess properties. We don't have them now. I hope we won't permit any new pointer properties. If you guys want pointer property imply its owner's cannot_instantiate_with_device_add_yet, even though it's not generally necessary, I'm fine with that. [...]