aboutsummaryrefslogtreecommitdiff
path: root/memory.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2014-12-16 11:21:23 +0200
committerMichael S. Tsirkin <mst@redhat.com>2015-01-08 13:17:54 +0200
commite7af4c67300b3f9382e96f7a6741a5992116b2d2 (patch)
tree3ac54bff09310f946a272b322780150231968ec1 /memory.c
parentd86fb03469e016af4e54f04efccbc20a8afa3e19 (diff)
memory: add memory_region_set_size
Add API to change MR size. Will be used internally for RAM resize. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'memory.c')
-rw-r--r--memory.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/memory.c b/memory.c
index 15cf9ebd84..618470bc4f 100644
--- a/memory.c
+++ b/memory.c
@@ -1707,6 +1707,22 @@ void memory_region_set_enabled(MemoryRegion *mr, bool enabled)
memory_region_transaction_commit();
}
+void memory_region_set_size(MemoryRegion *mr, uint64_t size)
+{
+ Int128 s = int128_make64(size);
+
+ if (size == UINT64_MAX) {
+ s = int128_2_64();
+ }
+ if (int128_eq(s, mr->size)) {
+ return;
+ }
+ memory_region_transaction_begin();
+ mr->size = s;
+ memory_region_update_pending = true;
+ memory_region_transaction_commit();
+}
+
static void memory_region_readd_subregion(MemoryRegion *mr)
{
MemoryRegion *container = mr->container;