From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WI37I-0007nB-RD for qemu-devel@nongnu.org; Mon, 24 Feb 2014 16:31:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WI378-0007gC-Rc for qemu-devel@nongnu.org; Mon, 24 Feb 2014 16:31:12 -0500 Received: from e33.co.us.ibm.com ([32.97.110.151]:51068) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WI378-0007g2-Kh for qemu-devel@nongnu.org; Mon, 24 Feb 2014 16:31:02 -0500 Received: from /spool/local by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 24 Feb 2014 14:31:02 -0700 Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id C7E753E40045 for ; Mon, 24 Feb 2014 14:30:58 -0700 (MST) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by b03cxnp07029.gho.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s1OJSIVp8520054 for ; Mon, 24 Feb 2014 20:28:18 +0100 Received: from d03av01.boulder.ibm.com (localhost [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s1OLUwMZ012428 for ; Mon, 24 Feb 2014 14:30:58 -0700 From: Matthew Rosato Date: Mon, 24 Feb 2014 16:30:50 -0500 Message-Id: <1393277453-13942-3-git-send-email-mjrosato@linux.vnet.ibm.com> In-Reply-To: <1393277453-13942-1-git-send-email-mjrosato@linux.vnet.ibm.com> References: <1393277453-13942-1-git-send-email-mjrosato@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v2 2/5] vl.c: extend -m option to support options for memory hotplug List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, gleb@redhat.com, agraf@suse.de, borntraeger@de.ibm.com, aliguori@amazon.com, imammedo@redhat.com, cornelia.huck@de.ibm.com, pbonzini@redhat.com, rth@twiddle.net From: Igor Mammedov Add following parameters: "slots" - total number of hotplug memory slots "maxmem" - maximum possible memory "slots" and "maxmem" should go in pair and "maxmem" should be greater than "mem" for memory hotplug to be enabled. Signed-off-by: Igor Mammedov --- qemu-options.hx | 7 +++++-- vl.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index 4d7ef52..ff60504 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -210,10 +210,13 @@ use is discouraged as it may be removed from future versions. ETEXI DEF("m", HAS_ARG, QEMU_OPTION_m, - "-m [mem=]megs\n" + "-m [mem=]megs[,slots=n,maxmem=size]\n" " configure guest RAM\n" " mem: initial amount of guest memory (default: " - stringify(DEFAULT_RAM_SIZE) "Mb)\n", + stringify(DEFAULT_RAM_SIZE) "Mb)\n" + " slots=number of hotplug slots (default: none)\n" + " maxmem=maximum amount of guest memory (default: none)\n" + " slots and maxmem must be used together\n", QEMU_ARCH_ALL) STEXI @item -m @var{megs} diff --git a/vl.c b/vl.c index a3e43d6..d8ff51f 100644 --- a/vl.c +++ b/vl.c @@ -542,6 +542,14 @@ static QemuOptsList qemu_mem_opts = { .name = "mem", .type = QEMU_OPT_SIZE, }, + { + .name = "slots", + .type = QEMU_OPT_NUMBER, + }, + { + .name = "maxmem", + .type = QEMU_OPT_SIZE, + }, { /* end of list */ } }, }; @@ -3226,6 +3234,7 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_m: { uint64_t sz; const char *mem_str; + const char *maxmem_str, *slots_str; opts = qemu_opts_parse(qemu_find_opts("memory-opts"), optarg, 1); @@ -3255,6 +3264,42 @@ int main(int argc, char **argv, char **envp) fprintf(stderr, "qemu: ram size too large\n"); exit(1); } + + maxmem_str = qemu_opt_get(opts, "maxmem"); + slots_str = qemu_opt_get(opts, "slots"); + if (maxmem_str && slots_str) { + uint64_t slots; + + sz = qemu_opt_get_size(opts, "maxmem", 0); + if (sz < ram_size) { + fprintf(stderr, "qemu: invalid -m option value: maxmem " + "(%" PRIu64 ") <= initial memory (%" + PRIu64 ")\n", sz, ram_size); + exit(1); + } + + slots = qemu_opt_get_number(opts, "slots", 0); + if ((sz > ram_size) && !slots) { + fprintf(stderr, "qemu: invalid -m option value: maxmem " + "(%" PRIu64 ") more than initial memory (%" + PRIu64 ") but no hotplug slots where " + "specified\n", sz, ram_size); + exit(1); + } + + if ((sz <= ram_size) && slots) { + fprintf(stderr, "qemu: invalid -m option value: %" + PRIu64 " hotplug slots where specified but " + "maxmem (%" PRIu64 ") <= initial memory (%" + PRIu64 ")\n", slots, sz, ram_size); + exit(1); + } + } else if ((!maxmem_str && slots_str) || + (maxmem_str && !slots_str)) { + fprintf(stderr, "qemu: invalid -m option value: missing " + "'%s' option\n", slots_str ? "maxmem" : "slots"); + exit(1); + } break; } #ifdef CONFIG_TPM -- 1.7.9.5