From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2omP-0002ir-KL for qemu-devel@nongnu.org; Thu, 03 Jul 2014 17:43:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X2omJ-0001QG-Gk for qemu-devel@nongnu.org; Thu, 03 Jul 2014 17:42:57 -0400 Received: from omzsmtpe04.verizonbusiness.com ([199.249.25.207]:8881) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2omJ-0001KG-BE for qemu-devel@nongnu.org; Thu, 03 Jul 2014 17:42:51 -0400 From: Don Slutz Message-ID: <53B5CE55.1010202@terremark.com> Date: Thu, 03 Jul 2014 17:42:45 -0400 MIME-Version: 1.0 References: <1404416735-22371-1-git-send-email-ehabkost@redhat.com> <1404416735-22371-3-git-send-email-ehabkost@redhat.com> <53B5BC36.2030507@redhat.com> In-Reply-To: <53B5BC36.2030507@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH for-2.1 2/2] qdev: Fix crash when using non-device class name on -global List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , Eduardo Habkost , qemu-devel@nongnu.org, =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= Cc: Peter Maydell , "Michael S. Tsirkin" , Markus Armbruster , Don Slutz , Paolo Bonzini , Igor Mammedov On 07/03/14 16:25, Eric Blake wrote: > On 07/03/2014 01:45 PM, Eduardo Habkost wrote: >> This fixes the following crash: >> >> $ qemu-system-x86_64 -global container.xxx=y >> hw/core/qdev-properties-system.c:399:qdev_add_one_global: Object 0x7f7eff234100 is not an instance of type device >> Aborted (core dumped) >> >> New behavior will be to just warn, just like when non-existing clas > s/clas/class/ > >> names are used: >> >> $ qemu-system-x86_64 -global container.xxx=y >> qemu-system-x86_64: Warning: "-global container.xxx=y" not used >> >> Signed-off-by: Eduardo Habkost >> --- >> hw/core/qdev-properties-system.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c >> index 8e140af..ae0900f 100644 >> --- a/hw/core/qdev-properties-system.c >> +++ b/hw/core/qdev-properties-system.c >> @@ -394,7 +394,8 @@ static int qdev_add_one_global(QemuOpts *opts, void *opaque) >> g->driver = qemu_opt_get(opts, "driver"); >> g->property = qemu_opt_get(opts, "property"); >> g->value = qemu_opt_get(opts, "value"); >> - oc = object_class_by_name(g->driver); >> + oc = object_class_dynamic_cast(object_class_by_name(g->driver), >> + TYPE_DEVICE); >> if (oc) { >> DeviceClass *dc = DEVICE_CLASS(oc); > I'm not an expert on the type system, but this one looks simple enough > that I don't mind: > > Reviewed-by: Eric Blake > Looks good to me also, and it passes my quick tests. Tested-by: Don Slutz -Don Slutz