[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 30/30] memory: give name to every AddressSpace
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 30/30] memory: give name to every AddressSpace |
Date: |
Tue, 21 May 2013 12:57:31 +0200 |
From: Alexey Kardashevskiy <address@hidden>
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 mtree" output.
The patch fixes this.
Signed-off-by: Alexey Kardashevskiy <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
exec.c | 6 ++----
hw/pci/pci.c | 3 ++-
hw/ppc/spapr_vio.c | 2 +-
include/exec/memory.h | 5 +++--
memory.c | 8 +++-----
5 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/exec.c b/exec.c
index f508a59..1610604 100644
--- a/exec.c
+++ b/exec.c
@@ -1846,13 +1846,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);
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 2b1bc6d..fa30110 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -815,7 +815,8 @@ static PCIDevice *do_pci_register_device(PCIDevice
*pci_dev, PCIBus *bus,
memory_region_init_alias(&pci_dev->bus_master_enable_region, "bus master",
dma_as->root, 0,
memory_region_size(dma_as->root));
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);
diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c
index 5e72f1b..3cfa326 100644
--- a/hw/ppc/spapr_vio.c
+++ b/hw/ppc/spapr_vio.c
@@ -458,7 +458,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);
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 05b9bb2..01b70ed 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -191,7 +191,7 @@ struct MemoryRegionPortio {
*/
struct AddressSpace {
/* All fields are private. */
- const char *name;
+ char *name;
MemoryRegion *root;
struct FlatView *current_map;
int ioeventfd_nb;
@@ -858,8 +858,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);
/**
diff --git a/memory.c b/memory.c
index e3970bf..66258e2 100644
--- a/memory.c
+++ b/memory.c
@@ -1605,7 +1605,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;
@@ -1614,7 +1614,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();
@@ -1629,6 +1629,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);
}
@@ -1755,9 +1756,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);
}
--
1.8.1.4
- [Qemu-devel] [PATCH 22/30] vfio: abort if an emulated iommu is used, (continued)
- [Qemu-devel] [PATCH 22/30] vfio: abort if an emulated iommu is used, Paolo Bonzini, 2013/05/21
- [Qemu-devel] [PATCH 23/30] spapr: convert TCE API to use an opaque type, Paolo Bonzini, 2013/05/21
- [Qemu-devel] [PATCH 24/30] spapr: make IOMMU translation go through IOMMUTLBEntry, Paolo Bonzini, 2013/05/21
- [Qemu-devel] [PATCH 25/30] spapr: use memory core for iommu support, Paolo Bonzini, 2013/05/21
- [Qemu-devel] [PATCH 26/30] dma: eliminate old-style IOMMU support, Paolo Bonzini, 2013/05/21
- [Qemu-devel] [PATCH 27/30] pci: use memory core for iommu support, Paolo Bonzini, 2013/05/21
- [Qemu-devel] [PATCH 28/30] spapr_vio: take care of creating our own AddressSpace/DMAContext, Paolo Bonzini, 2013/05/21
- [Qemu-devel] [PATCH 30/30] memory: give name to every AddressSpace,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 29/30] dma: eliminate DMAContext, Paolo Bonzini, 2013/05/21
- Re: [Qemu-devel] [PATCH 00/30] Introduction of IOMMUs into the memory API, Alexey Kardashevskiy, 2013/05/21