From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, dgilbert@redhat.com,
Juan Quintela <quintela@redhat.com>
Subject: [Qemu-devel] [PATCH 4/5] memory: interface to allocate device ram
Date: Mon, 17 Nov 2014 22:08:59 +0200 [thread overview]
Message-ID: <1416254843-16859-5-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1416254843-16859-1-git-send-email-mst@redhat.com>
Add API to allocate on-device RAM.
This looks just like regular RAM from migration POV,
but has two special properties internally:
- it is never exposed to guest
- block is sized on migration, making it easier to extend
without breaking migration compatibility or wasting
virtual memory
Device is notified on resize, so it can adjust
if necessary.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/exec/memory.h | 22 ++++++++++++++++++++++
memory.c | 17 +++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 4caaa9b..983d11e 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -320,6 +320,28 @@ void memory_region_init_ram(MemoryRegion *mr,
uint64_t size,
Error **errp);
+/**
+ * memory_region_init_device_ram: Initialize memory region with device RAM.
+ * This region is migrated as RAM but is not normally
+ * accessible to guests.
+ *
+ * @mr: the #MemoryRegion to be initialized.
+ * @owner: the object that tracks the region's reference count
+ * @name: the name of the region.
+ * @size: size of the region.
+ * @max_size: max size of the region - if region is resizeable.
+ * @resized: callback to notify owner about region resize.
+ * @errp: pointer to Error*, to store an error if it happens.
+ */
+void memory_region_init_device_ram(MemoryRegion *mr,
+ struct Object *owner,
+ const char *name,
+ uint64_t size,
+ uint64_t max_size,
+ void (*resized)(const char*,
+ uint64_t length,
+ void *host),
+ Error **errp);
#ifdef __linux__
/**
* memory_region_init_ram_from_file: Initialize RAM memory region with a
diff --git a/memory.c b/memory.c
index bf50a2c..8f09db7 100644
--- a/memory.c
+++ b/memory.c
@@ -1152,6 +1152,23 @@ void memory_region_init_ram(MemoryRegion *mr,
mr->ram_addr = qemu_ram_alloc(size, mr, errp);
}
+void memory_region_init_device_ram(MemoryRegion *mr,
+ Object *owner,
+ const char *name,
+ uint64_t size,
+ uint64_t max_size,
+ void (*resized)(const char*,
+ uint64_t length,
+ void *host),
+ Error **errp)
+{
+ memory_region_init(mr, owner, name, size);
+ mr->ram = true;
+ mr->terminates = true;
+ mr->destructor = memory_region_destructor_ram;
+ mr->ram_addr = qemu_ram_alloc_device(size, max_size, resized, mr, errp);
+}
+
#ifdef __linux__
void memory_region_init_ram_from_file(MemoryRegion *mr,
struct Object *owner,
--
MST
next prev parent reply other threads:[~2014-11-17 20:09 UTC|newest]
Thread overview: 82+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-17 20:08 [Qemu-devel] [PATCH 0/5] pc: make ROMs resizeable Michael S. Tsirkin
2014-11-17 20:08 ` [Qemu-devel] [PATCH 1/5] cpu: add cpu_physical_memory_clear_dirty_range_nocode Michael S. Tsirkin
2014-11-19 9:10 ` Juan Quintela
2014-11-17 20:08 ` [Qemu-devel] [PATCH 2/5] exec: qemu_ram_alloc_device, qemu_ram_resize Michael S. Tsirkin
2014-11-17 20:15 ` Michael S. Tsirkin
2014-11-18 6:03 ` Paolo Bonzini
2014-11-18 7:49 ` Michael S. Tsirkin
2014-11-19 9:19 ` Juan Quintela
2014-11-19 9:33 ` Michael S. Tsirkin
2014-11-19 10:11 ` Juan Quintela
2014-11-19 10:21 ` Michael S. Tsirkin
2014-11-19 10:45 ` Juan Quintela
2014-11-19 13:28 ` Michael S. Tsirkin
2014-11-19 13:44 ` Paolo Bonzini
2014-11-19 13:57 ` Juan Quintela
2014-11-19 14:13 ` Dr. David Alan Gilbert
2014-11-19 14:22 ` Paolo Bonzini
2014-11-19 14:26 ` Dr. David Alan Gilbert
2014-11-19 14:28 ` Paolo Bonzini
2014-11-19 14:59 ` Dr. David Alan Gilbert
2014-11-19 15:38 ` Michael S. Tsirkin
2014-11-19 15:53 ` Dr. David Alan Gilbert
2014-11-19 14:22 ` Juan Quintela
2014-11-19 14:20 ` Paolo Bonzini
2014-11-19 16:39 ` Juan Quintela
2014-11-19 16:56 ` Paolo Bonzini
2014-11-19 16:27 ` Kevin O'Connor
2014-11-19 17:01 ` Paolo Bonzini
2014-11-20 8:12 ` Gerd Hoffmann
2014-11-20 10:00 ` Paolo Bonzini
2014-11-19 13:49 ` Juan Quintela
2014-11-19 13:51 ` Paolo Bonzini
2014-11-19 14:03 ` Juan Quintela
2014-11-19 14:11 ` Paolo Bonzini
2014-11-19 14:16 ` Dr. David Alan Gilbert
2014-11-19 14:28 ` Paolo Bonzini
2014-11-19 14:20 ` Juan Quintela
2014-11-19 15:43 ` Michael S. Tsirkin
2014-11-19 10:16 ` Markus Armbruster
2014-11-19 10:30 ` Michael S. Tsirkin
2014-11-19 10:50 ` Juan Quintela
2014-11-19 13:36 ` Michael S. Tsirkin
2014-11-19 13:51 ` Juan Quintela
2014-11-19 15:46 ` Michael S. Tsirkin
2014-11-19 16:45 ` Juan Quintela
2014-11-19 18:28 ` Paolo Bonzini
2014-11-20 13:35 ` Markus Armbruster
2014-11-20 14:04 ` Michael S. Tsirkin
2014-11-24 13:48 ` Paolo Bonzini
2014-11-19 13:58 ` Peter Maydell
2014-11-19 14:07 ` Juan Quintela
2014-11-19 14:10 ` Peter Maydell
2014-11-19 14:18 ` Juan Quintela
2014-11-19 16:08 ` Stefan Hajnoczi
2014-11-19 14:19 ` Paolo Bonzini
2014-11-19 14:21 ` Peter Maydell
2014-11-19 14:30 ` Paolo Bonzini
2014-11-19 15:16 ` Michael S. Tsirkin
2014-11-19 16:50 ` Juan Quintela
2014-11-19 15:12 ` Michael S. Tsirkin
2014-11-19 15:04 ` Michael S. Tsirkin
2014-11-17 20:08 ` [Qemu-devel] [PATCH 3/5] arch_init: support resizing on incoming migration Michael S. Tsirkin
2014-11-17 20:08 ` Michael S. Tsirkin [this message]
2014-11-17 20:21 ` [Qemu-devel] [PATCH 4/5] memory: interface to allocate device ram Peter Maydell
2014-11-18 11:54 ` Michael S. Tsirkin
2014-11-17 20:09 ` [Qemu-devel] [PATCH 5/5] acpi-build: make ROMs device RAM, make them resizeable Michael S. Tsirkin
2014-11-17 20:11 ` [Qemu-devel] [PATCH 0/5] pc: make ROMs resizeable Michael S. Tsirkin
2014-11-19 7:29 ` Amit Shah
2014-11-18 14:47 ` Markus Armbruster
2014-11-18 15:00 ` Michael S. Tsirkin
2014-11-19 8:16 ` Markus Armbruster
2014-11-19 13:41 ` Michael S. Tsirkin
2014-11-19 7:31 ` Amit Shah
2014-11-19 8:15 ` Michael S. Tsirkin
2014-11-19 8:22 ` Amit Shah
2014-11-19 13:33 ` Michael S. Tsirkin
2014-11-19 13:52 ` Juan Quintela
2014-11-19 16:01 ` Michael S. Tsirkin
2014-11-19 13:52 ` Peter Maydell
2014-11-19 14:41 ` Paolo Bonzini
2014-11-19 15:34 ` Michael S. Tsirkin
2014-11-19 16:40 ` Juan Quintela
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=1416254843-16859-5-git-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=dgilbert@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).