All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/9] RFC: add memfd memory backend
@ 2016-04-12 11:55 marcandre.lureau
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 1/9] exec: check kvm mmu notifiers earlier marcandre.lureau
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: marcandre.lureau @ 2016-04-12 11:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Add a new memory backend, similar to hostmem-file, except that it
doesn't need a file path, or hugepages directory permissions. It also
try to enforce memory sealing if available.

This backend is mainly useful for easily sharing the memory with other
processes, for example with vhost-user backend, when hugepages aren't
available (for security reasons or other limitations).

Marc-André Lureau (9):
  exec: check kvm mmu notifiers earlier
  exec: split file_ram_alloc()
  exec: split qemu_ram_alloc_from_file()
  Add memory_region_init_ram_from_fd()
  RFC: ivshmem: use ram_from_fd()
  exec: remove qemu_set_ram_fd()
  memfd: split qemu_memfd_alloc()
  Add memfd based hostmem
  tests: use memfd in vhost-user-test

 backends/Makefile.objs   |   1 +
 backends/hostmem-memfd.c |  85 ++++++++++++++++++++++++++++++++++++++
 exec.c                   | 103 +++++++++++++++++++++++++++--------------------
 hw/misc/ivshmem.c        |  13 +++---
 include/exec/memory.h    |  20 +++++++++
 include/exec/ram_addr.h  |   4 +-
 include/qemu/memfd.h     |   1 +
 memory.c                 |  16 ++++++++
 qemu-options.hx          |  12 ++++++
 tests/vhost-user-test.c  |  12 +++---
 util/memfd.c             |  19 ++++++---
 11 files changed, 222 insertions(+), 64 deletions(-)
 create mode 100644 backends/hostmem-memfd.c

-- 
2.5.5

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 1/9] exec: check kvm mmu notifiers earlier
  2016-04-12 11:55 [Qemu-devel] [PATCH 0/9] RFC: add memfd memory backend marcandre.lureau
@ 2016-04-12 11:55 ` marcandre.lureau
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 2/9] exec: split file_ram_alloc() marcandre.lureau
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: marcandre.lureau @ 2016-04-12 11:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Move kvm mmu notifiers check before calling file_ram_alloc().
This shouldn't change the validation logic.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 exec.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/exec.c b/exec.c
index c4f9036..dcc6632 100644
--- a/exec.c
+++ b/exec.c
@@ -1242,12 +1242,6 @@ static void *file_ram_alloc(RAMBlock *block,
     int fd = -1;
     int64_t page_size;
 
-    if (kvm_enabled() && !kvm_has_sync_mmu()) {
-        error_setg(errp,
-                   "host lacks kvm mmu notifiers, -mem-path unsupported");
-        return NULL;
-    }
-
     for (;;) {
         fd = open(path, O_RDWR);
         if (fd >= 0) {
@@ -1675,6 +1669,12 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
         return NULL;
     }
 
+    if (kvm_enabled() && !kvm_has_sync_mmu()) {
+        error_setg(errp,
+                   "host lacks kvm mmu notifiers, -mem-path unsupported");
+        return NULL;
+    }
+
     size = HOST_PAGE_ALIGN(size);
     new_block = g_malloc0(sizeof(*new_block));
     new_block->mr = mr;
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 2/9] exec: split file_ram_alloc()
  2016-04-12 11:55 [Qemu-devel] [PATCH 0/9] RFC: add memfd memory backend marcandre.lureau
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 1/9] exec: check kvm mmu notifiers earlier marcandre.lureau
@ 2016-04-12 11:55 ` marcandre.lureau
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 3/9] exec: split qemu_ram_alloc_from_file() marcandre.lureau
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: marcandre.lureau @ 2016-04-12 11:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Move file opening part in a seperate function file_ram_open(). This
allows for reuse of file_ram_alloc() with only a fd.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 exec.c | 58 ++++++++++++++++++++++++++++++++++------------------------
 1 file changed, 34 insertions(+), 24 deletions(-)

diff --git a/exec.c b/exec.c
index dcc6632..422ea3e 100644
--- a/exec.c
+++ b/exec.c
@@ -1229,19 +1229,17 @@ void qemu_mutex_unlock_ramlist(void)
 }
 
 #ifdef __linux__
