diff mbox

[02/16] vl: set default ram_size during variable initialization

Message ID 1374596592-7027-3-git-send-email-imammedo@redhat.com
State New
Headers show

Commit Message

Igor Mammedov July 23, 2013, 4:22 p.m. UTC
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 vl.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

Comments

Andreas Färber Aug. 2, 2013, 8:33 p.m. UTC | #1
Am 23.07.2013 18:22, schrieb Igor Mammedov:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  vl.c |    7 +------
>  1 files changed, 1 insertions(+), 6 deletions(-)
> 
> diff --git a/vl.c b/vl.c
> index 8190504..bf0c658 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2947,7 +2947,7 @@ int main(int argc, char **argv, char **envp)
>      module_call_init(MODULE_INIT_MACHINE);
>      machine = find_default_machine();
>      cpu_model = NULL;
> -    ram_size = 0;
> +    ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
>      snapshot = 0;
>      cyls = heads = secs = 0;
>      translation = BIOS_ATA_TRANSLATION_AUTO;
> @@ -4064,11 +4064,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);

Commit message doesn't give any explanation why?

What happens with -m 0? My guess is the old code translates that to the
default size, where by intializing the default earlier it would stay.

Andreas
Igor Mammedov Sept. 9, 2013, 2:06 p.m. UTC | #2
On Fri, 02 Aug 2013 22:33:24 +0200
Andreas Färber <afaerber@suse.de> wrote:

> Am 23.07.2013 18:22, schrieb Igor Mammedov:
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> >  vl.c |    7 +------
> >  1 files changed, 1 insertions(+), 6 deletions(-)
> > 
> > diff --git a/vl.c b/vl.c
> > index 8190504..bf0c658 100644
> > --- a/vl.c
> > +++ b/vl.c
> > @@ -2947,7 +2947,7 @@ int main(int argc, char **argv, char **envp)
> >      module_call_init(MODULE_INIT_MACHINE);
> >      machine = find_default_machine();
> >      cpu_model = NULL;
> > -    ram_size = 0;
> > +    ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
> >      snapshot = 0;
> >      cyls = heads = secs = 0;
> >      translation = BIOS_ATA_TRANSLATION_AUTO;
> > @@ -4064,11 +4064,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);
> 
> Commit message doesn't give any explanation why?
it was intended as cleanup

> 
> What happens with -m 0? My guess is the old code translates that to the
> default size, where by intializing the default earlier it would stay.
patch is broken in this aspect. It aborts on start up with -m 0

The question is if -m 0 is correct value, perhaps QEMU should exit with
error message in this case, instead of silent fallback to default?

> 
> Andreas
>
Paolo Bonzini Sept. 9, 2013, 2:31 p.m. UTC | #3
Il 09/09/2013 16:06, Igor Mammedov ha scritto:
> On Fri, 02 Aug 2013 22:33:24 +0200
> Andreas Färber <afaerber@suse.de> wrote:
> 
>> Am 23.07.2013 18:22, schrieb Igor Mammedov:
>>> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
>>> ---
>>>  vl.c |    7 +------
>>>  1 files changed, 1 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/vl.c b/vl.c
>>> index 8190504..bf0c658 100644
>>> --- a/vl.c
>>> +++ b/vl.c
>>> @@ -2947,7 +2947,7 @@ int main(int argc, char **argv, char **envp)
>>>      module_call_init(MODULE_INIT_MACHINE);
>>>      machine = find_default_machine();
>>>      cpu_model = NULL;
>>> -    ram_size = 0;
>>> +    ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
>>>      snapshot = 0;
>>>      cyls = heads = secs = 0;
>>>      translation = BIOS_ATA_TRANSLATION_AUTO;
>>> @@ -4064,11 +4064,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);
>>
>> Commit message doesn't give any explanation why?
> it was intended as cleanup
> 
>>
>> What happens with -m 0? My guess is the old code translates that to the
>> default size, where by intializing the default earlier it would stay.
> patch is broken in this aspect. It aborts on start up with -m 0
> 
> The question is if -m 0 is correct value, perhaps QEMU should exit with
> error message in this case, instead of silent fallback to default?

I guess we have to keep it for backwards compatibility.

Paolo
Igor Mammedov Sept. 9, 2013, 3:26 p.m. UTC | #4
On Mon, 09 Sep 2013 16:31:03 +0200
Paolo Bonzini <pbonzini@redhat.com> wrote:

> Il 09/09/2013 16:06, Igor Mammedov ha scritto:
> > On Fri, 02 Aug 2013 22:33:24 +0200
> > Andreas Färber <afaerber@suse.de> wrote:
> > 
> >> Am 23.07.2013 18:22, schrieb Igor Mammedov:
> >>> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> >>> ---
> >>>  vl.c |    7 +------
> >>>  1 files changed, 1 insertions(+), 6 deletions(-)
> >>>
> >>> diff --git a/vl.c b/vl.c
> >>> index 8190504..bf0c658 100644
> >>> --- a/vl.c
> >>> +++ b/vl.c
> >>> @@ -2947,7 +2947,7 @@ int main(int argc, char **argv, char **envp)
> >>>      module_call_init(MODULE_INIT_MACHINE);
> >>>      machine = find_default_machine();
> >>>      cpu_model = NULL;
> >>> -    ram_size = 0;
> >>> +    ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
> >>>      snapshot = 0;
> >>>      cyls = heads = secs = 0;
> >>>      translation = BIOS_ATA_TRANSLATION_AUTO;
> >>> @@ -4064,11 +4064,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);
> >>
> >> Commit message doesn't give any explanation why?
> > it was intended as cleanup
> > 
> >>
> >> What happens with -m 0? My guess is the old code translates that to the
> >> default size, where by intializing the default earlier it would stay.
> > patch is broken in this aspect. It aborts on start up with -m 0
> > 
> > The question is if -m 0 is correct value, perhaps QEMU should exit with
> > error message in this case, instead of silent fallback to default?
> 
> I guess we have to keep it for backwards compatibility.
I could swap this patch with 3/16 and add -m 0 compat logic there. Then
it would be ok to move default to initialization time + cleanup.

> 
> Paolo
> 
>
diff mbox

Patch

diff --git a/vl.c b/vl.c
index 8190504..bf0c658 100644
--- a/vl.c
+++ b/vl.c
@@ -2947,7 +2947,7 @@  int main(int argc, char **argv, char **envp)
     module_call_init(MODULE_INIT_MACHINE);
     machine = find_default_machine();
     cpu_model = NULL;
-    ram_size = 0;
+    ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
     snapshot = 0;
     cyls = heads = secs = 0;
     translation = BIOS_ATA_TRANSLATION_AUTO;
@@ -4064,11 +4064,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);