All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: qemu-devel@nongnu.org
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Subject: [Qemu-devel] [patch 2/2] qemu: add -mem-path-force option to force RAM allocation via -mem-path
Date: Mon, 07 Oct 2013 21:41:28 -0300	[thread overview]
Message-ID: <20131008004224.581631545@amt.cnet> (raw)
In-Reply-To: 20131008004126.773017235@amt.cnet

[-- Attachment #1: add-option-to-force-mem-path --]
[-- Type: text/plain, Size: 3108 bytes --]

Default behaviour is to fallback for standard RAM allocation if -mem-path
allocation fails.

Add an option to force -mem-path RAM allocation (failing otherwise).

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: qemu/exec.c
===================================================================
--- qemu.orig/exec.c
+++ qemu/exec.c
@@ -985,6 +985,9 @@ static void *file_ram_alloc(RAMBlock *bl
     if (area == MAP_FAILED) {
         perror("file_ram_alloc: can't mmap RAM pages");
         close(fd);
+        if (mem_path_force) {
+            exit(1);
+        }
         return (NULL);
     }
 
Index: qemu/vl.c
===================================================================
--- qemu.orig/vl.c
+++ qemu/vl.c
@@ -189,6 +189,7 @@ const char* keyboard_layout = NULL;
 ram_addr_t ram_size;
 const char *mem_path = NULL;
 int mem_prealloc = 0; /* force preallocation of physical target memory */
+int mem_path_force = 0; /* quit in case -mem-path allocation fails */
 int nb_nics;
 NICInfo nd_table[MAX_NICS];
 int autostart;
@@ -3203,6 +3204,9 @@ int main(int argc, char **argv, char **e
             case QEMU_OPTION_mempath:
                 mem_path = optarg;
                 break;
+            case QEMU_OPTION_mempath_force:
+                mem_path_force = 1;
+                break;
             case QEMU_OPTION_mem_prealloc:
                 mem_prealloc = 1;
                 break;
Index: qemu/include/exec/cpu-all.h
===================================================================
--- qemu.orig/include/exec/cpu-all.h
+++ qemu/include/exec/cpu-all.h
@@ -468,6 +468,7 @@ typedef struct RAMList {
 extern RAMList ram_list;
 
 extern const char *mem_path;
+extern int mem_path_force;
 extern int mem_prealloc;
 
 /* Flags stored in the low bits of the TLB virtual address.  These are
Index: qemu/qemu-options.def
===================================================================
--- qemu.orig/qemu-options.def
+++ qemu/qemu-options.def
@@ -66,6 +66,9 @@ stringify(DEFAULT_RAM_SIZE) "]\n", QEMU_
 DEF("mem-path", HAS_ARG, QEMU_OPTION_mempath,
 "-mem-path FILE  provide backing storage for guest RAM\n", QEMU_ARCH_ALL)
 
+DEF("mem-path-force", 0, QEMU_OPTION_mempath_force,
+"-mem-path-force    fail if unable to allocate RAM as specified by -mem-path\n", QEMU_ARCH_ALL)
+
 DEF("mem-prealloc", 0, QEMU_OPTION_mem_prealloc,
 "-mem-prealloc   preallocate guest memory (use with -mem-path)\n",
 QEMU_ARCH_ALL)
Index: qemu/qemu-options.hx
===================================================================
--- qemu.orig/qemu-options.hx
+++ qemu/qemu-options.hx
@@ -228,6 +228,14 @@ STEXI
 Allocate guest RAM from a temporarily created file in @var{path}.
 ETEXI
 
+DEF("mem-path-force", 0, QEMU_OPTION_mempath_force,
+    "-mem-path-force    fail if unable to allocate RAM as specified by -mem-path\n", QEMU_ARCH_ALL)
+STEXI
+@item -mem-path-force
+@findex -mem-path-force
+Fail if unable to allocate RAM as specified by -mem-path.
+ETEXI
+
 DEF("mem-prealloc", 0, QEMU_OPTION_mem_prealloc,
     "-mem-prealloc   preallocate guest memory (use with -mem-path)\n",
     QEMU_ARCH_ALL)

  parent reply	other threads:[~2013-10-08  0:48 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-08  0:41 [Qemu-devel] [patch 0/2] force -mem-path RAM allocation Marcelo Tosatti
2013-10-08  0:41 ` [Qemu-devel] [patch 1/2] qemu: mempath: prefault pages manually Marcelo Tosatti
2013-10-08  8:03   ` Paolo Bonzini
2013-10-08 21:51     ` Marcelo Tosatti
2013-10-09  8:05       ` Paolo Bonzini
2013-10-09 19:41         ` Marcelo Tosatti
2013-10-09 21:26           ` Paolo Bonzini
2013-10-10  2:11             ` Marcelo Tosatti
2013-10-10  6:30             ` Paolo Bonzini
2013-10-28 13:48   ` Paolo Bonzini
2013-10-28 19:21     ` [Qemu-devel] qemu: mempath: prefault pages manually (v3) Marcelo Tosatti
2013-10-28 20:51       ` [Qemu-devel] qemu: mempath: prefault pages manually (v4) Marcelo Tosatti
2013-10-28 16:15   ` [Qemu-devel] [patch 1/2] qemu: mempath: prefault pages manually Peter Maydell
2013-10-08  0:41 ` Marcelo Tosatti [this message]
2013-10-08  7:32 ` [Qemu-devel] [patch 0/2] force -mem-path RAM allocation Markus Armbruster
2013-10-08  8:02   ` Paolo Bonzini
2013-10-08 22:03     ` Marcelo Tosatti
2013-10-09  6:23       ` Markus Armbruster
2013-10-09 20:05         ` Marcelo Tosatti
2013-10-09 21:27           ` Paolo Bonzini
2013-10-10 15:17             ` Marcelo Tosatti
2013-10-09  7:43       ` 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=20131008004224.581631545@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 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.