-static void *file_ram_alloc(RAMBlock *block,
-                            ram_addr_t memory,
-                            const char *path,
-                            Error **errp)
+static int file_ram_open(const char *path,
+                         const char *region_name,
+                         bool *created,
+                         Error **errp)
 {
-    bool unlink_on_error = false;
-    char *filename;
     char *sanitized_name;
+    char *filename;
     char *c;
-    void *area;
     int fd = -1;
-    int64_t page_size;
 
+    *created = false;
     for (;;) {
         fd = open(path, O_RDWR);
         if (fd >= 0) {
@@ -1252,13 +1250,13 @@ static void *file_ram_alloc(RAMBlock *block,
             /* @path names a file that doesn't exist, create it */
             fd = open(path, O_RDWR | O_CREAT | O_EXCL, 0644);
             if (fd >= 0) {
-                unlink_on_error = true;
+                *created = true;
                 break;
             }
         } else if (errno == EISDIR) {
             /* @path names a directory, create a file there */
             /* Make name safe to use with mkstemp by replacing '/' with '_'. */
-            sanitized_name = g_strdup(memory_region_name(block->mr));
+            sanitized_name = g_strdup(region_name);
             for (c = sanitized_name; *c != '\0'; c++) {
                 if (*c == '/') {
                     *c = '_';
@@ -1281,7 +1279,7 @@ static void *file_ram_alloc(RAMBlock *block,
             error_setg_errno(errp, errno,
                              "can't open backing store %s for guest RAM",
                              path);
-            goto error;
+            return -1;
         }
         /*
          * Try again on EINTR and EEXIST.  The latter happens when
@@ -1289,6 +1287,17 @@ static void *file_ram_alloc(RAMBlock *block,
          */
     }
 
+    return fd;
+}
+
+static void *file_ram_alloc(RAMBlock *block,
+                            ram_addr_t memory,
+                            int fd,
+                            Error **errp)
+{
+    void *area;
+    int64_t page_size;
+
     page_size = qemu_fd_getpagesize(fd);
     block->mr->align = page_size;
 
@@ -1296,7 +1305,7 @@ static void *file_ram_alloc(RAMBlock *block,
         error_setg(errp, "memory size 0x" RAM_ADDR_FMT " must be equal to "
                    "or larger than page size 0x%" PRIx64,
                    memory, page_size);
-        goto error;
+        return NULL;
     }
 
     memory = ROUND_UP(memory, page_size);
@@ -1315,7 +1324,7 @@ static void *file_ram_alloc(RAMBlock *block,
     if (area == MAP_FAILED) {
         error_setg_errno(errp, errno,
                          "unable to map backing store for guest RAM");
-        goto error;
+        return NULL;
     }
 
     if (mem_prealloc) {
@@ -1324,15 +1333,6 @@ static void *file_ram_alloc(RAMBlock *block,
 
     block->fd = fd;
     return area;
-
-error:
-    if (unlink_on_error) {
-        unlink(path);
-    }
-    if (fd != -1) {
-        close(fd);
-    }
-    return NULL;
 }
 #endif
 
@@ -1652,6 +1652,8 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
 {
     RAMBlock *new_block;
     Error *local_err = NULL;
+    int fd;
+    bool created;
 
     if (xen_enabled()) {
         error_setg(errp, "-mem-path not supported with Xen");
@@ -1675,15 +1677,23 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
         return NULL;
     }
 
+    fd = file_ram_open(mem_path, memory_region_name(mr), &created, errp);
+    if (fd < 0) {
+        return NULL;
+    }
+
     size = HOST_PAGE_ALIGN(size);
     new_block = g_malloc0(sizeof(*new_block));
     new_block->mr = mr;
     new_block->used_length = size;
     new_block->max_length = size;
     new_block->flags = share ? RAM_SHARED : 0;
-    new_block->host = file_ram_alloc(new_block, size,
-                                     mem_path, errp);
+    new_block->host = file_ram_alloc(new_block, size, fd, errp);
     if (!new_block->host) {
+        if (created) {
+            unlink(mem_path);
+        }
+        close(fd);
         g_free(new_block);
         return NULL;
     }
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 3/9] exec: split qemu_ram_alloc_from_file()
  2016-04-12 11:55 [Qemu-devel] [PATCH 0/9] RFC: add memfd memory backend marcandre.lureau
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 1/9] exec: check kvm mmu notifiers earlier marcandre.lureau
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 2/9] exec: split file_ram_alloc() marcandre.lureau
@ 2016-04-12 11:55 ` marcandre.lureau
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 4/9] Add memory_region_init_ram_from_fd() marcandre.lureau
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: marcandre.lureau @ 2016-04-12 11:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Add qemu_ram_alloc_from_fd(), which can be use to allocate ramblock from
fd only.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 exec.c                  | 45 ++++++++++++++++++++++++++++++---------------
 include/exec/ram_addr.h |  3 +++
 2 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/exec.c b/exec.c
index 422ea3e..8675b5e 100644
--- a/exec.c
+++ b/exec.c
@@ -1646,14 +1646,12 @@ static void ram_block_add(RAMBlock *new_block, Error **errp)
 }
 
 #ifdef __linux__
-RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
-                                   bool share, const char *mem_path,
-                                   Error **errp)
+RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr,
+                                 bool share, int fd,
+                                 Error **errp)
 {
     RAMBlock *new_block;
     Error *local_err = NULL;
-    int fd;
-    bool created;
 
     if (xen_enabled()) {
         error_setg(errp, "-mem-path not supported with Xen");
@@ -1677,11 +1675,6 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
         return NULL;
     }
 
-    fd = file_ram_open(mem_path, memory_region_name(mr), &created, errp);
-    if (fd < 0) {
-        return NULL;
-    }
-
     size = HOST_PAGE_ALIGN(size);
     new_block = g_malloc0(sizeof(*new_block));
     new_block->mr = mr;
@@ -1690,11 +1683,6 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
     new_block->flags = share ? RAM_SHARED : 0;
     new_block->host = file_ram_alloc(new_block, size, fd, errp);
     if (!new_block->host) {
-        if (created) {
-            unlink(mem_path);
-        }
-        close(fd);
-        g_free(new_block);
         return NULL;
     }
 
@@ -1705,6 +1693,33 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
         return NULL;
     }
     return new_block;
+
+}
+
+
+RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
+                                   bool share, const char *mem_path,
+                                   Error **errp)
+{
+    int fd;
+    bool created;
+    RAMBlock *block;
+
+    fd = file_ram_open(mem_path, memory_region_name(mr), &created, errp);
+    if (fd < 0) {
+        return NULL;
+    }
+
+    block = qemu_ram_alloc_from_fd(size, mr, share, fd, errp);
+    if (!block) {
+        if (created) {
+            unlink(mem_path);
+        }
+        close(fd);
+        return NULL;
+    }
+
+    return block;
 }
 #endif
 
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index 5adf7a4..153f1b2 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -97,6 +97,9 @@ void qemu_mutex_unlock_ramlist(void);
 RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
                                    bool share, const char *mem_path,
                                    Error **errp);
+RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr,
+                                 bool share, int fd,
+                                 Error **errp);
 RAMBlock *qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
                                   MemoryRegion *mr, Error **errp);
 RAMBlock *qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr, Error **errp);
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 4/9] Add memory_region_init_ram_from_fd()
  2016-04-12 11:55 [Qemu-devel] [PATCH 0/9] RFC: add memfd memory backend marcandre.lureau
                   ` (2 preceding siblings ...)
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 3/9] exec: split qemu_ram_alloc_from_file() marcandre.lureau
@ 2016-04-12 11:55 ` marcandre.lureau
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 5/9] RFC: ivshmem: use ram_from_fd() marcandre.lureau
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: marcandre.lureau @ 2016-04-12 11:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Add a new function to Initialize a RAM memory region with a mmap-ed file
descriptor.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/exec/memory.h | 20 ++++++++++++++++++++
 memory.c              | 16 ++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/include/exec/memory.h b/include/exec/memory.h
index e2a3e99..017bfdd 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -399,6 +399,26 @@ void memory_region_init_ram_from_file(MemoryRegion *mr,
                                       bool share,
                                       const char *path,
                                       Error **errp);
+
+/**
+ * memory_region_init_ram_from_fd:  Initialize RAM memory region with a
+ *                                  mmap-ed backend.
+ *
+ * @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.
+ * @share: %true if memory must be mmaped with the MAP_SHARED flag
+ * @fd: the fd to mmap.
+ * @errp: pointer to Error*, to store an error if it happens.
+ */
+void memory_region_init_ram_from_fd(MemoryRegion *mr,
+                                    struct Object *owner,
+                                    const char *name,
+                                    uint64_t size,
+                                    bool share,
+                                    int fd,
+                                    Error **errp);
 #endif
 
 /**
diff --git a/memory.c b/memory.c
index f76f85d..dad99a9 100644
--- a/memory.c
+++ b/memory.c
@@ -1351,6 +1351,22 @@ void memory_region_init_ram_from_file(MemoryRegion *mr,
     mr->ram_block = qemu_ram_alloc_from_file(size, mr, share, path, errp);
     mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
 }
+
+void memory_region_init_ram_from_fd(MemoryRegion *mr,
+                                    struct Object *owner,
+                                    const char *name,
+                                    uint64_t size,
+                                    bool share,
+                                    int fd,
+                                    Error **errp)
+{
+    memory_region_init(mr, owner, name, size);
+    mr->ram = true;
+    mr->terminates = true;
+    mr->destructor = memory_region_destructor_ram;
+    mr->ram_block = qemu_ram_alloc_from_fd(size, mr, share, fd, errp);
+    mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
+}
 #endif
 
 void memory_region_init_ram_ptr(MemoryRegion *mr,
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 5/9] RFC: ivshmem: use ram_from_fd()
  2016-04-12 11:55 [Qemu-devel] [PATCH 0/9] RFC: add memfd memory backend marcandre.lureau
                   ` (3 preceding siblings ...)
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 4/9] Add memory_region_init_ram_from_fd() marcandre.lureau
@ 2016-04-12 11:55 ` marcandre.lureau
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 6/9] exec: remove qemu_set_ram_fd() marcandre.lureau
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: marcandre.lureau @ 2016-04-12 11:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Instead of writing our own mmap handling code, reuse the code from
exec.c.

RFC because memory_region_init_ram_from_fd() adds some restrictions
(check for xen, kvm sync-mmu, etc) and changes (such as size
alignment). In practice, this doesn't seem to hurt though.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/misc/ivshmem.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index 2eb8668..08bf5c6 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -494,9 +494,9 @@ static void setup_interrupt(IVShmemState *s, int vector, Error **errp)
 
 static void process_msg_shmem(IVShmemState *s, int fd, Error **errp)
 {
+    Error *err = NULL;
     struct stat buf;
     size_t size;
-    void *ptr;
 
     if (s->ivshmem_bar2) {
         error_setg(errp, "server sent unexpected shared memory message");
@@ -525,15 +525,12 @@ static void process_msg_shmem(IVShmemState *s, int fd, Error **errp)
     }
 
     /* mmap the region and map into the BAR2 */
-    ptr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
-    if (ptr == MAP_FAILED) {
-        error_setg_errno(errp, errno, "Failed to mmap shared memory");
-        close(fd);
+    memory_region_init_ram_from_fd(&s->server_bar2, OBJECT(s),
+                                   "ivshmem.bar2", size, true, fd, &err);
+    if (err) {
+        error_propagate(errp, err);
         return;
     }
-    memory_region_init_ram_ptr(&s->server_bar2, OBJECT(s),
-                               "ivshmem.bar2", size, ptr);
-    qemu_set_ram_fd(memory_region_get_ram_addr(&s->server_bar2), fd);
     s->ivshmem_bar2 = &s->server_bar2;
 }
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 6/9] exec: remove qemu_set_ram_fd()
  2016-04-12 11:55 [Qemu-devel] [PATCH 0/9] RFC: add memfd memory backend marcandre.lureau
                   ` (4 preceding siblings ...)
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 5/9] RFC: ivshmem: use ram_from_fd() marcandre.lureau
@ 2016-04-12 11:55 ` marcandre.lureau
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 7/9] memfd: split qemu_memfd_alloc() marcandre.lureau
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: marcandre.lureau @ 2016-04-12 11:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

If the previous ivshmem patch is applied, qemu_set_ram_fd() is no longer used.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 exec.c                  | 10 ----------
 include/exec/ram_addr.h |  1 -
 2 files changed, 11 deletions(-)

diff --git a/exec.c b/exec.c
index 8675b5e..ec72064 100644
--- a/exec.c
+++ b/exec.c
@@ -1873,16 +1873,6 @@ int qemu_get_ram_fd(ram_addr_t addr)
     return fd;
 }
 
-void qemu_set_ram_fd(ram_addr_t addr, int fd)
-{
-    RAMBlock *block;
-
-    rcu_read_lock();
-    block = qemu_get_ram_block(addr);
-    block->fd = fd;
-    rcu_read_unlock();
-}
-
 void *qemu_get_ram_block_host_ptr(ram_addr_t addr)
 {
     RAMBlock *block;
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index 153f1b2..3a21aee 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -109,7 +109,6 @@ RAMBlock *qemu_ram_alloc_resizeable(ram_addr_t size, ram_addr_t max_size,
                                                     void *host),
                                     MemoryRegion *mr, Error **errp);
 int qemu_get_ram_fd(ram_addr_t addr);
-void qemu_set_ram_fd(ram_addr_t addr, int fd);
 void *qemu_get_ram_block_host_ptr(ram_addr_t addr);
 void qemu_ram_free(RAMBlock *block);
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 7/9] memfd: split qemu_memfd_alloc()
  2016-04-12 11:55 [Qemu-devel] [PATCH 0/9] RFC: add memfd memory backend marcandre.lureau
                   ` (5 preceding siblings ...)
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 6/9] exec: remove qemu_set_ram_fd() marcandre.lureau
@ 2016-04-12 11:55 ` marcandre.lureau
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 8/9] Add memfd based hostmem marcandre.lureau
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 9/9] tests: use memfd in vhost-user-test marcandre.lureau
  8 siblings, 0 replies; 12+ messages in thread
From: marcandre.lureau @ 2016-04-12 11:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/qemu/memfd.h |  1 +
 util/memfd.c         | 19 ++++++++++++++-----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/include/qemu/memfd.h b/include/qemu/memfd.h
index 745a8c5..41c24d8 100644
--- a/include/qemu/memfd.h
+++ b/include/qemu/memfd.h
@@ -16,6 +16,7 @@
 #define F_SEAL_WRITE    0x0008  /* prevent writes */
 #endif
 
+int qemu_memfd_create(const char *name, size_t size, unsigned int seals);
 void *qemu_memfd_alloc(const char *name, size_t size, unsigned int seals,
                        int *fd);
 void qemu_memfd_free(void *ptr, size_t size, int fd);
diff --git a/util/memfd.c b/util/memfd.c
index 7c40691..31aaced 100644
--- a/util/memfd.c
+++ b/util/memfd.c
@@ -64,14 +64,10 @@ static int memfd_create(const char *name, unsigned int flags)
  * memfd with sealing, but may fallback on other methods without
  * sealing.
  */
-void *qemu_memfd_alloc(const char *name, size_t size, unsigned int seals,
-                       int *fd)
+int qemu_memfd_create(const char *name, size_t size, unsigned int seals)
 {
-    void *ptr;
     int mfd = -1;
 
-    *fd = -1;
-
 #ifdef CONFIG_LINUX
     if (seals) {
         mfd = memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC);
@@ -117,6 +113,19 @@ void *qemu_memfd_alloc(const char *name, size_t size, unsigned int seals,
         }
     }
 
+    return mfd;
+}
+
+void *qemu_memfd_alloc(const char *name, size_t size, unsigned int seals,
+                       int *fd)
+{
+    void *ptr;
+    int mfd = qemu_memfd_create(name, size, seals);
+
+    if (mfd == -1) {
+        return NULL;
+    }
+
     ptr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, mfd, 0);
     if (ptr == MAP_FAILED) {
         perror("mmap");
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 8/9] Add memfd based hostmem
  2016-04-12 11:55 [Qemu-devel] [PATCH 0/9] RFC: add memfd memory backend marcandre.lureau
                   ` (6 preceding siblings ...)
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 7/9] memfd: split qemu_memfd_alloc() marcandre.lureau
@ 2016-04-12 11:55 ` marcandre.lureau
  2016-04-12 13:07   ` Igor Mammedov
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 9/9] tests: use memfd in vhost-user-test marcandre.lureau
  8 siblings, 1 reply; 12+ messages in thread
