Received: from eggs.gnu.org ([2001:4830:134:3::10]:35858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2mxC-0001M4-AP for qemu-devel@nongnu.org; Thu, 03 Jul 2014 15:46:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X2mx6-0001JV-6C for qemu-devel@nongnu.org; Thu, 03 Jul 2014 15:45:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63011) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2mx5-0001JO-Ti for qemu-devel@nongnu.org; Thu, 03 Jul 2014 15:45:52 -0400 From: Eduardo Habkost Date: Thu, 3 Jul 2014 16:45:35 -0300 Message-Id: <1404416735-22371-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1404416735-22371-1-git-send-email-ehabkost@redhat.com> References: <1404416735-22371-1-git-send-email-ehabkost@redhat.com> Subject: [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: qemu-devel@nongnu.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= Cc: Peter Maydell , "Michael S. Tsirkin" , Markus Armbruster , Don Slutz , Paolo Bonzini , Igor Mammedov 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 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); -- 1.9.3