From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47762) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsDHl-0003uV-KY for qemu-devel@nongnu.org; Mon, 07 Jan 2013 09:02:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TsDHk-0005C7-Aa for qemu-devel@nongnu.org; Mon, 07 Jan 2013 09:02:41 -0500 Received: from cantor2.suse.de ([195.135.220.15]:34749 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsDHk-0005C2-13 for qemu-devel@nongnu.org; Mon, 07 Jan 2013 09:02:40 -0500 Message-ID: <50EAD57B.8040905@suse.de> Date: Mon, 07 Jan 2013 15:02:35 +0100 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1357320880-10782-1-git-send-email-afaerber@suse.de> <20130107144700.1cc540d4@thinkpad.mammed.net> In-Reply-To: <20130107144700.1cc540d4@thinkpad.mammed.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2] qdev: Don't assume existence of parent bus on unparenting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: Paolo Bonzini , qemu-devel@nongnu.org, anthony@codemonkey.ws, ehabkost@redhat.com Am 07.01.2013 14:47, schrieb Igor Mammedov: > On Fri, 4 Jan 2013 18:34:40 +0100 > Andreas F=C3=A4rber wrote: >=20 >> Commit 667d22d1ae59da46b4c1fbd094ca61145f19b8c3 (qdev: move bus remova= l >> to object_unparent) made the assumption that at unparenting time >> parent_bus is not NULL. This assumption is unjustified since >> object_unparent() may well be called directly after object_initialize(= ), >> without any qdev_set_parent_bus(). >> >> This did not cause any issues yet because qdev_[try_]create() does cal= l >> qdev_set_parent_bus(), falling back to SysBus if unsupplied. >> >> While at it, ensure that this new function uses the device_ prefix and >> make the name more neutral in light of this semantic change. >> >> Reported-by: Eduardo Habkost >> Signed-off-by: Andreas F=C3=A4rber >> Cc: Paolo Bonzini >> --- >> Planning to insert this before the final CPU-as-a-device patch on qom= -cpu, >> to avoid a regression for, e.g., -cpu Haswell,enforce if unsupported = by host. >> >> This supersedes my cosmetic patch in the "QOM realize, device-only" s= eries: >> >> v1 -> v2: >> * Make bus removal conditional on parent bus >> * Rename function further >> >> hw/qdev.c | 8 +++++--- >> 1 Datei ge=C3=A4ndert, 5 Zeilen hinzugef=C3=BCgt(+), 3 Zeilen entfern= t(-) >> >> diff --git a/hw/qdev.c b/hw/qdev.c >> index f2c2484..e2a5c57 100644 >> --- a/hw/qdev.c >> +++ b/hw/qdev.c >> @@ -698,16 +698,18 @@ static void device_class_base_init(ObjectClass *= class, void *data) >> klass->props =3D NULL; >> } >> =20 >> -static void qdev_remove_from_bus(Object *obj) >> +static void device_unparent(Object *obj) >> { >> DeviceState *dev =3D DEVICE(obj); >> =20 >> - bus_remove_child(dev->parent_bus, dev); >> + if (dev->parent_bus !=3D NULL) { >> + bus_remove_child(dev->parent_bus, dev); >> + } >> } >> =20 >> static void device_class_init(ObjectClass *class, void *data) >> { >> - class->unparent =3D qdev_remove_from_bus; >> + class->unparent =3D device_unparent; >> } >> =20 >> void device_reset(DeviceState *dev) >> --=20 >> 1.7.10.4 >> >> > Works for me, >=20 > Tested-By: Igor Mammedov Thanks, inserted into qom-cpu queue: https://github.com/afaerber/qemu-cpu/commits/qom-cpu Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer; HRB 16746 AG N=C3=BC= rnberg