From: marcandre.lureau @ 2016-04-12 11:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Add a new memory backend, similar to hostmem-file, except that it
doesn't need a file path, or hugepages directory permissions. It also
try to enforce memory sealing if available.

This backend is mainly useful for easily sharing the memory with other
processes, for example with vhost-user backend, when hugepages aren't
available (for security reasons and other limitations).

Usage:
-object memory-backend-memfd,id=mem1,size=1G

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 backends/Makefile.objs   |  1 +
 backends/hostmem-memfd.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++
 qemu-options.hx          | 12 +++++++
 3 files changed, 98 insertions(+)
 create mode 100644 backends/hostmem-memfd.c

diff --git a/backends/Makefile.objs b/backends/Makefile.objs
index 31a3a89..32cfcdb 100644
--- a/backends/Makefile.objs
+++ b/backends/Makefile.objs
@@ -9,3 +9,4 @@ common-obj-$(CONFIG_TPM) += tpm.o
 
 common-obj-y += hostmem.o hostmem-ram.o
 common-obj-$(CONFIG_LINUX) += hostmem-file.o
+common-obj-$(CONFIG_POSIX) += hostmem-memfd.o
diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c
new file mode 100644
index 0000000..e0e18d7
--- /dev/null
+++ b/backends/hostmem-memfd.c
@@ -0,0 +1,85 @@
+/*
+ * QEMU host memfd memory backend
+ *
+ * Copyright (C) 2016 Red Hat Inc
+ *
+ * Authors:
+ *   Marc-André Lureau <marcandre.lureau@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "sysemu/hostmem.h"
+#include "sysemu/sysemu.h"
+#include "qom/object_interfaces.h"
+#include "qemu/memfd.h"
+#include "qapi/error.h"
+
+/**
+ * @TYPE_MEMORY_BACKEND_MEMFD:
+ * name of the memory backend that uses memfd mmap
+ */
+#define TYPE_MEMORY_BACKEND_MEMFD "memory-backend-memfd"
+
+#define MEMORY_BACKEND_MEMFD(obj) \
+    OBJECT_CHECK(HostMemoryBackendMemfd, (obj), TYPE_MEMORY_BACKEND_MEMFD)
+
+typedef struct HostMemoryBackendMemfd HostMemoryBackendMemfd;
+
+struct HostMemoryBackendMemfd {
+    HostMemoryBackend parent_obj;
+
+    int fd;
+};
+
+static void
+memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
+{
+    int fd;
+
+    if (!backend->size) {
+        error_setg(errp, "can't create backend with size 0");
+        return;
+    }
+#ifndef CONFIG_LINUX
+    error_setg(errp, "memfd not supported on this host");
+#else
+    if (!memory_region_size(&backend->mr)) {
+        backend->force_prealloc = mem_prealloc;
+        fd = qemu_memfd_create(TYPE_MEMORY_BACKEND_MEMFD,
+                               backend->size,
+                               F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL);
+        if (fd == -1) {
+            error_setg(errp, "can't allocate memfd backend");
+            return;
+        }
+        memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend),
+            object_get_canonical_path(OBJECT(backend)),
+            backend->size, true, fd, errp);
+    }
+#endif
+}
+
+static void
+memfd_backend_class_init(ObjectClass *oc, void *data)
+{
+    HostMemoryBackendClass *bc = MEMORY_BACKEND_CLASS(oc);
+
+    bc->alloc = memfd_backend_memory_alloc;
+}
+
+static const TypeInfo memfd_backend_info = {
+    .name = TYPE_MEMORY_BACKEND_MEMFD,
+    .parent = TYPE_MEMORY_BACKEND,
+    .class_init = memfd_backend_class_init,
+    .instance_size = sizeof(HostMemoryBackendMemfd),
+};
+
+static void register_types(void)
+{
+    type_register_static(&memfd_backend_info);
+}
+
+type_init(register_types);
diff --git a/qemu-options.hx b/qemu-options.hx
index 587de8f..a54af0f 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3756,6 +3756,18 @@ The @option{share} boolean option determines whether the memory
 region is marked as private to QEMU, or shared. The latter allows
 a co-operating external process to access the QEMU memory region.
 
