qemu-e2k/qom
Philippe Mathieu-Daudé e02bdf1cec qom/object: Display more helpful message when an object type is missing
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=<optimized out>) 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=<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é <philmd@redhat.com>
Message-Id: <20190427135642.16464-1-philmd@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-05-24 15:29:02 -03:00
..
Makefile.objs qom: allow QOM to be linked into tools binaries 2015-09-15 14:35:39 +01:00
container.c container: don't leak container reference 2017-05-04 15:34:41 +04:00
cpu.c qom/cpu: Simplify how CPUClass:cpu_dump_state() prints 2019-04-18 22:18:59 +02:00
object.c qom/object: Display more helpful message when an object type is missing 2019-05-24 15:29:02 -03:00
object_interfaces.c qom: don't require user creatable objects to be registered 2019-02-26 15:25:58 +00:00
qom-qobject.c qapi: Drop unused non-strict qobject input visitor 2017-03-05 09:14:19 +01:00
trace-events trace-events: Shorten file names in comments 2019-03-22 16:18:07 +00:00