memory/hmp: Print owners/parents in "info mtree"
PATCH v2 1/2 memory/hmp: Print owners/parents in "info mtree"
In reply to Alexey KardashevskiyThis adds owners/parents (which are the same, just occasionally owner==NULL) printing for memory regions; a new '-o' flag enabled new output.
---
Changes:
v2:
* cleanups
--- include/exec/memory.h | 2 +- memory.c | 69 +++++++++++++++++++++++++++++++++++++++++++-------- monitor.c | 4 ++- hmp-commands-info.hx | 7 +++--- 4 files changed, 67 insertions(+), 15 deletions(-)
include/exec/memory.h +1 -1
@@ -1541,7 +1541,7 @@ void memory_global_dirty_log_start(void);void memory_global_dirty_log_stop (void );void mtree_info (fprintf_function mon_printf,void *f,bool flatview, -bool dispatch_tree); +bool dispatch_tree,bool owner);/** * memory_region_request_mmio_ptr: request a pointer to an mmio
memory.c +59 -10
152 lines not on this page · raw message
monitor.c +3 -1
@@ -1969,8 +1969,10 @@ static void hmp_info_mtree(Monitor *mon, const QDict *qdict) {bool flatview =qdict_get_try_bool (qdict,"flatview" , false);bool dispatch_tree =qdict_get_try_bool (qdict,"dispatch_tree" , false); +bool owner =qdict_get_try_bool (qdict,"owner" , false); -mtree_info ((fprintf_function )monitor_printf, mon, flatview, dispatch_tree); +mtree_info ((fprintf_function )monitor_printf, mon, flatview, dispatch_tree, + owner); }static void hmp_info_numa (Monitor *mon,const QDict *qdict)
hmp-commands-info.hx +4 -3
@@ -250,10 +250,11 @@ ETEXI { .name = "mtree", - .args_type = "flatview:-f,dispatch_tree:-d", - .params = "[-f][-d]", + .args_type = "flatview:-f,dispatch_tree:-d,owner:-o", + .params = "[-f][-d][-o]", .help = "show memory tree (-f: dump flat view for address spaces;" - "-d: dump dispatch tree, valid with -f only)", + "-d: dump dispatch tree, valid with -f only);" + "-o: dump region owners/parents", .cmd = hmp_info_mtree, },
Signature · 1 line
2.11.0
PATCH v2 2/2 object: Handle objects with no parents
In reply to Alexey KardashevskiyAt the moment object_get_canonical_path_component() crashes on assert() if the object does not have a parent. Usually it is not called for orphan objects but various HMP/QMP commands can do that (info mtree, qom-get).
This adds few more tests in object_get_canonical_path() to prevent QEMU from crashing.
--- qom/object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
qom/object.c +1 -1
@@ -1668,7 +1668,7 @@ gchar *object_get_canonical_path(Object *obj)Object *root =object_get_root ();char *newpath, *path =NULL ; -while (obj != root) { +while (obj && obj->parent && obj != root) {char *component =object_get_canonical_path_component (obj);if (path) {
Signature · 1 line
2.11.0
v2 cover memory/hmp: Print owners/parents in "info mtree"
This is a debug extension to "into mtree" to print a memory region owner/parent.
This is based on sha1
4743c23 Peter Maydell "Update version for v2.12.0 release".
Please comment. Thanks.
Alexey Kardashevskiy (2):
memory/hmp: Print owners/parents in "info mtree"
object: Handle objects with no parents
include/exec/memory.h | 2 +- memory.c | 69 +++++++++++++++++++++++++++++++++++++++++++-------- monitor.c | 4 ++- qom/object.c | 2 +- hmp-commands-info.hx | 7 +++--- 5 files changed, 68 insertions(+), 16 deletions(-)
Signature · 1 line
2.11.0
Re: [Qemu-devel] [PATCH qemu v2 2/2] object: Handle objects with no parents
In reply to Alexey KardashevskiyQuoted 18 lines · Alexey Kardashevskiy
At the moment
object_get_canonical_path_component()crashes onassert()if the object does not have a parent. Usually it is not called for orphan objects but various HMP/QMP commands can do that (info mtree, qom-get).This adds few more tests in
object_get_canonical_path()to prevent QEMU from crashing.Signed-off-by Alexey Kardashevskiy <[email protected]>--- qom/object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)qom/object.c +0
-0
qom/object.c gchar *object_get_canonical_path(Object *obj) · line 1674
Quoted 8 lines
qom/object.c +1
-1@@ -1668,7 +1668,7 @@ gchar *object_get_canonical_path(Object *obj)Object *root =object_get_root ();char *newpath, *path =NULL ; -while (obj != root) { +while (obj && obj->parent && obj != root) {char *component =object_get_canonical_path_component (obj);if (path) {
I think the patch is a good idea, but as it is written it is incorrect, because it will return an invalid canonical path. You should return NULL instead.
Also, checking both obj and obj->parent is unnecessary; if obj->parent is NULL, obj will be NULL on the next iteration.
Thanks,
Paolo
memory.c typedef QTAILQ_HEAD(mrqueue, MemoryRegionList) MemoryRegionListHead; · line 2837
Quoted 2 lines · Alexey Kardashevskiy
memory.c +2
-0+DeviceState *dev = (DeviceState *)object_dynamic_cast (obj,TYPE_DEVICE ); +const char *id =object_property_print (obj,"id" , true,NULL );
The only objects that have an "id" property are memdevs. If you want to special case their printing too, it's probably a good idea (that is, print one of "dev id=ID"/"memdev id=ID"/"obj path=PATH").
Otherwise, I can also queue this patch as is, but I'd remove the "id" property handling because I'm going to submit a small series to remove the "id" property altogether.
Let me know what you prefer!
Thanks,
Paolo
Quoted 9 lines
memory.c +9
-0+mon_printf (f," %s:{%s" , label, dev ?"dev" :"obj" ); +if (dev ? dev->id : id) { +mon_printf (f," id=%s" , dev ? dev->id : id); + }else { +gchar *canonical_path =object_get_canonical_path (obj); +mon_printf (f," path=%s" , canonical_path); +g_free (canonical_path); + } +mon_printf (f,"}" );
Quoted 8 lines · Paolo Bonzini
memory.c typedef QTAILQ_HEAD(mrqueue, MemoryRegionList) MemoryRegionListHead; · line 2837
Quoted 2 lines · Alexey Kardashevskiy
memory.c +2
-0+DeviceState *dev = (DeviceState *)object_dynamic_cast (obj,TYPE_DEVICE ); +const char *id =object_property_print (obj,"id" , true,NULL );The only objects that have an "id" property are memdevs. If you want to special case their printing too, it's probably a good idea (that is, print one of "dev id=ID"/"memdev id=ID"/"obj path=PATH").
Quoted 5 lines
Otherwise, I can also queue this patch as is, but I'd remove the "id" property handling because I'm going to submit a small series to remove the "id" property altogether.
Let me know what you prefer!
I choose to wait and repost, thanks :)
Quoted 15 lines
Thanks,
Paolo
Quoted 9 lines
memory.c +9
-0+mon_printf (f," %s:{%s" , label, dev ?"dev" :"obj" ); +if (dev ? dev->id : id) { +mon_printf (f," id=%s" , dev ? dev->id : id); + }else { +gchar *canonical_path =object_get_canonical_path (obj); +mon_printf (f," path=%s" , canonical_path); +g_free (canonical_path); + } +mon_printf (f,"}" );
Signature · 1 line
Alexey
Quoted 9 lines · Alexey Kardashevskiy
Quoted 8 lines · Paolo Bonzini
memory.c typedef QTAILQ_HEAD(mrqueue, MemoryRegionList) MemoryRegionListHead; · line 2837
Quoted 2 lines · Alexey Kardashevskiy
memory.c +2
-0+DeviceState *dev = (DeviceState *)object_dynamic_cast (obj,TYPE_DEVICE ); +const char *id =object_property_print (obj,"id" , true,NULL );The only objects that have an "id" property are memdevs. If you want to special case their printing too, it's probably a good idea (that is, print one of "dev id=ID"/"memdev id=ID"/"obj path=PATH").
Quoted 8 lines
Quoted 5 lines
Otherwise, I can also queue this patch as is, but I'd remove the "id" property handling because I'm going to submit a small series to remove the "id" property altogether.
Let me know what you prefer!
I choose to wait and repost, thanks :)
I waited, checked https://git.qemu.org/?p=qemu.git;a=commitdiff;h=29de4e
that "id" is no more and then grepped:
hw/intc/apic_common.c|489| object_property_add(obj, "id", "uint32", hw/ppc/spapr_drc.c|557| object_property_add_uint32_ptr(obj, "id", &drc->id, NULL);
This does not look like "remove the "id" property altogether" :) Does this mean we still rather want to print QOM's "id"? spapr_drc does not own MRs and APIC seems not to either.
Quoted 19 lines
Quoted 17 lines
Thanks,
Paolo
Quoted 9 lines
memory.c +9
-0+mon_printf (f," %s:{%s" , label, dev ?"dev" :"obj" ); +if (dev ? dev->id : id) { +mon_printf (f," id=%s" , dev ? dev->id : id); + }else { +gchar *canonical_path =object_get_canonical_path (obj); +mon_printf (f," path=%s" , canonical_path); +g_free (canonical_path); + } +mon_printf (f,"}" );
Signature · 1 line
Alexey
Quoted 7 lines · Alexey Kardashevskiy
hw/intc/apic_common.c|489| object_property_add(obj, "id", "uint32", hw/ppc/spapr_drc.c|557|
object_property_add_uint32_ptr(obj, "id", &drc->id, NULL);This does not look like "remove the "id" property altogether" :) Does this mean we still rather want to print QOM's "id"?
spapr_drcdoes not own MRs and APIC seems not to either.
No, those properties are specific to some devices (and in fact they are integers rather than strings). The id property that mirrors the path component is gone.
Paolo