+@item -object memory-backend-memfd,id=@var{id},size=@var{size}
+
+Creates an anonymous memory file backend object, which can be used to
+share the memory with a co-operating external process. The memory is
+created with memfd and sealing if possible, but has fallback mechanism
+for systems that lack it.
+
+The @option{id} parameter is a unique ID that will be used to
+reference this memory region when configuring the @option{-numa}
+argument. The @option{size} option provides the size of the memory
+region, and accepts common suffixes, eg @option{500M}.
+
 @item -object rng-random,id=@var{id},filename=@var{/dev/random}
 
 Creates a random number generator backend which obtains entropy from
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 9/9] tests: use memfd in vhost-user-test
  2016-04-12 11:55 [Qemu-devel] [PATCH 0/9] RFC: add memfd memory backend marcandre.lureau
                   ` (7 preceding siblings ...)
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 8/9] Add memfd based hostmem marcandre.lureau
@ 2016-04-12 11:55 ` marcandre.lureau
  8 siblings, 0 replies; 12+ messages in thread
From: marcandre.lureau @ 2016-04-12 11:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

This will exercise the memfd memory backend and should generally be
better for testing than memory-backend-file (thanks to anonymous files
and sealing).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 tests/vhost-user-test.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 6961596..6ef6c48 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -32,8 +32,8 @@
 #endif
 
 #define QEMU_CMD_ACCEL  " -machine accel=tcg"
