[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/17] qom/object: Display more helpful message when
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PULL 01/17] qom/object: Display more helpful message when an object type is missing |
Date: |
Fri, 24 May 2019 15:44:31 -0300 |
From: Philippe Mathieu-Daudé <address@hidden>
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 (address@hidden,
address@hidden, type=<optimized out>) at /source/qemu/qom/object.c:454
#5 0x000055c4bcac6e6d in object_initialize (address@hidden, address@hidden,
address@hidden "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=<optimized out>, argv=<optimized out>,
envp=<optimized out>) 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é <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Cornelia Huck <address@hidden>
Reviewed-by: Stefano Garzarella <address@hidden>
Reviewed-by: Daniel P. Berrangé <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>
---
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);
}
--
2.18.0.rc1.1.g3f1ff2140
- [Qemu-devel] [PULL 00/17] Machine Core queue, 2019-05-24, Eduardo Habkost, 2019/05/24
- [Qemu-devel] [PULL 01/17] qom/object: Display more helpful message when an object type is missing,
Eduardo Habkost <=
- [Qemu-devel] [PULL 02/17] hw/ppc/pnv: Use object_initialize_child for correct reference counting, Eduardo Habkost, 2019/05/24
- [Qemu-devel] [PULL 03/17] hw/misc/macio: Use object_initialize_child for correct ref. counting, Eduardo Habkost, 2019/05/24
- [Qemu-devel] [PULL 04/17] hw/virtio: Use object_initialize_child for correct reference counting, Eduardo Habkost, 2019/05/24
- [Qemu-devel] [PULL 05/17] hw/arm/bcm2835: Use TYPE_PL011 instead of hardcoded string, Eduardo Habkost, 2019/05/24
- [Qemu-devel] [PULL 06/17] hw/arm/bcm2835: Use object_initialize() on PL011State, Eduardo Habkost, 2019/05/24
- [Qemu-devel] [PULL 07/17] hw/arm/bcm2835: Use object_initialize_child for correct ref. counting, Eduardo Habkost, 2019/05/24
- [Qemu-devel] [PULL 08/17] hw/arm/aspeed: Use object_initialize_child for correct ref. counting, Eduardo Habkost, 2019/05/24
- [Qemu-devel] [PULL 09/17] hw/arm: Use object_initialize_child for correct reference counting, Eduardo Habkost, 2019/05/24
- [Qemu-devel] [PULL 10/17] hw/mips: Use object_initialize() on MIPSCPSState, Eduardo Habkost, 2019/05/24
- [Qemu-devel] [PULL 12/17] hw/microblaze/zynqmp: Move the IPI state into the PMUSoC state, Eduardo Habkost, 2019/05/24