From patchwork Wed Nov 27 00:27:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 294445 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0B2152C009A for ; Wed, 27 Nov 2013 11:28:29 +1100 (EST) Received: from localhost ([::1]:33289 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlSzS-0001hL-G5 for incoming@patchwork.ozlabs.org; Tue, 26 Nov 2013 19:28:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37041) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlSz1-0001ea-AO for qemu-devel@nongnu.org; Tue, 26 Nov 2013 19:28:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VlSyv-0007JY-BZ for qemu-devel@nongnu.org; Tue, 26 Nov 2013 19:27:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43113) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlSyv-0007JS-2q for qemu-devel@nongnu.org; Tue, 26 Nov 2013 19:27:53 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAR0RjGA031572 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 26 Nov 2013 19:27:45 -0500 Received: from thinkpad.redhat.com (vpn-227-207.phx2.redhat.com [10.3.227.207]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rAR0RaxF011886; Tue, 26 Nov 2013 19:27:41 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Wed, 27 Nov 2013 01:27:36 +0100 Message-Id: <1385512056-24556-2-git-send-email-imammedo@redhat.com> In-Reply-To: <1385512056-24556-1-git-send-email-imammedo@redhat.com> References: <87pppn6wwu.fsf@blackfin.pond.sub.org> <1385512056-24556-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, stefanha@redhat.com, mst@redhat.com, hutao@cn.fujitsu.com, stefanb@linux.vnet.ibm.com, mjt@tls.msk.ru, mdroth@linux.vnet.ibm.com, armbru@redhat.com, vasilis.liaskovitis@profitbricks.com, quintela@redhat.com, kraxel@redhat.com, aliguori@amazon.com, pbonzini@redhat.com, marcel.a@redhat.com, lcapitulino@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH 05/28] vl.c: extend -m option to support options for memory hotplug 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 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 d923995..0eb1587 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 44cc4ed..1611ea0 100644 --- a/vl.c +++ b/vl.c @@ -539,6 +539,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 */ } }, }; @@ -3197,6 +3205,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); @@ -3226,6 +3235,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