From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.crosthwaite@xilinx.com
Subject: [Qemu-devel] [PATCH 7/9] memory: convert memory_region_destroy to object_unparent
Date: Wed, 30 Jul 2014 12:27:10 +0200 [thread overview]
Message-ID: <1406716032-21795-8-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1406716032-21795-1-git-send-email-pbonzini@redhat.com>
Explicitly call object_unparent in the few places where we
will re-create the memory region. If the memory region is
simply being destroyed as part of device teardown, let QOM
handle it.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
docs/memory.txt | 15 ++++++++++-----
hw/display/vga.c | 2 +-
hw/i386/kvmvapic.c | 2 +-
hw/mips/gt64xxx_pci.c | 2 +-
hw/misc/omap_gpmc.c | 2 +-
hw/misc/vfio.c | 4 ++--
ioport.c | 2 +-
memory.c | 1 -
8 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/docs/memory.txt b/docs/memory.txt
index 5bdbdb3..b12f1f0 100644
--- a/docs/memory.txt
+++ b/docs/memory.txt
@@ -74,11 +74,15 @@ Region lifecycle
----------------
A region is created by one of the constructor functions (memory_region_init*())
-and destroyed by the destructor (memory_region_destroy()). In between,
-a region can be added to an address space by using memory_region_add_subregion()
-and removed using memory_region_del_subregion(). Region attributes may be
-changed at any point; they take effect once the region becomes exposed to the
-guest.
+and attached to an object. It is then destroyed by object_unparent() or simply
+when the parent object dies.
+
+In between, a region can be added to an address space
+by using memory_region_add_subregion() and removed using
+memory_region_del_subregion().
+
+Region attributes may be changed at any point; they take effect once
+the region becomes exposed to the guest.
Overlapping regions and priority
--------------------------------
diff --git a/hw/display/vga.c b/hw/display/vga.c
index 68cfee2..65dab8d 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -176,7 +176,7 @@ static void vga_update_memory_access(VGACommonState *s)
if (s->has_chain4_alias) {
memory_region_del_subregion(s->legacy_address_space, &s->chain4_alias);
- memory_region_destroy(&s->chain4_alias);
+ object_unparent(OBJECT(&s->chain4_alias));
s->has_chain4_alias = false;
s->plane_updated = 0xf;
}
diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c
index cb855c7..ee95963 100644
--- a/hw/i386/kvmvapic.c
+++ b/hw/i386/kvmvapic.c
@@ -584,7 +584,7 @@ static int vapic_map_rom_writable(VAPICROMState *s)
if (s->rom_mapped_writable) {
memory_region_del_subregion(as, &s->rom);
- memory_region_destroy(&s->rom);
+ object_unparent(OBJECT(&s->rom));
}
/* grab RAM memory region (region @rom_paddr may still be pc.rom) */
diff --git a/hw/mips/gt64xxx_pci.c b/hw/mips/gt64xxx_pci.c
index 22f63ce..1f2fe5f 100644
--- a/hw/mips/gt64xxx_pci.c
+++ b/hw/mips/gt64xxx_pci.c
@@ -297,7 +297,7 @@ static void gt64120_pci_mapping(GT64120State *s)
if (s->PCI0IO_length)
{
memory_region_del_subregion(get_system_memory(), &s->PCI0IO_mem);
- memory_region_destroy(&s->PCI0IO_mem);
+ object_unparent(OBJECT(&s->PCI0IO_mem));
}
/* Map new IO address */
s->PCI0IO_start = s->regs[GT_PCI0IOLD] << 21;
diff --git a/hw/misc/omap_gpmc.c b/hw/misc/omap_gpmc.c
index cddea24..fbbe2ff 100644
--- a/hw/misc/omap_gpmc.c
+++ b/hw/misc/omap_gpmc.c
@@ -436,7 +436,7 @@ static void omap_gpmc_cs_unmap(struct omap_gpmc_s *s, int cs)
}
memory_region_del_subregion(get_system_memory(), &f->container);
memory_region_del_subregion(&f->container, omap_gpmc_cs_memregion(s, cs));
- memory_region_destroy(&f->container);
+ object_unparent(OBJECT(&f->container));
}
void omap_gpmc_reset(struct omap_gpmc_s *s)
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
index 0b9eba0..af9ae1f 100644
--- a/hw/misc/vfio.c
+++ b/hw/misc/vfio.c
@@ -2266,7 +2266,7 @@ static void vfio_vga_quirk_teardown(VFIODevice *vdev)
while (!QLIST_EMPTY(&vdev->vga.region[i].quirks)) {
VFIOQuirk *quirk = QLIST_FIRST(&vdev->vga.region[i].quirks);
memory_region_del_subregion(&vdev->vga.region[i].mem, &quirk->mem);
- memory_region_destroy(&quirk->mem);
+ object_unparent(OBJECT(&quirk->mem));
QLIST_REMOVE(quirk, next);
g_free(quirk);
}
@@ -2290,7 +2290,7 @@ static void vfio_bar_quirk_teardown(VFIODevice *vdev, int nr)
while (!QLIST_EMPTY(&bar->quirks)) {
VFIOQuirk *quirk = QLIST_FIRST(&bar->quirks);
memory_region_del_subregion(&bar->mem, &quirk->mem);
- memory_region_destroy(&quirk->mem);
+ object_unparent(OBJECT(&quirk->mem));
QLIST_REMOVE(quirk, next);
g_free(quirk);
}
diff --git a/ioport.c b/ioport.c
index dce94a3..783a3ae 100644
--- a/ioport.c
+++ b/ioport.c
@@ -154,7 +154,7 @@ void portio_list_destroy(PortioList *piolist)
for (i = 0; i < piolist->nr; ++i) {
mrpio = container_of(piolist->regions[i], MemoryRegionPortioList, mr);
- memory_region_destroy(&mrpio->mr);
+ object_unparent(OBJECT(&mrpio->mr));
g_free(mrpio);
}
g_free(piolist->regions);
diff --git a/memory.c b/memory.c
index 64d7176..23c5269 100644
--- a/memory.c
+++ b/memory.c
@@ -1266,7 +1266,6 @@ static void memory_region_finalize(Object *obj)
void memory_region_destroy(MemoryRegion *mr)
{
- object_unparent(OBJECT(mr));
}
--
1.8.3.1
next prev parent reply other threads:[~2014-07-30 10:27 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-30 10:27 [Qemu-devel] [PATCH for-2.2 0/9] memory: remove memory_region_destroy Paolo Bonzini
2014-07-30 10:27 ` [Qemu-devel] [PATCH 1/9] qom: object: delete properties before calling instance_finalize Paolo Bonzini
2014-07-31 11:41 ` Peter Crosthwaite
2014-07-30 10:27 ` [Qemu-devel] [PATCH 2/9] qom: object: move unparenting to the child property's release callback Paolo Bonzini
2014-07-30 10:27 ` [Qemu-devel] [PATCH 3/9] sysbus: remove unused function sysbus_del_io Paolo Bonzini
2014-07-31 4:04 ` Peter Crosthwaite
2014-07-30 10:27 ` [Qemu-devel] [PATCH 4/9] vga: do not dynamically allocate chain4_alias Paolo Bonzini
2014-07-31 12:01 ` Peter Crosthwaite
2014-07-31 12:06 ` Paolo Bonzini
2014-07-30 10:27 ` [Qemu-devel] [PATCH 5/9] nic: do not destroy memory regions in cleanup functions Paolo Bonzini
2014-07-31 9:46 ` Stefan Hajnoczi
2014-07-31 12:06 ` Peter Crosthwaite
2014-07-30 10:27 ` [Qemu-devel] [PATCH 6/9] ioport: split deletion and destruction Paolo Bonzini
2014-07-31 12:34 ` Peter Crosthwaite
2014-07-31 14:30 ` Paolo Bonzini
2014-07-30 10:27 ` Paolo Bonzini [this message]
2014-07-30 10:27 ` [Qemu-devel] [PATCH 8/9] memory: remove memory_region_destroy Paolo Bonzini
2014-07-31 12:52 ` Peter Crosthwaite
2014-08-15 7:23 ` Peter Crosthwaite
2014-07-30 10:27 ` [Qemu-devel] [PATCH 9/9] tpm_tis: remove instance_finalize callback Paolo Bonzini
2014-07-31 12:00 ` Peter Crosthwaite
2014-07-31 12:05 ` Paolo Bonzini
2014-07-31 13:02 ` Peter Crosthwaite
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1406716032-21795-8-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).