From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:43793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RyD7I-0005mj-Sj for qemu-devel@nongnu.org; Thu, 16 Feb 2012 21:00:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RyD7E-0002DT-Nm for qemu-devel@nongnu.org; Thu, 16 Feb 2012 21:00:08 -0500 Received: from cantor2.suse.de ([195.135.220.15]:58537 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RyD7E-0002Bs-Iw for qemu-devel@nongnu.org; Thu, 16 Feb 2012 21:00:04 -0500 Message-ID: <4F3DB4A1.10104@suse.de> Date: Fri, 17 Feb 2012 03:00:01 +0100 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1329443264-13819-1-git-send-email-afaerber@suse.de> In-Reply-To: <1329443264-13819-1-git-send-email-afaerber@suse.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] qdev: Fix qdev_try_create() semantics List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel Developers Cc: Peter Maydell , Jan Kiszka , Alexander Graf , Igor Mammedov Am 17.02.2012 02:47, schrieb Andreas F=C3=A4rber: > Since QOM'ification, qdev_try_create() uses object_new() internally, > which asserts "type !=3D NULL" when the type is not registered. > This was revealed by the combination of kvmclock's kvm_enabled() check > and early QOM type registration. >=20 > Check whether the class exists before calling object_new(), so that > the caller (e.g., qdev_create) can fail gracefully, telling us which > device could not be created. >=20 > Signed-off-by: Andreas F=C3=A4rber > Cc: Anthony Liguori Er, it's late here... ;) As one can guess I've managed to convert x86. Still need to cleanup but I pushed my work branch for the curious (and as backup!): http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/qom-cpu Andreas > --- > hw/qdev.c | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) >=20 > diff --git a/hw/qdev.c b/hw/qdev.c > index f0eb3a7..ee21d90 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -117,6 +117,9 @@ DeviceState *qdev_try_create(BusState *bus, const c= har *name) > { > DeviceState *dev; > =20 > + if (object_class_by_name(name) =3D=3D NULL) { > + return NULL; > + } > dev =3D DEVICE(object_new(name)); > if (!dev) { > return NULL; --=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