+ 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);