From patchwork Fri May 24 18:44:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 1105092 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 459b0f18cnz9s9y for ; Sat, 25 May 2019 04:45:38 +1000 (AEST) Received: from localhost ([127.0.0.1]:58757 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hUFCC-0006XB-4V for incoming@patchwork.ozlabs.org; Fri, 24 May 2019 14:45:36 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hUFBb-0006Vf-Qm for qemu-devel@nongnu.org; Fri, 24 May 2019 14:45:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hUFBa-0005py-6v for qemu-devel@nongnu.org; Fri, 24 May 2019 14:44:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55576) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hUFBY-0005lC-6E for qemu-devel@nongnu.org; Fri, 24 May 2019 14:44:57 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 23F073086268; Fri, 24 May 2019 18:44:54 +0000 (UTC) Received: from localhost (ovpn-116-14.gru2.redhat.com [10.97.116.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F2EF7D925; Fri, 24 May 2019 18:44:51 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 24 May 2019 15:44:31 -0300 Message-Id: <20190524184447.16678-2-ehabkost@redhat.com> In-Reply-To: <20190524184447.16678-1-ehabkost@redhat.com> References: <20190524184447.16678-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 24 May 2019 18:44:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/17] qom/object: Display more helpful message when an object type is missing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé When writing a new board, adding device which uses other devices (container) or simply refactoring, one can discover the hard way his machine misses some devices. In the case of containers, the error is not obvious: $ qemu-system-microblaze -M xlnx-zynqmp-pmu ** ERROR:/source/qemu/qom/object.c:454:object_initialize_with_type: assertion failed: (type != NULL) Aborted (core dumped) And we have to look at the coredump to figure the error: (gdb) bt #1 0x00007f84773cf895 in abort () at /lib64/libc.so.6 #2 0x00007f847961fb53 in () at /lib64/libglib-2.0.so.0 #3 0x00007f847967a4de in g_assertion_message_expr () at /lib64/libglib-2.0.so.0 #4 0x000055c4bcac6c11 in object_initialize_with_type (data=data@entry=0x55c4bdf239e0, size=size@entry=2464, type=) at /source/qemu/qom/object.c:454 #5 0x000055c4bcac6e6d in object_initialize (data=data@entry=0x55c4bdf239e0, size=size@entry=2464, typename=typename@entry=0x55c4bcc7c643 "xlnx.zynqmp_ipi") at /source/qemu/qom/object.c:474 #6 0x000055c4bc9ea474 in xlnx_zynqmp_pmu_init (machine=0x55c4bdd46000) at /source/qemu/hw/microblaze/xlnx-zynqmp-pmu.c:176 #7 0x000055c4bca3b6cb in machine_run_board_init (machine=0x55c4bdd46000) at /source/qemu/hw/core/machine.c:1030 #8 0x000055c4bc95f6d2 in main (argc=, argv=, envp=) at /source/qemu/vl.c:4479 Since the caller knows the type name requested, we can simply display it to ease development. With this patch applied we get: $ qemu-system-microblaze -M xlnx-zynqmp-pmu qemu-system-microblaze: missing object type 'xlnx.zynqmp_ipi' Aborted (core dumped) Since the assert(type) check in object_initialize_with_type() is now impossible, remove it. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190427135642.16464-1-philmd@redhat.com> Reviewed-by: Cornelia Huck Reviewed-by: Stefano Garzarella Reviewed-by: Daniel P. Berrangé Signed-off-by: Eduardo Habkost --- qom/object.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/qom/object.c b/qom/object.c index 99c4fa707e..3966a3d461 100644 --- a/qom/object.c +++ b/qom/object.c @@ -28,6 +28,7 @@ #include "qapi/qmp/qbool.h" #include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" +#include "qemu/error-report.h" #define MAX_INTERFACES 32 @@ -448,7 +449,6 @@ static void object_initialize_with_type(void *data, size_t size, TypeImpl *type) { Object *obj = data; - g_assert(type != NULL); type_initialize(type); g_assert(type->instance_size >= sizeof(Object)); @@ -468,6 +468,11 @@ void object_initialize(void *data, size_t size, const char *typename) { TypeImpl *type = type_get_by_name(typename); + if (!type) { + error_report("missing object type '%s'", typename); + abort(); + } + object_initialize_with_type(data, size, type); }