From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52293) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTLSz-0004i5-No for qemu-devel@nongnu.org; Mon, 07 Oct 2013 20:48:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTLSt-0005EP-KV for qemu-devel@nongnu.org; Mon, 07 Oct 2013 20:48:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59988) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTLSt-0005E8-Cj for qemu-devel@nongnu.org; Mon, 07 Oct 2013 20:47:55 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r980lseJ031613 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 7 Oct 2013 20:47:54 -0400 Message-Id: <20131008004224.581631545@amt.cnet> Date: Mon, 07 Oct 2013 21:41:28 -0300 From: Marcelo Tosatti References: <20131008004126.773017235@amt.cnet> Content-Disposition: inline; filename=add-option-to-force-mem-path Subject: [Qemu-devel] [patch 2/2] qemu: add -mem-path-force option to force RAM allocation via -mem-path List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Marcelo Tosatti 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 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)