qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Amit Shah <amit.shah@redhat.com>,
	pbonzini@redhat.com, imammedo@redhat.com, dgilbert@redhat.com,
	Juan Quintela <quintela@redhat.com>
Subject: [Qemu-devel] [PATCH v3 1/8] memory: add memory_region_set_size
Date: Wed, 7 Jan 2015 21:48:48 +0200	[thread overview]
Message-ID: <1420660083-9961-2-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1420660083-9961-1-git-send-email-mst@redhat.com>

Add API to change MR size.
Will be used internally for RAM resize.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/exec/memory.h | 10 ++++++++++
 memory.c              | 16 ++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/include/exec/memory.h b/include/exec/memory.h
index f64ab5e..0882221 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -878,6 +878,16 @@ void memory_region_set_enabled(MemoryRegion *mr, bool enabled);
 void memory_region_set_address(MemoryRegion *mr, hwaddr addr);
 
 /*
+ * memory_region_set_size: dynamically update the size of a region.
+ *
+ * Dynamically updates the size of a region.
+ *
+ * @mr: the region to be updated
+ * @size: used size of the region.
+ */
+void memory_region_set_size(MemoryRegion *mr, uint64_t size);
+
+/*
  * memory_region_set_alias_offset: dynamically update a memory alias's offset
  *
  * Dynamically updates the offset into the target region that an alias points
diff --git a/memory.c b/memory.c
index 15cf9eb..618470b 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;
-- 
MST

  reply	other threads:[~2015-01-07 19:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-07 19:48 [Qemu-devel] [PATCH v3 0/8] acpi: make ROMs resizeable Michael S. Tsirkin
2015-01-07 19:48 ` Michael S. Tsirkin [this message]
2015-01-07 19:48 ` [Qemu-devel] [PATCH v3 2/8] exec: cpu_physical_memory_set/clear_dirty_range Michael S. Tsirkin
2015-01-07 19:48 ` [Qemu-devel] [PATCH v3 3/8] exec: split length -> used_length/max_length Michael S. Tsirkin
2015-01-07 19:49 ` [Qemu-devel] [PATCH v3 4/8] exec: qemu_ram_alloc_resizeable, qemu_ram_resize Michael S. Tsirkin
2015-01-07 19:49 ` [Qemu-devel] [PATCH v3 5/8] arch_init: support resizing on incoming migration Michael S. Tsirkin
2015-01-07 19:49 ` [Qemu-devel] [PATCH v3 6/8] memory: API to allocate resizeable RAM MR Michael S. Tsirkin
2015-01-07 19:49 ` [Qemu-devel] [PATCH v3 7/8] acpi-build: make ROMs RAM blocks resizeable Michael S. Tsirkin
2015-01-07 19:49 ` [Qemu-devel] [PATCH v3 8/8] qemu_ram_resize: document assumptions Michael S. Tsirkin
2015-01-07 20:48 ` [Qemu-devel] [PATCH v3 0/8] acpi: make ROMs resizeable Paolo Bonzini

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=1420660083-9961-2-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /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).