Blame SOURCES/kvm-memory-add-memory_region_ram_resize.patch

8be556
From c18b0f65a2fa51ed10e9e6b07f1319335efb9779 Mon Sep 17 00:00:00 2001
8be556
From: Andrew Jones <drjones@redhat.com>
8be556
Date: Tue, 16 Jun 2015 11:48:13 +0200
8be556
Subject: [PATCH 052/217] memory: add memory_region_ram_resize
8be556
8be556
Message-id: <1434455325-23399-2-git-send-email-drjones@redhat.com>
8be556
Patchwork-id: 66234
8be556
O-Subject: [AArch64 RHEL-7.2 qemu-kvm-rhev PATCH 01/33] memory: add memory_region_ram_resize
8be556
Bugzilla: 1231719
8be556
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
8be556
RH-Acked-by: Wei Huang <wei@redhat.com>
8be556
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
8be556
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
8be556
8be556
Author: Paolo Bonzini <pbonzini@redhat.com>
8be556
8be556
This is a simple MemoryRegion wrapper for qemu_ram_resize.
8be556
8be556
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8be556
(cherry picked from commit 37d7c08413cd4307f53c83d43b1b06cf2701d7a7)
8be556
Signed-off-by: Andrew Jones <drjones@redhat.com>
8be556
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
8be556
---
8be556
 include/exec/memory.h | 12 ++++++++++++
8be556
 memory.c              |  7 +++++++
8be556
 2 files changed, 19 insertions(+)
8be556
8be556
diff --git a/include/exec/memory.h b/include/exec/memory.h
8be556
index 06ffa1d..a2ea587 100644
8be556
--- a/include/exec/memory.h
8be556
+++ b/include/exec/memory.h
8be556
@@ -605,6 +605,18 @@ int memory_region_get_fd(MemoryRegion *mr);
8be556
  */
8be556
 void *memory_region_get_ram_ptr(MemoryRegion *mr);
8be556
 
8be556
+/* memory_region_ram_resize: Resize a RAM region.
8be556
+ *
8be556
+ * Only legal before guest might have detected the memory size: e.g. on
8be556
+ * incoming migration, or right after reset.
8be556
+ *
8be556
+ * @mr: a memory region created with @memory_region_init_resizeable_ram.
8be556
+ * @newsize: the new size the region
8be556
+ * @errp: pointer to Error*, to store an error if it happens.
8be556
+ */
8be556
+void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize,
8be556
+                              Error **errp);
8be556
+
8be556
 /**
8be556
  * memory_region_set_log: Turn dirty logging on or off for a region.
8be556
  *
8be556
diff --git a/memory.c b/memory.c
8be556
index ee3f2a8..a11e9bf 100644
8be556
--- a/memory.c
8be556
+++ b/memory.c
8be556
@@ -1452,6 +1452,13 @@ void *memory_region_get_ram_ptr(MemoryRegion *mr)
8be556
     return qemu_get_ram_ptr(mr->ram_addr & TARGET_PAGE_MASK);
8be556
 }
8be556
 
8be556
+void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize, Error **errp)
8be556
+{
8be556
+    assert(mr->terminates);
8be556
+
8be556
+    qemu_ram_resize(mr->ram_addr, newsize, errp);
8be556
+}
8be556
+
8be556
 static void memory_region_update_coalesced_range_as(MemoryRegion *mr, AddressSpace *as)
8be556
 {
8be556
     FlatView *view;
8be556
-- 
8be556
1.8.3.1
8be556