Patchwork [v2,1/2] vl: Round argument of -m up to multiple of 8KiB

login
register
mail settings
Submitter Markus Armbruster
Date Aug. 15, 2012, 9:31 a.m.
Message ID <1345023103-11717-2-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/177595/
State New
Headers show

Comments

Markus Armbruster - Aug. 15, 2012, 9:31 a.m.
Partial pages make little sense and don't work.  Ensure the RAM size
is a multiple of any possible target's page size.

Fixes

    $ qemu-system-x86_64 -nodefaults -S -vnc :0 -m 0.8
    qemu-system-x86_64: /work/armbru/qemu/exec.c:2255: register_subpage: Assertion `existing->mr->subpage || existing->mr == &io_mem_unassigned' failed.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 vl.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Patch

diff --git a/vl.c b/vl.c
index d01256a..dd6b861 100644
--- a/vl.c
+++ b/vl.c
@@ -2708,12 +2708,11 @@  int main(int argc, char **argv, char **envp)
                     fprintf(stderr, "qemu: invalid ram size: %s\n", optarg);
                     exit(1);
                 }
-
-                if (value != (uint64_t)(ram_addr_t)value) {
+                ram_size = QEMU_ALIGN_UP((uint64_t)value, 8192);
+                if (ram_size < value) {
                     fprintf(stderr, "qemu: ram size too large\n");
                     exit(1);
                 }
-                ram_size = value;
                 break;
             }
             case QEMU_OPTION_mempath: