From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Subject: [Qemu-devel] [PULL 09/11] memory: MemoryRegion: factor out memory region re-adder
Date: Wed, 18 Jun 2014 15:42:06 +0200 [thread overview]
Message-ID: <1403098928-30749-10-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1403098928-30749-1-git-send-email-pbonzini@redhat.com>
From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
memory_region_set_address is mostly just a function that deletes and
re-adds a memory region. Factor this generic functionality out into a
re-usable function. This prepares support for further QOMification
of MemoryRegion.
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
memory.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/memory.c b/memory.c
index 15f63e8..06a4af7 100644
--- a/memory.c
+++ b/memory.c
@@ -1517,21 +1517,27 @@ void memory_region_set_enabled(MemoryRegion *mr, bool enabled)
memory_region_transaction_commit();
}
-void memory_region_set_address(MemoryRegion *mr, hwaddr addr)
+static void memory_region_readd_subregion(MemoryRegion *mr)
{
MemoryRegion *parent = mr->parent;
- if (addr == mr->addr || !parent) {
- mr->addr = addr;
- return;
+ if (parent) {
+ memory_region_transaction_begin();
+ memory_region_ref(mr);
+ memory_region_del_subregion(parent, mr);
+ mr->parent = parent;
+ memory_region_update_parent_subregions(mr);
+ memory_region_unref(mr);
+ memory_region_transaction_commit();
}
+}
- memory_region_transaction_begin();
- memory_region_ref(mr);
- memory_region_del_subregion(parent, mr);
- memory_region_add_subregion_common(parent, addr, mr);
- memory_region_unref(mr);
- memory_region_transaction_commit();
+void memory_region_set_address(MemoryRegion *mr, hwaddr addr)
+{
+ if (addr != mr->addr) {
+ mr->addr = addr;
+ memory_region_readd_subregion(mr);
+ }
}
void memory_region_set_alias_offset(MemoryRegion *mr, hwaddr offset)
--
1.8.3.1
next prev parent reply other threads:[~2014-06-18 13:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-18 13:41 [Qemu-devel] [PULL 00/11] Memory API changes for 2014-06-18 Paolo Bonzini
2014-06-18 13:41 ` [Qemu-devel] [PULL 01/11] MAINTAINERS: Add myself as Memory API maintainer Paolo Bonzini
2014-06-18 13:41 ` [Qemu-devel] [PULL 02/11] exec: introduce qemu_ram_unset_idstr() to unset RAMBlock idstr Paolo Bonzini
2014-06-18 13:42 ` [Qemu-devel] [PULL 03/11] unset RAMBlock idstr when unregister MemoryRegion Paolo Bonzini
2014-06-18 13:42 ` [Qemu-devel] [PULL 04/11] memory: Don't update all memory region when ioeventfd changed Paolo Bonzini
2014-06-18 13:42 ` [Qemu-devel] [PULL 05/11] memory: Simplify mr_add_subregion() if-else Paolo Bonzini
2014-06-18 13:42 ` [Qemu-devel] [PULL 06/11] exec: dummy_section: Pass address space through Paolo Bonzini
2014-06-18 13:42 ` [Qemu-devel] [PULL 07/11] qtest: fix qtest_clock_warp() for no deadline case Paolo Bonzini
2014-06-18 13:42 ` [Qemu-devel] [PULL 08/11] memory: MemoryRegion: factor out subregion add functionality Paolo Bonzini
2014-06-18 13:42 ` Paolo Bonzini [this message]
2014-06-18 13:42 ` [Qemu-devel] [PULL 10/11] memory: MemoryRegion: rename parent to container Paolo Bonzini
2014-06-18 13:42 ` [Qemu-devel] [PULL 11/11] memory: Don't call memory_region_update_coalesced_range if nothing changed Paolo Bonzini
2014-06-18 15:28 ` [Qemu-devel] [PULL 00/11] Memory API changes for 2014-06-18 Peter Maydell
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=1403098928-30749-10-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).