-#define QEMU_CMD_MEM    " -m %d -object memory-backend-file,id=mem,size=%dM,"\
-                        "mem-path=%s,share=on -numa node,memdev=mem"
+#define QEMU_CMD_MEM    " -m %d -object memory-backend-memfd,id=mem,size=%dM"\
+                        " -numa node,memdev=mem"
 #define QEMU_CMD_CHR    " -chardev socket,id=%s,path=%s"
 #define QEMU_CMD_NETDEV " -netdev vhost-user,id=net0,chardev=%s,vhostforce"
 #define QEMU_CMD_NET    " -device virtio-net-pci,netdev=net0,romfile=./pc-bios/pxe-virtio.rom"
@@ -383,12 +383,12 @@ static TestServer *test_server_new(const gchar *name)
     return server;
 }
 
-#define GET_QEMU_CMD(s)                                                        \
-    g_strdup_printf(QEMU_CMD, 512, 512, (root), (s)->chr_name,                 \
+#define GET_QEMU_CMD(s)                                 \
+    g_strdup_printf(QEMU_CMD, 512, 512, (s)->chr_name,  \
                     (s)->socket_path, (s)->chr_name)
 
-#define GET_QEMU_CMDE(s, mem, extra, ...)                                      \
-    g_strdup_printf(QEMU_CMD extra, (mem), (mem), (root), (s)->chr_name,       \
+#define GET_QEMU_CMDE(s, mem, extra, ...)                               \
+    g_strdup_printf(QEMU_CMD extra, (mem), (mem), (s)->chr_name,        \
                     (s)->socket_path, (s)->chr_name, ##__VA_ARGS__)
 
 static gboolean _test_server_free(TestServer *server)
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 8/9] Add memfd based hostmem
  2016-04-12 11:55 ` [Qemu-devel] [PATCH 8/9] Add memfd based hostmem marcandre.lureau
@ 2016-04-12 13:07   ` Igor Mammedov
  2016-04-12 13:32     ` Marc-André Lureau
  0 siblings, 1 reply; 12+ messages in thread
From: Igor Mammedov @ 2016-04-12 13:07 UTC (permalink / raw)
  To: marcandre.lureau; +Cc: qemu-devel, pbonzini

On Tue, 12 Apr 2016 13:55:28 +0200
marcandre.lureau@redhat.com wrote:

> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> Add a new memory backend, similar to hostmem-file, except that it
> doesn't need a file path, or hugepages directory permissions. It also
> try to enforce memory sealing if available.
> 
> This backend is mainly useful for easily sharing the memory with other
> processes, for example with vhost-user backend, when hugepages aren't
> available (for security reasons and other limitations).
> 
> Usage:
> -object memory-backend-memfd,id=mem1,size=1G
Does it make sense if it's possible to reuse/extend memory-backend-file,
i.e. make 'mem-path' optional and behave like this patch
and also add 'memfd' property so that parent process could
pass its handle to QEMU as well?

> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  backends/Makefile.objs   |  1 +
>  backends/hostmem-memfd.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++
>  qemu-options.hx          | 12 +++++++
>  3 files changed, 98 insertions(+)
>  create mode 100644 backends/hostmem-memfd.c
> 
> diff --git a/backends/Makefile.objs b/backends/Makefile.objs
> index 31a3a89..32cfcdb 100644
> --- a/backends/Makefile.objs
> +++ b/backends/Makefile.objs
> @@ -9,3 +9,4 @@ common-obj-$(CONFIG_TPM) += tpm.o
>  
>  common-obj-y += hostmem.o hostmem-ram.o
>  common-obj-$(CONFIG_LINUX) += hostmem-file.o
> +common-obj-$(CONFIG_POSIX) += hostmem-memfd.o
> diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c
> new file mode 100644
> index 0000000..e0e18d7
> --- /dev/null
> +++ b/backends/hostmem-memfd.c
> @@ -0,0 +1,85 @@
> +/*
> + * QEMU host memfd memory backend
> + *
> + * Copyright (C) 2016 Red Hat Inc
> + *
> + * Authors:
> + *   Marc-André Lureau <marcandre.lureau@redhat.com>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + */
> +#include "qemu/osdep.h"
> +#include "qemu-common.h"
> +#include "sysemu/hostmem.h"
> +#include "sysemu/sysemu.h"
> +#include "qom/object_interfaces.h"
> +#include "qemu/memfd.h"
> +#include "qapi/error.h"
> +
> +/**
> + * @TYPE_MEMORY_BACKEND_MEMFD:
> + * name of the memory backend that uses memfd mmap
> + */
> +#define TYPE_MEMORY_BACKEND_MEMFD "memory-backend-memfd"
> +
> +#define MEMORY_BACKEND_MEMFD(obj) \
> +    OBJECT_CHECK(HostMemoryBackendMemfd, (obj), TYPE_MEMORY_BACKEND_MEMFD)
> +
> +typedef struct HostMemoryBackendMemfd HostMemoryBackendMemfd;
> +
> +struct HostMemoryBackendMemfd {
> +    HostMemoryBackend parent_obj;
> +
> +    int fd;
> +};
> +
> +static void
> +memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
> +{
> +    int fd;
> +
> +    if (!backend->size) {
> +        error_setg(errp, "can't create backend with size 0");
> +        return;
> +    }
> +#ifndef CONFIG_LINUX
> +    error_setg(errp, "memfd not supported on this host");
> +#else
> +    if (!memory_region_size(&backend->mr)) {
> +        backend->force_prealloc = mem_prealloc;
> +        fd = qemu_memfd_create(TYPE_MEMORY_BACKEND_MEMFD,
> +                               backend->size,
> +                               F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL);
> +        if (fd == -1) {
> +            error_setg(errp, "can't allocate memfd backend");
> +            return;
> +        }
> +        memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend),
> +            object_get_canonical_path(OBJECT(backend)),
> +            backend->size, true, fd, errp);
> +    }
> +#endif
> +}
> +
> +static void
> +memfd_backend_class_init(ObjectClass *oc, void *data)
> +{
> +    HostMemoryBackendClass *bc = MEMORY_BACKEND_CLASS(oc);
> +
> +    bc->alloc = memfd_backend_memory_alloc;
> +}
> +
> +static const TypeInfo memfd_backend_info = {
> +    .name = TYPE_MEMORY_BACKEND_MEMFD,
> +    .parent = TYPE_MEMORY_BACKEND,
> +    .class_init = memfd_backend_class_init,
> +    .instance_size = sizeof(HostMemoryBackendMemfd),
> +};
> +
> +static void register_types(void)
> +{
> +    type_register_static(&memfd_backend_info);
> +}
> +
> +type_init(register_types);
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 587de8f..a54af0f 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -3756,6 +3756,18 @@ The @option{share} boolean option determines whether the memory
>  region is marked as private to QEMU, or shared. The latter allows
>  a co-operating external process to access the QEMU memory region.
>  
> +@item -object memory-backend-memfd,id=@var{id},size=@var{size}
> +
> +Creates an anonymous memory file backend object, which can be used to
> +share the memory with a co-operating external process. The memory is
> +created with memfd and sealing if possible, but has fallback mechanism
> +for systems that lack it.
> +
> +The @option{id} parameter is a unique ID that will be used to
> +reference this memory region when configuring the @option{-numa}
> +argument. The @option{size} option provides the size of the memory
> +region, and accepts common suffixes, eg @option{500M}.
> +
>  @item -object rng-random,id=@var{id},filename=@var{/dev/random}
>  
>  Creates a random number generator backend which obtains entropy from

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 8/9] Add memfd based hostmem
  2016-04-12 13:07   ` Igor Mammedov
@ 2016-04-12 13:32     ` Marc-André Lureau
  0 siblings, 0 replies; 12+ messages in thread
From: Marc-André Lureau @ 2016-04-12 13:32 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: marcandre lureau, qemu-devel, pbonzini



----- Original Message -----
> On Tue, 12 Apr 2016 13:55:28 +0200
> marcandre.lureau@redhat.com wrote:
> 
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> > 
> > Add a new memory backend, similar to hostmem-file, except that it
> > doesn't need a file path, or hugepages directory permissions. It also
> > try to enforce memory sealing if available.
> > 
> > This backend is mainly useful for easily sharing the memory with other
> > processes, for example with vhost-user backend, when hugepages aren't
> > available (for security reasons and other limitations).
> > 
> > Usage:
> > -object memory-backend-memfd,id=mem1,size=1G
> Does it make sense if it's possible to reuse/extend memory-backend-file,
> i.e. make 'mem-path' optional and behave like this patch
> and also add 'memfd' property so that parent process could
> pass its handle to QEMU as well?

I don't mind, I would be a bit worried by the combination of options and the expected result though.

> > 
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  backends/Makefile.objs   |  1 +
> >  backends/hostmem-memfd.c | 85
> >  ++++++++++++++++++++++++++++++++++++++++++++++++
> >  qemu-options.hx          | 12 +++++++
> >  3 files changed, 98 insertions(+)
> >  create mode 100644 backends/hostmem-memfd.c
> > 
> > diff --git a/backends/Makefile.objs b/backends/Makefile.objs
> > index 31a3a89..32cfcdb 100644
> > --- a/backends/Makefile.objs
> > +++ b/backends/Makefile.objs
> > @@ -9,3 +9,4 @@ common-obj-$(CONFIG_TPM) += tpm.o
> >  
> >  common-obj-y += hostmem.o hostmem-ram.o
> >  common-obj-$(CONFIG_LINUX) += hostmem-file.o
> > +common-obj-$(CONFIG_POSIX) += hostmem-memfd.o
> > diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c
> > new file mode 100644
> > index 0000000..e0e18d7
> > --- /dev/null
> > +++ b/backends/hostmem-memfd.c
> > @@ -0,0 +1,85 @@
> > +/*
> > + * QEMU host memfd memory backend
> > + *
> > + * Copyright (C) 2016 Red Hat Inc
> > + *
> > + * Authors:
> > + *   Marc-André Lureau <marcandre.lureau@redhat.com>
> > + *
> > + * This work is licensed under the terms of the GNU GPL, version 2 or
> > later.
> > + * See the COPYING file in the top-level directory.
> > + */
> > +#include "qemu/osdep.h"
> > +#include "qemu-common.h"
> > +#include "sysemu/hostmem.h"
> > +#include "sysemu/sysemu.h"
> > +#include "qom/object_interfaces.h"
> > +#include "qemu/memfd.h"
> > +#include "qapi/error.h"
> > +
> > +/**
> > + * @TYPE_MEMORY_BACKEND_MEMFD:
> > + * name of the memory backend that uses memfd mmap
> > + */
> > +#define TYPE_MEMORY_BACKEND_MEMFD "memory-backend-memfd"
> > +
> > +#define MEMORY_BACKEND_MEMFD(obj) \
> > +    OBJECT_CHECK(HostMemoryBackendMemfd, (obj), TYPE_MEMORY_BACKEND_MEMFD)
> > +
> > +typedef struct HostMemoryBackendMemfd HostMemoryBackendMemfd;
> > +
> > +struct HostMemoryBackendMemfd {
> > +    HostMemoryBackend parent_obj;
> > +
> > +    int fd;
> > +};
> > +
> > +static void
> > +memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
> > +{
> > +    int fd;
> > +
> > +    if (!backend->size) {
> > +        error_setg(errp, "can't create backend with size 0");
> > +        return;
> > +    }
> > +#ifndef CONFIG_LINUX
> > +    error_setg(errp, "memfd not supported on this host");
> > +#else
> > +    if (!memory_region_size(&backend->mr)) {
> > +        backend->force_prealloc = mem_prealloc;
> > +        fd = qemu_memfd_create(TYPE_MEMORY_BACKEND_MEMFD,
> > +                               backend->size,
> > +                               F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL);
> > +        if (fd == -1) {
> > +            error_setg(errp, "can't allocate memfd backend");
> > +            return;
> > +        }
> > +        memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend),
> > +            object_get_canonical_path(OBJECT(backend)),
> > +            backend->size, true, fd, errp);
> > +    }
> > +#endif
> > +}
> > +
> > +static void
> > +memfd_backend_class_init(ObjectClass *oc, void *data)
> > +{
> > +    HostMemoryBackendClass *bc = MEMORY_BACKEND_CLASS(oc);
> > +
> > +    bc->alloc = memfd_backend_memory_alloc;
> > +}
> > +
> > +static const TypeInfo memfd_backend_info = {
> > +    .name = TYPE_MEMORY_BACKEND_MEMFD,
> > +    .parent = TYPE_MEMORY_BACKEND,
> > +    .class_init = memfd_backend_class_init,
> > +    .instance_size = sizeof(HostMemoryBackendMemfd),
> > +};
> > +
> > +static void register_types(void)
> > +{
> > +    type_register_static(&memfd_backend_info);
> > +}
> > +
> > +type_init(register_types);
> > diff --git a/qemu-options.hx b/qemu-options.hx
> > index 587de8f..a54af0f 100644
> > --- a/qemu-options.hx
> > +++ b/qemu-options.hx
> > @@ -3756,6 +3756,18 @@ The @option{share} boolean option determines whether
> > the memory
> >  region is marked as private to QEMU, or shared. The latter allows
> >  a co-operating external process to access the QEMU memory region.
> >  
> > +@item -object memory-backend-memfd,id=@var{id},size=@var{size}
> > +
> > +Creates an anonymous memory file backend object, which can be used to
> > +share the memory with a co-operating external process. The memory is
> > +created with memfd and sealing if possible, but has fallback mechanism
> > +for systems that lack it.
> > +
> > +The @option{id} parameter is a unique ID that will be used to
> > +reference this memory region when configuring the @option{-numa}
> > +argument. The @option{size} option provides the size of the memory
> > +region, and accepts common suffixes, eg @option{500M}.
> > +
> >  @item -object rng-random,id=@var{id},filename=@var{/dev/random}
> >  
> >  Creates a random number generator backend which obtains entropy from
> 
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-04-12 13:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-12 11:55 [Qemu-devel] [PATCH 0/9] RFC: add memfd memory backend marcandre.lureau
2016-04-12 11:55 ` [Qemu-devel] [PATCH 1/9] exec: check kvm mmu notifiers earlier marcandre.lureau
2016-04-12 11:55 ` [Qemu-devel] [PATCH 2/9] exec: split file_ram_alloc() marcandre.lureau
2016-04-12 11:55 ` [Qemu-devel] [PATCH 3/9] exec: split qemu_ram_alloc_from_file() marcandre.lureau
2016-04-12 11:55 ` [Qemu-devel] [PATCH 4/9] Add memory_region_init_ram_from_fd() marcandre.lureau
2016-04-12 11:55 ` [Qemu-devel] [PATCH 5/9] RFC: ivshmem: use ram_from_fd() marcandre.lureau
2016-04-12 11:55 ` [Qemu-devel] [PATCH 6/9] exec: remove qemu_set_ram_fd() marcandre.lureau
2016-04-12 11:55 ` [Qemu-devel] [PATCH 7/9] memfd: split qemu_memfd_alloc() marcandre.lureau
2016-04-12 11:55 ` [Qemu-devel] [PATCH 8/9] Add memfd based hostmem marcandre.lureau
2016-04-12 13:07   ` Igor Mammedov
2016-04-12 13:32     ` Marc-André Lureau
2016-04-12 11:55 ` [Qemu-devel] [PATCH 9/9] tests: use memfd in vhost-user-test marcandre.lureau

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.