qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 04/27] vl: convert -m to qemu_opts_parse()


From: Li Guang
Subject: Re: [Qemu-devel] [PATCH 04/27] vl: convert -m to qemu_opts_parse()
Date: Thu, 21 Nov 2013 14:01:43 +0800
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.16) Gecko/20120421 Iceape/2.0.11

Igor Mammedov wrote:
Along with conversion extend -m option to support following parameters
...
+                if (!opts) {
                      exit(1);
                  }
-                sz = QEMU_ALIGN_UP((uint64_t)value, 8192);
+
+                /* fixup legacy sugffix-less format */
s/sugffix/suffix

+                end = qemu_opt_get(opts, "mem");
+                if (g_ascii_isdigit(end[strlen(end) - 1])) {
+                    s = g_strconcat(end, "M", NULL);
+                    qemu_opt_set(opts, "mem", s);
+                    g_free(s);
+                }
+
+                sz = QEMU_ALIGN_UP(qemu_opt_get_size(opts, "mem", ram_size),
+                                   8192);
+                /* compatibility behaviour for case "-m 0" */
+                if (sz == 0) {
+                    sz = DEFAULT_RAM_SIZE * 1024 * 1024;
+                }
+
                  ram_size = sz;
                  if (ram_size != sz) {
                      fprintf(stderr, "qemu: ram size too large\n");
                      exit(1);
                  }
+                /* store aligned value for future use */
+                qemu_opt_set_number(opts, "mem", ram_size);
+
+                sz = qemu_opt_get_size(opts, "maxmem", ram_size);
+                if (sz<  ram_size) {
+                    qemu_opt_set_number(opts, "maxmem", ram_size);
+                }
                  break;
              }
  #ifdef CONFIG_TPM
@@ -4029,11 +4083,6 @@ int main(int argc, char **argv, char **envp)
          exit(1);
      }

-    /* init the memory */
-    if (ram_size == 0) {
-        ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
-    }
-
      if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, 0)
          != 0) {
          exit(0);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]