diff mbox series

[03/22] machine: move UP defaults to class_base_init

Message ID 20201021205716.2359430-4-pbonzini@redhat.com
State Accepted
Commit 2c920e4577b29702c0c01b0d491903c159df894a
Headers show
Series cleanup qemu_init and make sense of command line processing | expand

Commit Message

Paolo Bonzini Oct. 21, 2020, 8:56 p.m. UTC
Clean up vl.c, default min/max/default_cpus to uniprocessor
directly in the QOM class initialization code.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/core/machine.c | 6 +++++-
 softmmu/vl.c      | 5 -----
 2 files changed, 5 insertions(+), 6 deletions(-)

Comments

Thomas Huth Oct. 22, 2020, 5:11 a.m. UTC | #1
On 21/10/2020 22.56, Paolo Bonzini wrote:
> Clean up vl.c, default min/max/default_cpus to uniprocessor

> directly in the QOM class initialization code.

> 

> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

> ---

>  hw/core/machine.c | 6 +++++-

>  softmmu/vl.c      | 5 -----

>  2 files changed, 5 insertions(+), 6 deletions(-)

> 

> diff --git a/hw/core/machine.c b/hw/core/machine.c

> index 80a918895a..d3a8450b1f 100644

> --- a/hw/core/machine.c

> +++ b/hw/core/machine.c

> @@ -854,8 +854,12 @@ static void machine_class_init(ObjectClass *oc, void *data)

>  

>  static void machine_class_base_init(ObjectClass *oc, void *data)

>  {

> +    MachineClass *mc = MACHINE_CLASS(oc);

> +    mc->max_cpus = mc->max_cpus ?: 1;

> +    mc->min_cpus = mc->min_cpus ?: 1;

> +    mc->default_cpus = mc->default_cpus ?: 1;

> +

>      if (!object_class_is_abstract(oc)) {

> -        MachineClass *mc = MACHINE_CLASS(oc);

>          const char *cname = object_class_get_name(oc);

>          assert(g_str_has_suffix(cname, TYPE_MACHINE_SUFFIX));

>          mc->name = g_strndup(cname,

> diff --git a/softmmu/vl.c b/softmmu/vl.c

> index 42314e6ff9..75bc686397 100644

> --- a/softmmu/vl.c

> +++ b/softmmu/vl.c

> @@ -3966,11 +3966,6 @@ void qemu_init(int argc, char **argv, char **envp)

>          exit(0);

>      }

>  

> -    /* machine_class: default to UP */

> -    machine_class->max_cpus = machine_class->max_cpus ?: 1;

> -    machine_class->min_cpus = machine_class->min_cpus ?: 1;

> -    machine_class->default_cpus = machine_class->default_cpus ?: 1;

> -

>      /* default to machine_class->default_cpus */

>      current_machine->smp.cpus = machine_class->default_cpus;

>      current_machine->smp.max_cpus = machine_class->default_cpus;

> 


Reviewed-by: Thomas Huth <thuth@redhat.com>
diff mbox series

Patch

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 80a918895a..d3a8450b1f 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -854,8 +854,12 @@  static void machine_class_init(ObjectClass *oc, void *data)
 
 static void machine_class_base_init(ObjectClass *oc, void *data)
 {
+    MachineClass *mc = MACHINE_CLASS(oc);
+    mc->max_cpus = mc->max_cpus ?: 1;
+    mc->min_cpus = mc->min_cpus ?: 1;
+    mc->default_cpus = mc->default_cpus ?: 1;
+
     if (!object_class_is_abstract(oc)) {
-        MachineClass *mc = MACHINE_CLASS(oc);
         const char *cname = object_class_get_name(oc);
         assert(g_str_has_suffix(cname, TYPE_MACHINE_SUFFIX));
         mc->name = g_strndup(cname,
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 42314e6ff9..75bc686397 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -3966,11 +3966,6 @@  void qemu_init(int argc, char **argv, char **envp)
         exit(0);
     }
 
-    /* machine_class: default to UP */
-    machine_class->max_cpus = machine_class->max_cpus ?: 1;
-    machine_class->min_cpus = machine_class->min_cpus ?: 1;
-    machine_class->default_cpus = machine_class->default_cpus ?: 1;
-
     /* default to machine_class->default_cpus */
     current_machine->smp.cpus = machine_class->default_cpus;
     current_machine->smp.max_cpus = machine_class->default_cpus;