Patchwork [V2,3/3] vl.c: Check the asked ram_size later.

login
register
mail settings
Submitter Anthony PERARD
Date July 20, 2011, 6:17 p.m.
Message ID <1311185864-32745-4-git-send-email-anthony.perard@citrix.com>
Download mbox | patch
Permalink /patch/105988/
State New
Headers show

Comments

Anthony PERARD - July 20, 2011, 6:17 p.m.
As a Xen guest can have more than 2GB of RAM on a 32bit host, we move
the conditions after than we now if we run one Xen or not.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 vl.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
Alexander Graf - July 27, 2011, 12:53 p.m.
On 07/20/2011 08:17 PM, Anthony PERARD wrote:
> As a Xen guest can have more than 2GB of RAM on a 32bit host, we move
> the conditions after than we now if we run one Xen or not.
>
> Signed-off-by: Anthony PERARD<anthony.perard@citrix.com>
> ---
>   vl.c |   14 ++++++++------
>   1 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/vl.c b/vl.c
> index fcd7395..c2efedf 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2433,11 +2433,6 @@ int main(int argc, char **argv, char **envp)
>                       exit(1);
>                   }
>
> -                /* On 32-bit hosts, QEMU is limited by virtual address space */
> -                if (value>  (2047<<  20)&&  HOST_LONG_BITS == 32) {
> -                    fprintf(stderr, "qemu: at most 2047 MB RAM can be simulated\n");
> -                    exit(1);
> -                }
>                   if (value != (uint64_t)(ram_addr_t)value) {
>                       fprintf(stderr, "qemu: ram size too large\n");
>                       exit(1);
> @@ -3091,8 +3086,15 @@ int main(int argc, char **argv, char **envp)
>           exit(1);
>
>       /* init the memory */
> -    if (ram_size == 0)
> +    if (ram_size == 0) {
>           ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
> +    } else if (!xen_enabled()) {

I don't see why those are mutually exclusive.

> +        /* On 32-bit hosts, QEMU is limited by virtual address space */
> +        if (ram_size>  (2047<<  20)&&  HOST_LONG_BITS == 32) {
> +            fprintf(stderr, "qemu: at most 2047 MB RAM can be simulated\n");
> +            exit(1);
> +        }
> +    }
>
>       /* init the dynamic translator */
>       cpu_exec_init_all(tb_size * 1024 * 1024);

Alex

Patch

diff --git a/vl.c b/vl.c
index fcd7395..c2efedf 100644
--- a/vl.c
+++ b/vl.c
@@ -2433,11 +2433,6 @@  int main(int argc, char **argv, char **envp)
                     exit(1);
                 }
 
-                /* On 32-bit hosts, QEMU is limited by virtual address space */
-                if (value > (2047 << 20) && HOST_LONG_BITS == 32) {
-                    fprintf(stderr, "qemu: at most 2047 MB RAM can be simulated\n");
-                    exit(1);
-                }
                 if (value != (uint64_t)(ram_addr_t)value) {
                     fprintf(stderr, "qemu: ram size too large\n");
                     exit(1);
@@ -3091,8 +3086,15 @@  int main(int argc, char **argv, char **envp)
         exit(1);
 
     /* init the memory */
-    if (ram_size == 0)
+    if (ram_size == 0) {
         ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
+    } else if (!xen_enabled()) {
+        /* On 32-bit hosts, QEMU is limited by virtual address space */
+        if (ram_size > (2047 << 20) && HOST_LONG_BITS == 32) {
+            fprintf(stderr, "qemu: at most 2047 MB RAM can be simulated\n");
+            exit(1);
+        }
+    }
 
     /* init the dynamic translator */
     cpu_exec_init_all(tb_size * 1024 * 1024);