From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:38986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RySLz-00022e-Vv for qemu-devel@nongnu.org; Fri, 17 Feb 2012 13:16:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RySLw-0002hD-3B for qemu-devel@nongnu.org; Fri, 17 Feb 2012 13:16:19 -0500 Received: from mail-pz0-f45.google.com ([209.85.210.45]:55059) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RySLv-0002gw-Ow for qemu-devel@nongnu.org; Fri, 17 Feb 2012 13:16:15 -0500 Received: by dadp14 with SMTP id p14so4287012dad.4 for ; Fri, 17 Feb 2012 10:16:14 -0800 (PST) Message-ID: <4F3E996A.9060006@redhat.com> Date: Fri, 17 Feb 2012 12:16:10 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1329443264-13819-1-git-send-email-afaerber@suse.de> <4F3DB4A1.10104@suse.de> In-Reply-To: <4F3DB4A1.10104@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH] qdev: Fix qdev_try_create() semantics List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= Cc: Peter Maydell , Alexander Graf , qemu-devel Developers , Igor Mammedov , Jan Kiszka On 02/16/2012 08:00 PM, Andreas Färber wrote: > Am 17.02.2012 02:47, schrieb Andreas Färber: >> Since QOM'ification, qdev_try_create() uses object_new() internally, >> which asserts "type != NULL" when the type is not registered. >> This was revealed by the combination of kvmclock's kvm_enabled() check >> and early QOM type registration. >> >> 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. >> >> Signed-off-by: Andreas Färber >> 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 Applied. Thanks. Regards, Anthony Liguori > > Andreas > >> --- >> hw/qdev.c | 3 +++ >> 1 files changed, 3 insertions(+), 0 deletions(-) >> >> 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 char *name) >> { >> DeviceState *dev; >> >> + if (object_class_by_name(name) == NULL) { >> + return NULL; >> + } >> dev = DEVICE(object_new(name)); >> if (!dev) { >> return NULL; >