From patchwork Fri Mar 7 00:40:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 327667 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C18972C00AF for ; Fri, 7 Mar 2014 11:41:16 +1100 (EST) Received: from localhost ([::1]:33716 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLiqg-0001zc-KY for incoming@patchwork.ozlabs.org; Thu, 06 Mar 2014 19:41:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44309) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLipw-0001pR-2o for qemu-devel@nongnu.org; Thu, 06 Mar 2014 19:40:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WLipq-0007Ma-2D for qemu-devel@nongnu.org; Thu, 06 Mar 2014 19:40:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57548) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLipp-0007MO-Qu for qemu-devel@nongnu.org; Thu, 06 Mar 2014 19:40:22 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s270eKSp006572 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 6 Mar 2014 19:40:20 -0500 Received: from amt.cnet (vpn1-6-40.gru2.redhat.com [10.97.6.40]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s270eJK2001861; Thu, 6 Mar 2014 19:40:19 -0500 Received: from amt.cnet (localhost [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 111B4104AFB; Thu, 6 Mar 2014 21:40:06 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.6/8.14.6/Submit) id s270e41A006356; Thu, 6 Mar 2014 21:40:04 -0300 Date: Thu, 6 Mar 2014 21:40:04 -0300 From: Marcelo Tosatti To: qemu-devel Message-ID: <20140307004004.GA6114@amt.cnet> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Paolo Bonzini , Igor Mammedov Subject: [Qemu-devel] [PATCH] mempath: add option to specify minimum huge page size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Failing initialization in case hugepage path has hugepage smaller than specified. Signed-off-by: Marcelo Tosatti diff --git a/exec.c b/exec.c index b69fd29..c95a0f3 100644 --- a/exec.c +++ b/exec.c @@ -1034,6 +1034,13 @@ static void *file_ram_alloc(RAMBlock *block, return NULL; } + if (mem_path_min_hpagesize && hpagesize < mem_path_min_hpagesize) { + fprintf(stderr, "mount point (%s) has page size " + "(%ld) < (%ld) = min_hpagesize\n", path, hpagesize, + mem_path_min_hpagesize); + exit(1); + } + if (memory < hpagesize) { return NULL; } diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 4cb4b4a..cc9e28a 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -470,6 +470,7 @@ extern RAMList ram_list; extern const char *mem_path; extern int mem_prealloc; +extern unsigned long int mem_path_min_hpagesize; /* Flags stored in the low bits of the TLB virtual address. These are defined so that fast path ram access is all zeros. */ diff --git a/qemu-options.hx b/qemu-options.hx index 56e5fdf..36743e1 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -221,9 +221,9 @@ gigabytes respectively. ETEXI DEF("mem-path", HAS_ARG, QEMU_OPTION_mempath, - "-mem-path FILE provide backing storage for guest RAM\n", QEMU_ARCH_ALL) + "-mem-path [mem-path=]file[,min-hpage-size=value] provide backing storage for guest RAM\n", QEMU_ARCH_ALL) STEXI -@item -mem-path @var{path} +@item -mem-path [mem-path=]@var{path}[,min-hpage-size=@var{min-hpage-size}] @findex -mem-path Allocate guest RAM from a temporarily created file in @var{path}. ETEXI diff --git a/vl.c b/vl.c index 1d27b34..08f9bee 100644 --- a/vl.c +++ b/vl.c @@ -136,6 +136,7 @@ static int display_remote; const char* keyboard_layout = NULL; ram_addr_t ram_size; const char *mem_path = NULL; +unsigned long int mem_path_min_hpagesize; int mem_prealloc = 0; /* force preallocation of physical target memory */ int nb_nics; NICInfo nd_table[MAX_NICS]; @@ -479,6 +480,22 @@ static QemuOptsList qemu_msg_opts = { }, }; +static QemuOptsList qemu_mempath_opts = { + .name = "mem-path", + .implied_opt_name = "mem-path", + .head = QTAILQ_HEAD_INITIALIZER(qemu_mempath_opts.head), + .desc = { + { + .name = "mem-path", + .type = QEMU_OPT_STRING, + },{ + .name = "min-hpage-size", + .type = QEMU_OPT_SIZE, + }, + { /* end of list */ } + }, +}; + /** * Get machine options * @@ -2863,6 +2880,7 @@ int main(int argc, char **argv, char **envp) qemu_add_opts(&qemu_tpmdev_opts); qemu_add_opts(&qemu_realtime_opts); qemu_add_opts(&qemu_msg_opts); + qemu_add_opts(&qemu_mempath_opts); runstate_init(); @@ -3189,9 +3207,16 @@ int main(int argc, char **argv, char **envp) } break; #endif - case QEMU_OPTION_mempath: - mem_path = optarg; + case QEMU_OPTION_mempath: { + opts = qemu_opts_parse(qemu_find_opts("mem-path"), optarg, 1); + if (!opts) { + exit(1); + } + mem_path = qemu_opt_get(opts, "mem-path"); + mem_path_min_hpagesize = qemu_opt_get_size(opts, + "min-hpage-size", 0); break; + } case QEMU_OPTION_mem_prealloc: mem_prealloc = 1; break;