memory: give name every AddressSpace
PATCH v2 1/1 memory: give name every AddressSpace
The "info mtree" command in QEMU console prints only "memory" and "I/O" address spaces while there are actually a lot more other AddressSpace structs created by PCI and VIO devices. Those devices do not normally have names and therefore not present in "info qtree" output.
The patch fixes this.
---
v2:
* removed "const" from AddressSpace::name
* removed redundand check for name!=NULL from mtree_info
--- exec.c | 6 ++---- hw/pci/pci.c | 3 ++- hw/ppc/spapr_vio.c | 2 +- include/exec/memory.h | 5 +++-- memory.c | 10 ++++------ 5 files changed, 12 insertions(+), 14 deletions(-)
exec.c +2 -4
@@ -1839,13 +1839,11 @@ static void memory_map_init(void) { system_memory =g_malloc (sizeof (*system_memory));memory_region_init (system_memory,"system" ,INT64_MAX ); -address_space_init (&address_space_memory, system_memory); - address_space_memory.name ="memory" ; +address_space_init (&address_space_memory, system_memory,"memory" ); system_io =g_malloc (sizeof (*system_io));memory_region_init (system_io,"io" ,65536 ); -address_space_init (&address_space_io, system_io); - address_space_io.name ="I/O" ; +address_space_init (&address_space_io, system_io,"I/O" );memory_listener_register (&core_memory_listener, &address_space_memory);memory_listener_register (&io_memory_listener, &address_space_io);
hw/pci/pci.c +2 -1
@@ -823,7 +823,8 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,memory_region_init_alias (&pci_dev->bus_master_enable_region,"bus master" , pci_dev->iommu,0 ,memory_region_size (pci_dev->iommu));memory_region_set_enabled (&pci_dev->bus_master_enable_region, false); -address_space_init (&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region); +address_space_init (&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region, + name); pci_dev->devfn = devfn;pstrcpy (pci_dev->name,sizeof (pci_dev->name), name);
hw/ppc/spapr_vio.c +1 -1
@@ -449,7 +449,7 @@ static int spapr_vio_busdev_init(DeviceState *qdev)if (pc->rtce_window_size) {uint32_t liobn =SPAPR_VIO_BASE_LIOBN | dev->reg; dev->tcet =spapr_tce_new_table (liobn, pc->rtce_window_size); -address_space_init (&dev->as,spapr_tce_get_iommu (dev->tcet)); +address_space_init (&dev->as,spapr_tce_get_iommu (dev->tcet), qdev->id); }return pc->init (dev);
include/exec/memory.h +3 -2
@@ -177,7 +177,7 @@ struct MemoryRegionPortio {*/ struct AddressSpace {/* All fields are private. */ -const char *name; +char *name;MemoryRegion *root;struct FlatView *current_map;int ioeventfd_nb;
@@ -839,8 +839,9 @@ void mtree_info(fprintf_function mon_printf, void *f);* * @as: an uninitialized #AddressSpace * @root: a #MemoryRegion that routes addesses for the address space +* @name: an address space name */ -void address_space_init (AddressSpace *as,MemoryRegion *root); +void address_space_init (AddressSpace *as,MemoryRegion *root,const char *name);/**
memory.c +4 -6
@@ -1002,7 +1002,7 @@ void memory_region_init_iommu(MemoryRegion *mr, mr->terminates = true;/* then re-forwards */ mr->destructor = memory_region_destructor_iommu; mr->iommu_target_as =g_new (AddressSpace,1 ); -address_space_init (mr->iommu_target_as, target); +address_space_init (mr->iommu_target_as, target, name); } static uint64_t invalid_read(void *opaque, hwaddr addr,
@@ -1599,7 +1599,7 @@ void memory_listener_unregister(MemoryListener *listener)QTAILQ_REMOVE (&memory_listeners, listener, link); } -void address_space_init (AddressSpace *as,MemoryRegion *root) +void address_space_init (AddressSpace *as,MemoryRegion *root,const char *name) {memory_region_transaction_begin (); as->root = root;
@@ -1608,7 +1608,7 @@ void address_space_init(AddressSpace *as, MemoryRegion *root) as->ioeventfd_nb =0 ; as->ioeventfds =NULL ;QTAILQ_INSERT_TAIL (&address_spaces, as, address_spaces_link); - as->name =NULL ; + as->name =g_strdup (name?name:"anonymous" );address_space_init_dispatch (as); memory_region_update_pending |= root->enabled;memory_region_transaction_commit ();
@@ -1623,6 +1623,7 @@ void address_space_destroy(AddressSpace *as)QTAILQ_REMOVE (&address_spaces, as, address_spaces_link);address_space_destroy_dispatch (as);flatview_destroy (as->current_map); +g_free (as->name);g_free (as->current_map);g_free (as->ioeventfds); }
@@ -1749,9 +1750,6 @@ void mtree_info(fprintf_function mon_printf, void *f)QTAILQ_INIT (&ml_head); QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { -if (!as->name) { -continue ; - }mon_printf (f,"%s\n" , as->name);mtree_print_mr (mon_printf, f, as->root,0 ,0 , &ml_head); }
Signature · 1 line
1.7.10.4
Paolo Bonzini
AppliedIl 30/04/2013 04:25, Alexey Kardashevskiy ha scritto:
Quoted 134 lines
The "info mtree" command in QEMU console prints only "memory" and "I/O" address spaces while there are actually a lot more other AddressSpace structs created by PCI and VIO devices. Those devices do not normally have names and therefore not present in "info qtree" output.
The patch fixes this.
Signed-off-by Alexey Kardashevskiy <[email protected]>---
v2:
* removed "const" fromAddressSpace::name
* removed redundand check for name!=NULL frommtree_info--- exec.c | 6 ++---- hw/pci/pci.c | 3 ++- hw/ppc/spapr_vio.c | 2 +- include/exec/memory.h | 5 +++-- memory.c | 10 ++++------ 5 files changed, 12 insertions(+), 14 deletions(-)exec.c +2
-4@@ -1839,13 +1839,11 @@ static void memory_map_init(void) { system_memory =g_malloc (sizeof (*system_memory));memory_region_init (system_memory,"system" ,INT64_MAX ); -address_space_init (&address_space_memory, system_memory); - address_space_memory.name ="memory" ; +address_space_init (&address_space_memory, system_memory,"memory" ); system_io =g_malloc (sizeof (*system_io));memory_region_init (system_io,"io" ,65536 ); -address_space_init (&address_space_io, system_io); - address_space_io.name ="I/O" ; +address_space_init (&address_space_io, system_io,"I/O" );memory_listener_register (&core_memory_listener, &address_space_memory);memory_listener_register (&io_memory_listener, &address_space_io);hw/pci/pci.c +2
-1@@ -823,7 +823,8 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,memory_region_init_alias (&pci_dev->bus_master_enable_region,"bus master" , pci_dev->iommu,0 ,memory_region_size (pci_dev->iommu));memory_region_set_enabled (&pci_dev->bus_master_enable_region, false); -address_space_init (&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region); +address_space_init (&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region, + name); pci_dev->devfn = devfn;pstrcpy (pci_dev->name,sizeof (pci_dev->name), name);hw/ppc/spapr_vio.c +1
-1@@ -449,7 +449,7 @@ static int spapr_vio_busdev_init(DeviceState *qdev)if (pc->rtce_window_size) {uint32_t liobn =SPAPR_VIO_BASE_LIOBN | dev->reg; dev->tcet =spapr_tce_new_table (liobn, pc->rtce_window_size); -address_space_init (&dev->as,spapr_tce_get_iommu (dev->tcet)); +address_space_init (&dev->as,spapr_tce_get_iommu (dev->tcet), qdev->id); }return pc->init (dev);include/exec/memory.h +3
-2@@ -177,7 +177,7 @@ struct MemoryRegionPortio {*/ struct AddressSpace {/* All fields are private. */ -const char *name; +char *name;MemoryRegion *root;struct FlatView *current_map;int ioeventfd_nb;@@ -839,8 +839,9 @@ void mtree_info(fprintf_function mon_printf, void *f);* * @as: an uninitialized #AddressSpace * @root: a #MemoryRegion that routes addesses for the address space +* @name: an address space name */ -void address_space_init (AddressSpace *as,MemoryRegion *root); +void address_space_init (AddressSpace *as,MemoryRegion *root,const char *name);/** memory.c +4
-3@@ -1002,7 +1002,7 @@ void memory_region_init_iommu(MemoryRegion *mr, mr->terminates = true;/* then re-forwards */ mr->destructor = memory_region_destructor_iommu; mr->iommu_target_as =g_new (AddressSpace,1 ); -address_space_init (mr->iommu_target_as, target); +address_space_init (mr->iommu_target_as, target, name); } static uint64_t invalid_read(void *opaque, hwaddr addr,@@ -1599,7 +1599,7 @@ void memory_listener_unregister(MemoryListener *listener)QTAILQ_REMOVE (&memory_listeners, listener, link); } -void address_space_init (AddressSpace *as,MemoryRegion *root) +void address_space_init (AddressSpace *as,MemoryRegion *root,const char *name) {memory_region_transaction_begin (); as->root = root;@@ -1608,7 +1608,7 @@ void address_space_init(AddressSpace *as, MemoryRegion *root) as->ioeventfd_nb =0 ; as->ioeventfds =NULL ;QTAILQ_INSERT_TAIL (&address_spaces, as, address_spaces_link); - as->name =NULL ; + as->name =g_strdup (name?name:"anonymous" );address_space_init_dispatch (as); memory_region_update_pending |= root->enabled;memory_region_transaction_commit ();@@ -1623,6 +1623,7 @@ void address_space_destroy(AddressSpace *as)QTAILQ_REMOVE (&address_spaces, as, address_spaces_link);address_space_destroy_dispatch (as);flatview_destroy (as->current_map); +g_free (as->name);g_free (as->current_map);g_free (as->ioeventfds); }
memory.c void mtree_info(fprintf_function mon_printf, void *f) · line 1755
Quoted 9 lines
memory.c +0
-3@@ -1749,9 +1750,6 @@ void mtree_info(fprintf_function mon_printf, void *f)QTAILQ_INIT (&ml_head); QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { -if (!as->name) { -continue ; - }mon_printf (f,"%s\n" , as->name);mtree_print_mr (mon_printf, f, as->root,0 ,0 , &ml_head); }
Applied to iommu branch, thanks.
Paolo
Quoted 136 lines · Paolo Bonzini
Il 30/04/2013 04:25, Alexey Kardashevskiy ha scritto:
Quoted 135 lines
The "info mtree" command in QEMU console prints only "memory" and "I/O" address spaces while there are actually a lot more other AddressSpace structs created by PCI and VIO devices. Those devices do not normally have names and therefore not present in "info qtree" output.
The patch fixes this.
Signed-off-by Alexey Kardashevskiy <[email protected]>---
v2:
* removed "const" fromAddressSpace::name
* removed redundand check for name!=NULL frommtree_info--- exec.c | 6 ++---- hw/pci/pci.c | 3 ++- hw/ppc/spapr_vio.c | 2 +- include/exec/memory.h | 5 +++-- memory.c | 10 ++++------ 5 files changed, 12 insertions(+), 14 deletions(-)exec.c +2
-4@@ -1839,13 +1839,11 @@ static void memory_map_init(void) { system_memory =g_malloc (sizeof (*system_memory));memory_region_init (system_memory,"system" ,INT64_MAX ); -address_space_init (&address_space_memory, system_memory); - address_space_memory.name ="memory" ; +address_space_init (&address_space_memory, system_memory,"memory" ); system_io =g_malloc (sizeof (*system_io));memory_region_init (system_io,"io" ,65536 ); -address_space_init (&address_space_io, system_io); - address_space_io.name ="I/O" ; +address_space_init (&address_space_io, system_io,"I/O" );memory_listener_register (&core_memory_listener, &address_space_memory);memory_listener_register (&io_memory_listener, &address_space_io);hw/pci/pci.c +2
-1@@ -823,7 +823,8 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,memory_region_init_alias (&pci_dev->bus_master_enable_region,"bus master" , pci_dev->iommu,0 ,memory_region_size (pci_dev->iommu));memory_region_set_enabled (&pci_dev->bus_master_enable_region, false); -address_space_init (&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region); +address_space_init (&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region, + name); pci_dev->devfn = devfn;pstrcpy (pci_dev->name,sizeof (pci_dev->name), name);hw/ppc/spapr_vio.c +1
-1@@ -449,7 +449,7 @@ static int spapr_vio_busdev_init(DeviceState *qdev)if (pc->rtce_window_size) {uint32_t liobn =SPAPR_VIO_BASE_LIOBN | dev->reg; dev->tcet =spapr_tce_new_table (liobn, pc->rtce_window_size); -address_space_init (&dev->as,spapr_tce_get_iommu (dev->tcet)); +address_space_init (&dev->as,spapr_tce_get_iommu (dev->tcet), qdev->id); }return pc->init (dev);include/exec/memory.h +3
-2@@ -177,7 +177,7 @@ struct MemoryRegionPortio {*/ struct AddressSpace {/* All fields are private. */ -const char *name; +char *name;MemoryRegion *root;struct FlatView *current_map;int ioeventfd_nb;@@ -839,8 +839,9 @@ void mtree_info(fprintf_function mon_printf, void *f);* * @as: an uninitialized #AddressSpace * @root: a #MemoryRegion that routes addesses for the address space +* @name: an address space name */ -void address_space_init (AddressSpace *as,MemoryRegion *root); +void address_space_init (AddressSpace *as,MemoryRegion *root,const char *name);/** memory.c +4
-3@@ -1002,7 +1002,7 @@ void memory_region_init_iommu(MemoryRegion *mr, mr->terminates = true;/* then re-forwards */ mr->destructor = memory_region_destructor_iommu; mr->iommu_target_as =g_new (AddressSpace,1 ); -address_space_init (mr->iommu_target_as, target); +address_space_init (mr->iommu_target_as, target, name); } static uint64_t invalid_read(void *opaque, hwaddr addr,@@ -1599,7 +1599,7 @@ void memory_listener_unregister(MemoryListener *listener)QTAILQ_REMOVE (&memory_listeners, listener, link); } -void address_space_init (AddressSpace *as,MemoryRegion *root) +void address_space_init (AddressSpace *as,MemoryRegion *root,const char *name) {memory_region_transaction_begin (); as->root = root;@@ -1608,7 +1608,7 @@ void address_space_init(AddressSpace *as, MemoryRegion *root) as->ioeventfd_nb =0 ; as->ioeventfds =NULL ;QTAILQ_INSERT_TAIL (&address_spaces, as, address_spaces_link); - as->name =NULL ; + as->name =g_strdup (name?name:"anonymous" );address_space_init_dispatch (as); memory_region_update_pending |= root->enabled;memory_region_transaction_commit ();@@ -1623,6 +1623,7 @@ void address_space_destroy(AddressSpace *as)QTAILQ_REMOVE (&address_spaces, as, address_spaces_link);address_space_destroy_dispatch (as);flatview_destroy (as->current_map); +g_free (as->name);g_free (as->current_map);g_free (as->ioeventfds); }@@ -1749,9 +1750,6 @@ void mtree_info(fprintf_function mon_printf, void *f)QTAILQ_INIT (&ml_head);
Quoted 10 lines
memory.c void mtree_info(fprintf_function mon_printf, void *f) · line 1755
Quoted 8 lines
memory.c +0
-3QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { -if (!as->name) { -continue ; - }mon_printf (f,"%s\n" , as->name);mtree_print_mr (mon_printf, f, as->root,0 ,0 , &ml_head); }Applied to iommu branch, thanks.
I don't see this patch at git://github.com/bonzini/qemu.git yet. Did you need to do something to push it out?
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Il 01/05/2013 05:25, David Gibson ha scritto:
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Applied to iommu branch, thanks.
I don't see this patch at
git://github.com/bonzini/qemu.gityet. Did you need to do something to push it out?
I just applied it locally for now.
Paolo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQIcBAEBAgAGBQJRgS/NAAoJEBvWZb6bTYbyr2wP/0SE8WDVpcteMf0oO+W/o1jg nav1QqSiVWs6KbFR5uQsiLK3l+Rv1BKKf5FZoGiOSvHxyr7/tYpv6MmOAMYyKqVF +KsYZ5J8snL9OyZviSkUPvmYF/v8+MZxBAMJHB5ryjpZoDk/4y5aT0LrPl6NLeqy fkXToabzPFWHEWVwa6JkHgyS1IFxYM0zgobCv82TGypSAebded02BvrIzUV6jSI0 iEjIAKdZiSK2pdgHnZFRHqd0I8+NHjeSaXXX5YxhtE0R3uCMNoRBiam9t5aGVIYb HLwGq94/ikf4gDnntkE6/J9zAwVcHltp97InGEhOQRP/71xgGjTbRVDn7v5kadwC UMZzGA+fBVhI80Zjnb280hQVPHihgicO3koaaEkW6zBDGuCZZtr2yocQFnVYRZhH CnQ5yUG6SZCgH+RlsIZ8mh/bEknH21+IF4xdTv5j3gSH8R5Y3I+l3KShTMDCcEfc +ItrdQQLJXMlPXXRCeG6N1+Hkg1VpcnhGBpfIXqUTgfJtvGqi+TzEMqt8KGeIMEf 7YLfpHm7vd5kseBo6u85XScAcxPazfoSn8vTb0yFiU+YeSUstZzoAwoQg/7lzarB 1ouWvNrT9plNywg2aMGO34tCQCSCDwMlsQ47HMGxKiCTlVEczz758Xki1NAURCTy uza3CdJb9OrYDQ5qeDOi
=jcUq
-----END PGP SIGNATURE-----