Make AddressSpaces QOM objects to ensure that they are destroyed when
their owners are finalized and also to get a unique path for debugging
output.

The name arguments were used to distinguish AddresSpaces in debugging
output, but they will represent property names after QOM-ification and
debugging output will show QOM paths. So change them to make them more
concise and also avoid conflicts with other properties.

Signed-off-by: Akihiko Odaki <od...@rsg.ci.i.u-tokyo.ac.jp>
---
 hw/ppc/pnv_lpc.c   | 2 +-
 hw/ppc/pnv_xscom.c | 2 +-
 hw/ppc/spapr_pci.c | 5 ++---
 hw/ppc/spapr_vio.c | 2 +-
 4 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/hw/ppc/pnv_lpc.c b/hw/ppc/pnv_lpc.c
index 373b5a8be573..304f01e240db 100644
--- a/hw/ppc/pnv_lpc.c
+++ b/hw/ppc/pnv_lpc.c
@@ -799,7 +799,7 @@ static void pnv_lpc_realize(DeviceState *dev, Error **errp)
 
     /* Create address space and backing MR for the OPB bus */
     memory_region_init(&lpc->opb_mr, OBJECT(dev), "lpc-opb", 0x100000000ull);
-    address_space_init(&lpc->opb_as, NULL, &lpc->opb_mr, "lpc-opb");
+    address_space_init(&lpc->opb_as, OBJECT(dev), &lpc->opb_mr, "as");
 
     /*
      * Create ISA IO, Mem, and FW space regions which are the root of
diff --git a/hw/ppc/pnv_xscom.c b/hw/ppc/pnv_xscom.c
index 58f86bcbd2a6..353eb9b14e29 100644
--- a/hw/ppc/pnv_xscom.c
+++ b/hw/ppc/pnv_xscom.c
@@ -219,7 +219,7 @@ void pnv_xscom_init(PnvChip *chip, uint64_t size, hwaddr 
addr)
     memory_region_add_subregion(get_system_memory(), addr, &chip->xscom_mmio);
 
     memory_region_init(&chip->xscom, OBJECT(chip), name, size);
-    address_space_init(&chip->xscom_as, NULL, &chip->xscom, name);
+    address_space_init(&chip->xscom_as, OBJECT(chip), &chip->xscom, "as");
     g_free(name);
 }
 
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 13fc5c9aa8f2..41bf65b291de 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1759,7 +1759,7 @@ static void spapr_phb_unrealize(DeviceState *dev)
      * address space.
      */
     address_space_remove_listeners(&sphb->iommu_as);
-    address_space_destroy(&sphb->iommu_as);
+    object_unparent(OBJECT(&sphb->iommu_as));
 
     qbus_set_hotplug_handler(BUS(phb->bus), NULL);
     pci_unregister_root_bus(phb->bus);
@@ -1902,8 +1902,7 @@ static void spapr_phb_realize(DeviceState *dev, Error 
**errp)
     memory_region_init(&sphb->iommu_root, OBJECT(sphb),
                        namebuf, UINT64_MAX);
     g_free(namebuf);
-    address_space_init(&sphb->iommu_as, NULL, &sphb->iommu_root,
-                       sphb->dtbusname);
+    address_space_init(&sphb->iommu_as, OBJECT(sphb), &sphb->iommu_root, "as");
 
     /*
      * As MSI/MSIX interrupts trigger by writing at MSI/MSIX vectors,
diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c
index ebe4bad23668..5f8dd153dedf 100644
--- a/hw/ppc/spapr_vio.c
+++ b/hw/ppc/spapr_vio.c
@@ -529,7 +529,7 @@ static void spapr_vio_busdev_realize(DeviceState *qdev, 
Error **errp)
                                  "iommu-spapr-bypass", get_system_memory(),
                                  0, MACHINE(spapr)->ram_size);
         memory_region_add_subregion_overlap(&dev->mrroot, 0, &dev->mrbypass, 
1);
-        address_space_init(&dev->as, NULL, &dev->mrroot, qdev->id);
+        address_space_init(&dev->as, OBJECT(dev), &dev->mrroot, "as");
 
         dev->tcet = spapr_tce_new_table(qdev, liobn);
         spapr_tce_table_enable(dev->tcet, SPAPR_TCE_PAGE_SHIFT, 0,

-- 
2.51.0


Reply via email to