* [Qemu-devel] [PATCH] qom/object: Display more helpful message when an object type is missing
@ 2019-04-27 13:56 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-04-27 13:56 UTC (permalink / raw)
To: Eduardo Habkost, qemu-devel
Cc: Andreas Färber, Daniel P . Berrangé, Eric Blake,
Markus Armbruster, 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=<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>
---
qom/object.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/qom/object.c b/qom/object.c
index e3206d6799e..b1ba62c5b9e 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
@@ -451,7 +452,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));
@@ -471,6 +471,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.20.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH] qom/object: Display more helpful message when an object type is missing
@ 2019-04-27 13:56 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-04-27 13:56 UTC (permalink / raw)
To: Eduardo Habkost, qemu-devel
Cc: Philippe Mathieu-Daudé, Andreas Färber,
Markus Armbruster
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>
---
qom/object.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/qom/object.c b/qom/object.c
index e3206d6799e..b1ba62c5b9e 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
@@ -451,7 +452,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));
@@ -471,6 +471,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.20.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH] qom/object: Display more helpful message when an object type is missing
@ 2019-04-29 7:13 ` Cornelia Huck
0 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2019-04-29 7:13 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Eduardo Habkost, qemu-devel, Andreas Färber,
Markus Armbruster
On Sat, 27 Apr 2019 15:56:42 +0200
Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
> 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>
> ---
> qom/object.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
Way more helpful error message :)
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH] qom/object: Display more helpful message when an object type is missing
@ 2019-04-29 7:13 ` Cornelia Huck
0 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2019-04-29 7:13 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Markus Armbruster, Eduardo Habkost, Andreas Färber,
qemu-devel
On Sat, 27 Apr 2019 15:56:42 +0200
Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
> 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>
> ---
> qom/object.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
Way more helpful error message :)
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH] qom/object: Display more helpful message when an object type is missing
@ 2019-04-30 8:47 ` Stefano Garzarella
0 siblings, 0 replies; 11+ messages in thread
From: Stefano Garzarella @ 2019-04-30 8:47 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Eduardo Habkost, qemu-devel, Andreas Färber,
Markus Armbruster
On Sat, Apr 27, 2019 at 03:56:42PM +0200, Philippe Mathieu-Daudé wrote:
> 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>
> ---
> qom/object.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
Very appreciated!
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Thanks,
Stefano
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH] qom/object: Display more helpful message when an object type is missing
@ 2019-04-30 8:47 ` Stefano Garzarella
0 siblings, 0 replies; 11+ messages in thread
From: Stefano Garzarella @ 2019-04-30 8:47 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Markus Armbruster, Eduardo Habkost, Andreas Färber,
qemu-devel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 2119 bytes --]
On Sat, Apr 27, 2019 at 03:56:42PM +0200, Philippe Mathieu-Daudé wrote:
> 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>
> ---
> qom/object.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
Very appreciated!
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Thanks,
Stefano
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH] qom/object: Display more helpful message when an object type is missing
@ 2019-04-30 10:18 ` Daniel P. Berrangé
0 siblings, 0 replies; 11+ messages in thread
From: Daniel P. Berrangé @ 2019-04-30 10:18 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Eduardo Habkost, qemu-devel, Andreas Färber, Eric Blake,
Markus Armbruster
On Sat, Apr 27, 2019 at 03:56:42PM +0200, Philippe Mathieu-Daudé wrote:
> 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>
> ---
> qom/object.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH] qom/object: Display more helpful message when an object type is missing
@ 2019-04-30 10:18 ` Daniel P. Berrangé
0 siblings, 0 replies; 11+ messages in thread
From: Daniel P. Berrangé @ 2019-04-30 10:18 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Markus Armbruster, Eduardo Habkost, Andreas Färber,
qemu-devel
On Sat, Apr 27, 2019 at 03:56:42PM +0200, Philippe Mathieu-Daudé wrote:
> 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>
> ---
> qom/object.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH] qom/object: Display more helpful message when an object type is missing
@ 2019-05-03 18:35 ` Eduardo Habkost
0 siblings, 0 replies; 11+ messages in thread
From: Eduardo Habkost @ 2019-05-03 18:35 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Andreas Färber, Daniel P . Berrangé,
Eric Blake, Markus Armbruster
On Sat, Apr 27, 2019 at 03:56:42PM +0200, Philippe Mathieu-Daudé wrote:
> 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>
Queued, thanks!
--
Eduardo
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH] qom/object: Display more helpful message when an object type is missing
@ 2019-05-03 18:35 ` Eduardo Habkost
0 siblings, 0 replies; 11+ messages in thread
From: Eduardo Habkost @ 2019-05-03 18:35 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Markus Armbruster, Andreas Färber
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 2016 bytes --]
On Sat, Apr 27, 2019 at 03:56:42PM +0200, Philippe Mathieu-Daudé wrote:
> 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>
Queued, thanks!
--
Eduardo
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH] qom/object: Display more helpful message when an object type is missing
2019-04-27 13:56 ` Philippe Mathieu-Daudé
` (4 preceding siblings ...)
(?)
@ 2019-05-06 8:07 ` Markus Armbruster
-1 siblings, 0 replies; 11+ messages in thread
From: Markus Armbruster @ 2019-05-06 8:07 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Eduardo Habkost, Andreas Färber, qemu-devel
Philippe Mathieu-Daudé <philmd@redhat.com> writes:
> 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)
I'd phrase it like "object type '%s' missing from build". Suggestion,
not demand.
> Since the assert(type) check in object_initialize_with_type() is
> now impossible, remove it.
You're right, it's impossible (I checked). Are we sure it'll stay
impossible?
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> qom/object.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/qom/object.c b/qom/object.c
> index e3206d6799e..b1ba62c5b9e 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
>
> @@ -451,7 +452,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));
> @@ -471,6 +471,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);
> }
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2019-05-06 8:08 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-27 13:56 [Qemu-devel] [PATCH] qom/object: Display more helpful message when an object type is missing Philippe Mathieu-Daudé
2019-04-27 13:56 ` Philippe Mathieu-Daudé
2019-04-29 7:13 ` Cornelia Huck
2019-04-29 7:13 ` Cornelia Huck
2019-04-30 8:47 ` Stefano Garzarella
2019-04-30 8:47 ` Stefano Garzarella
2019-04-30 10:18 ` Daniel P. Berrangé
2019-04-30 10:18 ` Daniel P. Berrangé
2019-05-03 18:35 ` Eduardo Habkost
2019-05-03 18:35 ` Eduardo Habkost
2019-05-06 8:07 ` Markus Armbruster
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.