qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qemu: Add support for suffixes to the -m parameter
@ 2008-04-11 17:43 Amit Shah
  2008-04-11 18:37 ` Aurelien Jarno
  0 siblings, 1 reply; 2+ messages in thread
From: Amit Shah @ 2008-04-11 17:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: kvm-devel, 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 <amit.shah@qumranet.com>
---
 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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu: Add support for suffixes to the -m parameter
  2008-04-11 17:43 [Qemu-devel] [PATCH] qemu: Add support for suffixes to the -m parameter Amit Shah
@ 2008-04-11 18:37 ` Aurelien Jarno
  0 siblings, 0 replies; 2+ messages in thread
From: Aurelien Jarno @ 2008-04-11 18:37 UTC (permalink / raw)
  To: qemu-devel

Amit Shah a écrit :
> 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.
> 

Such a patch as already been submitted by Anthony Liguori in the "[PATCH
1/5] Use correct types to enable > 2G support	(v3)" patch.

I am currently testing it, and trying to fix the > 3.5G support. I plan
to commit it as soon this problem is fixed.

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-04-11 18:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-11 17:43 [Qemu-devel] [PATCH] qemu: Add support for suffixes to the -m parameter Amit Shah
2008-04-11 18:37 ` Aurelien Jarno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).