From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X48Bw-0003mK-Li for qemu-devel@nongnu.org; Mon, 07 Jul 2014 08:38:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X48Br-0000gt-Fb for qemu-devel@nongnu.org; Mon, 07 Jul 2014 08:38:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64015) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X48Br-0000gn-51 for qemu-devel@nongnu.org; Mon, 07 Jul 2014 08:38:39 -0400 Date: Mon, 7 Jul 2014 15:40:39 +0300 From: "Michael S. Tsirkin" Message-ID: <1404711994-18228-11-git-send-email-mst@redhat.com> References: <1404711994-18228-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1404711994-18228-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 10/12] 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 Cc: Peter Maydell , Eduardo Habkost , Markus Armbruster , Don Slutz , Stefan Hajnoczi , Igor Mammedov , =?us-ascii?B?PT9VVEYtOD9xP0FuZHJlYXM9MjBGPUMzPUE0cmJlcj89?= , Anthony Liguori From: Eduardo Habkost 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 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Signed-off-by: Eduardo Habkost Tested-by: Don Slutz --- 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); -- MST