From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JkNn3-0005x5-46 for qemu-devel@nongnu.org; Fri, 11 Apr 2008 14:15:57 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JkNmv-0005sJ-S0 for qemu-devel@nongnu.org; Fri, 11 Apr 2008 14:15:52 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JkNmv-0005sG-Ls for qemu-devel@nongnu.org; Fri, 11 Apr 2008 14:15:49 -0400 Received: from bzq-179-150-194.static.bezeqint.net ([212.179.150.194] helo=il.qumranet.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JkNmu-0004TU-Un for qemu-devel@nongnu.org; Fri, 11 Apr 2008 14:15:49 -0400 From: Amit Shah Date: Fri, 11 Apr 2008 20:43:50 +0300 Message-Id: <1207935830-27938-1-git-send-email-amit.shah@qumranet.com> Subject: [Qemu-devel] [PATCH] qemu: Add support for suffixes to the -m parameter Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kvm-devel@lists.sourceforge.net, Amit Shah The -m parameter doesn't take suffixes like G or M currently and it doesn't complain if such a suffix is given. Add support for the G and M suffixes and update the usage instructions appropriately. Signed-off-by: Amit Shah --- qemu/vl.c | 25 +++++++++++++++++++++++-- 1 files changed, 23 insertions(+), 2 deletions(-) diff --git a/qemu/vl.c b/qemu/vl.c index 49d9af2..1c6f603 100644 --- a/qemu/vl.c +++ b/qemu/vl.c @@ -8085,7 +8085,9 @@ static void help(int exitcode) #ifdef TARGET_I386 "-no-fd-bootchk disable boot signature checking for floppy disks\n" #endif - "-m megs set virtual RAM size to megs MB [default=%d]\n" + "-m size set virtual RAM size to size megs [default=%d MB].\n" + " Optional suffixes 'M' (megabyte) and 'G' (gigabyte)" + " are supported\n" "-smp n set the number of CPUs to 'n' [default=1]\n" "-nographic disable graphical output and redirect serial I/Os to console\n" "-portrait rotate graphical output 90 deg left (only PXA LCD)\n" @@ -9140,7 +9142,26 @@ int main(int argc, char **argv) help(0); break; case QEMU_OPTION_m: - ram_size = (int64_t)atoi(optarg) * 1024 * 1024; + errno = 0; + ram_size = (uint64_t) strtoul(optarg, (char **)&optarg, 0); + if (errno) + help(1); + switch (*optarg) { + case 'G': + case 'g': + ram_size *= 1024; + /* fall through */ + case 'M': + case 'm': + case '\0': + ram_size *= 1024 * 1024; + optarg++; + break; + default: + help(1); + break; + } + if (ram_size <= 0) help(1); if (ram_size > PHYS_RAM_MAX_SIZE) { -- 1.4.4.2