Skip to contentSkip to conversation

Make MachineClass::is_default boolean, refuse multiple default machines

PATCH Applied Philippe Mathieu-Daudé 9 participants 21 messages Feb 7, 2020 – Feb 10, 2020 RISC-V

lore
Share & tools
lore
#0 lore raw

v4 cover Make MachineClass::is_default boolean, refuse multiple default machines

Cleanup after reviewing "ppc: function to setup latest class options":
https://www.mail-archive.com/[email protected]/msg677709.html

Since v3:
- addressed Laurent & Michael comments

Philippe Mathieu-Daudé (3):
hw: Do not initialize MachineClass::is_default to 0
hw: Make MachineClass::is_default a boolean type
vl: Abort if multiple machines are registered as default

 include/hw/boards.h                      |  4 +++-
 hw/alpha/dp264.c                         |  2 +-
 hw/cris/axis_dev88.c                     |  2 +-
 hw/hppa/machine.c                        |  2 +-
 hw/i386/pc_piix.c                        | 10 +++++-----
 hw/lm32/lm32_boards.c                    |  3 +--
 hw/lm32/milkymist.c                      |  1 -
 hw/m68k/mcf5208.c                        |  2 +-
 hw/m68k/q800.c                           |  1 -
 hw/microblaze/petalogix_ml605_mmu.c      |  1 -
 hw/microblaze/petalogix_s3adsp1800_mmu.c |  2 +-
 hw/mips/mips_malta.c                     |  2 +-
 hw/moxie/moxiesim.c                      |  2 +-
 hw/nios2/10m50_devboard.c                |  2 +-
 hw/openrisc/openrisc_sim.c               |  2 +-
 hw/ppc/mac_oldworld.c                    |  2 +-
 hw/ppc/spapr.c                           |  2 +-
 hw/riscv/spike.c                         |  2 +-
 hw/s390x/s390-virtio-ccw.c               |  2 +-
 hw/sh4/shix.c                            |  2 +-
 hw/sparc/sun4m.c                         |  2 +-
 hw/sparc64/sun4u.c                       |  2 +-
 hw/tricore/tricore_testboard.c           |  1 -
 hw/unicore32/puv3.c                      |  2 +-
 vl.c                                     |  6 ++++--
 25 files changed, 30 insertions(+), 31 deletions(-)
Signature · 1 line
2.21.1
#1 lore raw

PATCH v4 1/3 hw: Do not initialize MachineClass::is_default to 0

The MachineClass is already zeroed on creation.

Note: The code setting is_default=0 in hw/i386/pc_piix.c is
different (related to compat options). When adding a new versioned machine, we want it to be the new default, so we have to mark the previous one as not default.

---
v3: new patch

---
 hw/lm32/lm32_boards.c               | 1 -
 hw/lm32/milkymist.c                 | 1 -
 hw/m68k/q800.c                      | 1 -
 hw/microblaze/petalogix_ml605_mmu.c | 1 -
 hw/tricore/tricore_testboard.c      | 1 -
 5 files changed, 5 deletions(-)
hw/lm32/lm32_boards.c +0 -1
index d1894adab8..156b050abc 100644
@@ -302,7 +302,6 @@ static void lm32_uclinux_class_init(ObjectClass *oc, void *data)
 
     mc->desc = "lm32 platform for uClinux and u-boot by Theobroma Systems";
     mc->init = lm32_uclinux_init;
-    mc->is_default = 0;
     mc->default_cpu_type = LM32_CPU_TYPE_NAME("lm32-full");
 }
 
hw/lm32/milkymist.c +0 -1
index 6d46134232..9fa5fd7050 100644
@@ -214,7 +214,6 @@ static void milkymist_machine_init(MachineClass *mc)
 {
     mc->desc = "Milkymist One";
     mc->init = milkymist_init;
-    mc->is_default = 0;
     mc->default_cpu_type = LM32_CPU_TYPE_NAME("lm32-full");
 }
 
hw/m68k/q800.c +0 -1
index 1e32363688..788b5d663f 100644
@@ -441,7 +441,6 @@ static void q800_machine_class_init(ObjectClass *oc, void *data)
     mc->init = q800_init;
     mc->default_cpu_type = M68K_CPU_TYPE_NAME("m68040");
     mc->max_cpus = 1;
-    mc->is_default = 0;
     mc->block_default_type = IF_SCSI;
 }
 
hw/microblaze/petalogix_ml605_mmu.c +0 -1
index 09486bc8bf..0a2640c40b 100644
@@ -216,7 +216,6 @@ static void petalogix_ml605_machine_init(MachineClass *mc)
 {
     mc->desc = "PetaLogix linux refdesign for xilinx ml605 little endian";
     mc->init = petalogix_ml605_init;
-    mc->is_default = 0;
 }
 
 DEFINE_MACHINE("petalogix-ml605", petalogix_ml605_machine_init)
hw/tricore/tricore_testboard.c +0 -1
index 20c9ccb3ce..8ec2b5bddd 100644
@@ -105,7 +105,6 @@ static void ttb_machine_init(MachineClass *mc)
 {
     mc->desc = "a minimal TriCore board";
     mc->init = tricoreboard_init;
-    mc->is_default = 0;
     mc->default_cpu_type = TRICORE_CPU_TYPE_NAME("tc1796");
 }
 
Signature · 1 line
2.21.1
Reviewed-by on v4 1/3
#2 lore raw

Re: [PATCH v4 1/3] hw: Do not initialize MachineClass::is_default to 0

Le 07/02/2020 à 17:19, Philippe Mathieu-Daudé a écrit :

Quoted 72 lines

The MachineClass is already zeroed on creation.

Note: The code setting is_default=0 in hw/i386/pc_piix.c is
different (related to compat options). When adding a new versioned machine, we want it to be the new default, so we have to mark the previous one as not default.

---
v3: new patch

---
 hw/lm32/lm32_boards.c               | 1 -
 hw/lm32/milkymist.c                 | 1 -
 hw/m68k/q800.c                      | 1 -
 hw/microblaze/petalogix_ml605_mmu.c | 1 -
 hw/tricore/tricore_testboard.c      | 1 -
 5 files changed, 5 deletions(-)
hw/lm32/lm32_boards.c +0 -1
index d1894adab8..156b050abc 100644
@@ -302,7 +302,6 @@ static void lm32_uclinux_class_init(ObjectClass *oc, void *data)
 
     mc->desc = "lm32 platform for uClinux and u-boot by Theobroma Systems";
     mc->init = lm32_uclinux_init;
-    mc->is_default = 0;
     mc->default_cpu_type = LM32_CPU_TYPE_NAME("lm32-full");
 }
 
hw/lm32/milkymist.c +0 -1
index 6d46134232..9fa5fd7050 100644
@@ -214,7 +214,6 @@ static void milkymist_machine_init(MachineClass *mc)
 {
     mc->desc = "Milkymist One";
     mc->init = milkymist_init;
-    mc->is_default = 0;
     mc->default_cpu_type = LM32_CPU_TYPE_NAME("lm32-full");
 }
 
hw/m68k/q800.c +0 -1
index 1e32363688..788b5d663f 100644
@@ -441,7 +441,6 @@ static void q800_machine_class_init(ObjectClass *oc, void *data)
     mc->init = q800_init;
     mc->default_cpu_type = M68K_CPU_TYPE_NAME("m68040");
     mc->max_cpus = 1;
-    mc->is_default = 0;
     mc->block_default_type = IF_SCSI;
 }
 
hw/microblaze/petalogix_ml605_mmu.c +0 -1
index 09486bc8bf..0a2640c40b 100644
@@ -216,7 +216,6 @@ static void petalogix_ml605_machine_init(MachineClass *mc)
 {
     mc->desc = "PetaLogix linux refdesign for xilinx ml605 little endian";
     mc->init = petalogix_ml605_init;
-    mc->is_default = 0;
 }
 
 DEFINE_MACHINE("petalogix-ml605", petalogix_ml605_machine_init)
hw/tricore/tricore_testboard.c +0 -0
index 20c9ccb3ce..8ec2b5bddd 100644

hw/tricore/tricore_testboard.c static void ttb_machine_init(MachineClass *mc) · line 110

Quoted 7 lines
hw/tricore/tricore_testboard.c +0 -1
@@ -105,7 +105,6 @@ static void ttb_machine_init(MachineClass *mc)
 {
     mc->desc = "a minimal TriCore board";
     mc->init = tricoreboard_init;
-    mc->is_default = 0;
     mc->default_cpu_type = TRICORE_CPU_TYPE_NAME("tc1796");
 }
 
Reviewed-by on v4 1/3
#3 lore raw

Re: [PATCH v4 1/3] hw: Do not initialize MachineClass::is_default to 0

In reply to Philippe Mathieu-Daudé
Quoted 8 lines · Philippe Mathieu-Daudé

The MachineClass is already zeroed on creation.

Note: The code setting is_default=0 in hw/i386/pc_piix.c is
different (related to compat options). When adding a new versioned machine, we want it to be the new default, so we have to mark the previous one as not default.

Quoted 70 lines

---
v3: new patch

---
 hw/lm32/lm32_boards.c               | 1 -
 hw/lm32/milkymist.c                 | 1 -
 hw/m68k/q800.c                      | 1 -
 hw/microblaze/petalogix_ml605_mmu.c | 1 -
 hw/tricore/tricore_testboard.c      | 1 -
 5 files changed, 5 deletions(-)
hw/lm32/lm32_boards.c +0 -1
index d1894adab8..156b050abc 100644
@@ -302,7 +302,6 @@ static void lm32_uclinux_class_init(ObjectClass *oc, void *data)
 
     mc->desc = "lm32 platform for uClinux and u-boot by Theobroma Systems";
     mc->init = lm32_uclinux_init;
-    mc->is_default = 0;
     mc->default_cpu_type = LM32_CPU_TYPE_NAME("lm32-full");
 }
 
hw/lm32/milkymist.c +0 -1
index 6d46134232..9fa5fd7050 100644
@@ -214,7 +214,6 @@ static void milkymist_machine_init(MachineClass *mc)
 {
     mc->desc = "Milkymist One";
     mc->init = milkymist_init;
-    mc->is_default = 0;
     mc->default_cpu_type = LM32_CPU_TYPE_NAME("lm32-full");
 }
 
hw/m68k/q800.c +0 -1
index 1e32363688..788b5d663f 100644
@@ -441,7 +441,6 @@ static void q800_machine_class_init(ObjectClass *oc, void *data)
     mc->init = q800_init;
     mc->default_cpu_type = M68K_CPU_TYPE_NAME("m68040");
     mc->max_cpus = 1;
-    mc->is_default = 0;
     mc->block_default_type = IF_SCSI;
 }
 
hw/microblaze/petalogix_ml605_mmu.c +0 -1
index 09486bc8bf..0a2640c40b 100644
@@ -216,7 +216,6 @@ static void petalogix_ml605_machine_init(MachineClass *mc)
 {
     mc->desc = "PetaLogix linux refdesign for xilinx ml605 little endian";
     mc->init = petalogix_ml605_init;
-    mc->is_default = 0;
 }
 
 DEFINE_MACHINE("petalogix-ml605", petalogix_ml605_machine_init)
hw/tricore/tricore_testboard.c +0 -1
index 20c9ccb3ce..8ec2b5bddd 100644
@@ -105,7 +105,6 @@ static void ttb_machine_init(MachineClass *mc)
 {
     mc->desc = "a minimal TriCore board";
     mc->init = tricoreboard_init;
-    mc->is_default = 0;
     mc->default_cpu_type = TRICORE_CPU_TYPE_NAME("tc1796");
 }
 
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#4 lore raw

Tricore default machine (was: [PATCH v4 1/3] hw: Do not initialize MachineClass::is_default to 0)

In reply to Philippe Mathieu-Daudé
Quoted 17 lines · Philippe Mathieu-Daudé

The MachineClass is already zeroed on creation.

Note: The code setting is_default=0 in hw/i386/pc_piix.c is
different (related to compat options). When adding a new versioned machine, we want it to be the new default, so we have to mark the previous one as not default.

---
v3: new patch

---
 hw/lm32/lm32_boards.c               | 1 -
 hw/lm32/milkymist.c                 | 1 -
 hw/m68k/q800.c                      | 1 -
 hw/microblaze/petalogix_ml605_mmu.c | 1 -
 hw/tricore/tricore_testboard.c      | 1 -
 5 files changed, 5 deletions(-)

[...]

hw/tricore/tricore_testboard.c static void ttb_machine_init(MachineClass *mc) · line 109

Quoted 11 lines
hw/tricore/tricore_testboard.c +0 -1
index 20c9ccb3ce..8ec2b5bddd 100644
@@ -105,7 +105,6 @@ static void ttb_machine_init(MachineClass *mc)
 {
     mc->desc = "a minimal TriCore board";
     mc->init = tricoreboard_init;
-    mc->is_default = 0;
     mc->default_cpu_type = TRICORE_CPU_TYPE_NAME("tc1796");
 }

I wonder whether we should simply make that machine the default for qemu-system-tricore? There is only one machine here, and not having a default machine always causes some headaches in the tests... (see e.g. tests/qemu-iotests/check for example)

Thomas

#5 lore raw

Re: Tricore default machine

Quoted 19 lines · Thomas Huth
Quoted 17 lines · Philippe Mathieu-Daudé

The MachineClass is already zeroed on creation.

Note: The code setting is_default=0 in hw/i386/pc_piix.c is
different (related to compat options). When adding a new versioned machine, we want it to be the new default, so we have to mark the previous one as not default.

---
v3: new patch

---
  hw/lm32/lm32_boards.c               | 1 -
  hw/lm32/milkymist.c                 | 1 -
  hw/m68k/q800.c                      | 1 -
  hw/microblaze/petalogix_ml605_mmu.c | 1 -
  hw/tricore/tricore_testboard.c      | 1 -
  5 files changed, 5 deletions(-)

[...]

Quoted 16 lines

hw/tricore/tricore_testboard.c static void ttb_machine_init(MachineClass *mc) · line 109

Quoted 11 lines
hw/tricore/tricore_testboard.c +0 -1
index 20c9ccb3ce..8ec2b5bddd 100644
@@ -105,7 +105,6 @@ static void ttb_machine_init(MachineClass *mc)
  {
      mc->desc = "a minimal TriCore board";
      mc->init = tricoreboard_init;
-    mc->is_default = 0;
      mc->default_cpu_type = TRICORE_CPU_TYPE_NAME("tc1796");
  }

I wonder whether we should simply make that machine the default for qemu-system-tricore? There is only one machine here, and not having a default machine always causes some headaches in the tests... (see e.g. tests/qemu-iotests/check for example)

Or make it generic? If a architecture has a single machine, use it by default?

#6 lore raw

Re: Tricore default machine

Quoted 38 lines · Philippe Mathieu-Daudé
Quoted 28 lines · Thomas Huth
Quoted 17 lines · Philippe Mathieu-Daudé

The MachineClass is already zeroed on creation.

Note: The code setting is_default=0 in hw/i386/pc_piix.c is different (related to compat options). When adding a new versioned machine, we want it to be the new default, so we have to mark the previous one as not default.

---
v3: new patch
---
  hw/lm32/lm32_boards.c               | 1 -
  hw/lm32/milkymist.c                 | 1 -
  hw/m68k/q800.c                      | 1 -
  hw/microblaze/petalogix_ml605_mmu.c | 1 -
  hw/tricore/tricore_testboard.c      | 1 -

  5 files changed, 5 deletions(-)

[...]

Quoted 9 lines
hw/tricore/tricore_testboard.c +0 -0
index 20c9ccb3ce..8ec2b5bddd 100644
@@ -105,7 +105,6 @@ static void ttb_machine_init(MachineClass *mc)
   {
       mc->desc = "a minimal TriCore board";
       mc->init = tricoreboard_init;
Quoted 8 lines

hw/tricore/tricore_testboard.c static void ttb_machine_init(MachineClass *mc) · line 109

Quoted 3 lines
hw/tricore/tricore_testboard.c +0 -1
-    mc->is_default = 0;
       mc->default_cpu_type = TRICORE_CPU_TYPE_NAME("tc1796");
   }

I wonder whether we should simply make that machine the default for qemu-system-tricore? There is only one machine here, and not having a default machine always causes some headaches in the tests... (see e.g. tests/qemu-iotests/check for example)

Quoted 2 lines

Or make it generic? If a architecture has a single machine, use it by default?

Sounds like a good idea, too ... we've got a couple of targets that have only one machine.

Thomas

#7 lore raw

Re: Tricore default machine

Quoted 37 lines · Thomas Huth
Quoted 36 lines · Philippe Mathieu-Daudé
Quoted 35 lines · Thomas Huth
Quoted 17 lines · Philippe Mathieu-Daudé

The MachineClass is already zeroed on creation.

Note: The code setting is_default=0 in hw/i386/pc_piix.c is
       different (related to compat options). When adding a new versioned machine, we want it to be the new default, so we have to mark the previous one as not default.

---
v3: new patch

---
   hw/lm32/lm32_boards.c               | 1 -
   hw/lm32/milkymist.c                 | 1 -
   hw/m68k/q800.c                      | 1 -
   hw/microblaze/petalogix_ml605_mmu.c | 1 -
   hw/tricore/tricore_testboard.c      | 1 -
   5 files changed, 5 deletions(-)

[...]

hw/tricore/tricore_testboard.c static void ttb_machine_init(MachineClass *mc) · line 109

Quoted 12 lines
hw/tricore/tricore_testboard.c +0 -1
index 20c9ccb3ce..8ec2b5bddd 100644
@@ -105,7 +105,6 @@ static void ttb_machine_init(MachineClass *mc)
   {
       mc->desc = "a minimal TriCore board";
       mc->init = tricoreboard_init;
-    mc->is_default = 0;
       mc->default_cpu_type = TRICORE_CPU_TYPE_NAME("tc1796");
   }

I wonder whether we should simply make that machine the default for qemu-system-tricore? There is only one machine here, and not having a default machine always causes some headaches in the tests... (see e.g. tests/qemu-iotests/check for example)

Quoted 4 lines
Quoted 2 lines

Or make it generic? If a architecture has a single machine, use it by default?

Sounds like a good idea, too ... we've got a couple of targets that have only one machine.

As far as I remember, I did not make it the default machine, since Peter Maydell advised against it. His argument was that defaults are really hard to get rid off since external tools (like libvirt) might rely on the defaults and we don't want to break those. Anyways, no objections from my side.

Cheers,

Bastian

#8 lore raw

Re: Tricore default machine

Quoted 12 lines · Bastian Koppelmann
Quoted 9 lines · Thomas Huth
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Thomas Huth

On 07/02/2020 17.19, Philippe Mathieu-Daudé wrote:
I wonder whether we should simply make that machine the default for qemu-system-tricore? There is only one machine here, and not having a default machine always causes some headaches in the tests... (see e.g. tests/qemu-iotests/check for example)

Or make it generic? If a architecture has a single machine, use it by default?

Quoted 8 lines
Quoted 2 lines

Sounds like a good idea, too ... we've got a couple of targets that have only one machine.

As far as I remember, I did not make it the default machine, since Peter Maydell advised against it. His argument was that defaults are really hard to get rid off since external tools (like libvirt) might rely on the defaults and we don't want to break those. Anyways, no objections from my side.

Yes; we have default machines partly for historical reasons and partly because x86 does, but unless there's a good reason for some architecture why this specific machine should be the default, I don't think we should have a default:
making the user specify what they actually want helps to nudge them into thinking about what they do want, rather than assuming that QEMU will somehow magically be able to run guest images built for any random machine for the architecture.

Anything in tests or whatever that breaks if there's no default machine for the architecture should be improved to handle that (it already needs to handle that case, though: arm does not have a defined default machine).

thanks
-- PMM

#9 lore raw

Re: Tricore default machine

Quoted 23 lines · Peter Maydell
Quoted 12 lines · Bastian Koppelmann
Quoted 9 lines · Thomas Huth
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Thomas Huth

On 07/02/2020 17.19, Philippe Mathieu-Daudé wrote:
I wonder whether we should simply make that machine the default for qemu-system-tricore? There is only one machine here, and not having a default machine always causes some headaches in the tests... (see e.g. tests/qemu-iotests/check for example)

Or make it generic? If a architecture has a single machine, use it by default?

Quoted 8 lines
Quoted 2 lines

Sounds like a good idea, too ... we've got a couple of targets that have only one machine.

As far as I remember, I did not make it the default machine, since Peter Maydell advised against it. His argument was that defaults are really hard to get rid off since external tools (like libvirt) might rely on the defaults and we don't want to break those. Anyways, no objections from my side.

Quoted 8 lines

Yes; we have default machines partly for historical reasons and partly because x86 does, but unless there's a good reason for some architecture why this specific machine should be the default, I don't think we should have a default:
making the user specify what they actually want helps to nudge them into thinking about what they do want, rather than assuming that QEMU will somehow magically be able to run guest images built for any random machine for the architecture.

OK now it makes sense.

Quoted 4 lines

Anything in tests or whatever that breaks if there's no default machine for the architecture should be improved to handle that (it already needs to handle that case, though: arm does not have a defined default machine).

I tend to agree here.

#10 lore raw

PATCH v4 2/3 hw: Make MachineClass::is_default a boolean type

In reply to Philippe Mathieu-Daudé

There's no good reason for it to be type int, change it to bool.

---
v4:
- fixed incorrect changes to max_cpus (Laurent)
- describe field

---
 include/hw/boards.h                      |  4 +++-
 hw/alpha/dp264.c                         |  2 +-
 hw/cris/axis_dev88.c                     |  2 +-
 hw/hppa/machine.c                        |  2 +-
 hw/i386/pc_piix.c                        | 10 +++++-----
 hw/lm32/lm32_boards.c                    |  2 +-
 hw/m68k/mcf5208.c                        |  2 +-
 hw/microblaze/petalogix_s3adsp1800_mmu.c |  2 +-
 hw/mips/mips_malta.c                     |  2 +-
 hw/moxie/moxiesim.c                      |  2 +-
 hw/nios2/10m50_devboard.c                |  2 +-
 hw/openrisc/openrisc_sim.c               |  2 +-
 hw/ppc/mac_oldworld.c                    |  2 +-
 hw/ppc/spapr.c                           |  2 +-
 hw/riscv/spike.c                         |  2 +-
 hw/s390x/s390-virtio-ccw.c               |  2 +-
 hw/sh4/shix.c                            |  2 +-
 hw/sparc/sun4m.c                         |  2 +-
 hw/sparc64/sun4u.c                       |  2 +-
 hw/unicore32/puv3.c                      |  2 +-
 20 files changed, 26 insertions(+), 24 deletions(-)
include/hw/boards.h +3 -1
index fb1b43d5b9..c3523a70e8 100644
@@ -107,6 +107,8 @@ typedef struct {
  * @max_cpus: maximum number of CPUs supported. Default: 1
  * @min_cpus: minimum number of CPUs supported. Default: 1
  * @default_cpus: number of CPUs instantiated if none are specified. Default: 1
+ * @is_default:
+ *    If true QEMU will use this machine by default if no '-M' option is given.
  * @get_hotplug_handler: this function is called during bus-less
  *    device hotplug. If defined it returns pointer to an instance
  *    of HotplugHandler object, which handles hotplug operation
@@ -200,7 +202,7 @@ struct MachineClass {
         no_sdcard:1,
         pci_allow_0_address:1,
         legacy_fw_cfg_order:1;
-    int is_default;
+    bool is_default;
     const char *default_machine_opts;
     const char *default_boot_order;
     const char *default_display;
hw/alpha/dp264.c +1 -1
index a8f9a89cc4..083a198a64 100644
@@ -181,7 +181,7 @@ static void clipper_machine_init(MachineClass *mc)
     mc->init = clipper_init;
     mc->block_default_type = IF_IDE;
     mc->max_cpus = 4;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = ALPHA_CPU_TYPE_NAME("ev67");
 }
 
hw/cris/axis_dev88.c +1 -1
index be7760476a..de7b49188b 100644
@@ -349,7 +349,7 @@ static void axisdev88_machine_init(MachineClass *mc)
 {
     mc->desc = "AXIS devboard 88";
     mc->init = axisdev88_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = CRIS_CPU_TYPE_NAME("crisv32");
 }
 
hw/hppa/machine.c +1 -1
index d8755ec422..83ae87f565 100644
@@ -295,7 +295,7 @@ static void machine_hppa_machine_init(MachineClass *mc)
     mc->block_default_type = IF_SCSI;
     mc->max_cpus = HPPA_MAX_CPUS;
     mc->default_cpus = 1;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_ram_size = 512 * MiB;
     mc->default_boot_order = "cd";
 }
hw/i386/pc_piix.c +5 -5
index fa12203079..9088db8fb6 100644
@@ -423,7 +423,7 @@ static void pc_i440fx_5_0_machine_options(MachineClass *m)
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_i440fx_machine_options(m);
     m->alias = "pc";
-    m->is_default = 1;
+    m->is_default = true;
     pcmc->default_cpu_version = 1;
 }
 
@@ -434,7 +434,7 @@ static void pc_i440fx_4_2_machine_options(MachineClass *m)
 {
     pc_i440fx_5_0_machine_options(m);
     m->alias = NULL;
-    m->is_default = 0;
+    m->is_default = false;
     compat_props_add(m->compat_props, hw_compat_4_2, hw_compat_4_2_len);
     compat_props_add(m->compat_props, pc_compat_4_2, pc_compat_4_2_len);
 }
@@ -446,7 +446,7 @@ static void pc_i440fx_4_1_machine_options(MachineClass *m)
 {
     pc_i440fx_4_2_machine_options(m);
     m->alias = NULL;
-    m->is_default = 0;
+    m->is_default = false;
     compat_props_add(m->compat_props, hw_compat_4_1, hw_compat_4_1_len);
     compat_props_add(m->compat_props, pc_compat_4_1, pc_compat_4_1_len);
 }
@@ -459,7 +459,7 @@ static void pc_i440fx_4_0_machine_options(MachineClass *m)
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_i440fx_4_1_machine_options(m);
     m->alias = NULL;
-    m->is_default = 0;
+    m->is_default = false;
     pcmc->default_cpu_version = CPU_VERSION_LEGACY;
     compat_props_add(m->compat_props, hw_compat_4_0, hw_compat_4_0_len);
     compat_props_add(m->compat_props, pc_compat_4_0, pc_compat_4_0_len);
@@ -473,7 +473,7 @@ static void pc_i440fx_3_1_machine_options(MachineClass *m)
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
 
     pc_i440fx_4_0_machine_options(m);
-    m->is_default = 0;
+    m->is_default = false;
     pcmc->do_not_add_smb_acpi = true;
     m->smbus_no_migration_support = true;
     m->alias = NULL;
hw/lm32/lm32_boards.c +1 -1
index 156b050abc..352f69532e 100644
@@ -286,7 +286,7 @@ static void lm32_evr_class_init(ObjectClass *oc, void *data)
 
     mc->desc = "LatticeMico32 EVR32 eval system";
     mc->init = lm32_evr_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = LM32_CPU_TYPE_NAME("lm32-full");
 }
 
hw/m68k/mcf5208.c +1 -1
index a999c21982..5f8f6e4475 100644
@@ -352,7 +352,7 @@ static void mcf5208evb_machine_init(MachineClass *mc)
 {
     mc->desc = "MCF5208EVB";
     mc->init = mcf5208evb_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = M68K_CPU_TYPE_NAME("m5208");
 }
 
hw/microblaze/petalogix_s3adsp1800_mmu.c +1 -1
index 849bafc186..0bb6cdea8d 100644
@@ -132,7 +132,7 @@ static void petalogix_s3adsp1800_machine_init(MachineClass *mc)
 {
     mc->desc = "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800";
     mc->init = petalogix_s3adsp1800_init;
-    mc->is_default = 1;
+    mc->is_default = true;
 }
 
 DEFINE_MACHINE("petalogix-s3adsp1800", petalogix_s3adsp1800_machine_init)
hw/mips/mips_malta.c +1 -1
index 34b76bb6a1..499eac8d33 100644
@@ -1442,7 +1442,7 @@ static void mips_malta_machine_init(MachineClass *mc)
     mc->init = mips_malta_init;
     mc->block_default_type = IF_IDE;
     mc->max_cpus = 16;
-    mc->is_default = 1;
+    mc->is_default = true;
 #ifdef TARGET_MIPS64
     mc->default_cpu_type = MIPS_CPU_TYPE_NAME("20Kc");
 #else
hw/moxie/moxiesim.c +1 -1
index 1d06e39fcb..51a98287b5 100644
@@ -150,7 +150,7 @@ static void moxiesim_machine_init(MachineClass *mc)
 {
     mc->desc = "Moxie simulator platform";
     mc->init = moxiesim_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = MOXIE_CPU_TYPE_NAME("MoxieLite");
 }
 
hw/nios2/10m50_devboard.c +1 -1
index ad8b2fc670..33dc2bf511 100644
@@ -120,7 +120,7 @@ static void nios2_10m50_ghrd_machine_init(struct MachineClass *mc)
 {
     mc->desc = "Altera 10M50 GHRD Nios II design";
     mc->init = nios2_10m50_ghrd_init;
-    mc->is_default = 1;
+    mc->is_default = true;
 }
 
 DEFINE_MACHINE("10m50-ghrd", nios2_10m50_ghrd_machine_init);
hw/openrisc/openrisc_sim.c +1 -1
index ad5371250f..d08ce61811 100644
@@ -176,7 +176,7 @@ static void openrisc_sim_machine_init(MachineClass *mc)
     mc->desc = "or1k simulation";
     mc->init = openrisc_sim_init;
     mc->max_cpus = 2;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = OPENRISC_CPU_TYPE_NAME("or1200");
 }
 
hw/ppc/mac_oldworld.c +1 -1
index 7318d7e9b4..1630663bc2 100644
@@ -438,7 +438,7 @@ static void heathrow_class_init(ObjectClass *oc, void *data)
     mc->block_default_type = IF_IDE;
     mc->max_cpus = MAX_CPUS;
 #ifndef TARGET_PPC64
-    mc->is_default = 1;
+    mc->is_default = true;
 #endif
     /* TOFIX "cad" when Mac floppy is implemented */
     mc->default_boot_order = "cd";
hw/ppc/spapr.c +1 -1
index c9b2e0a5e0..e3e3208cd8 100644
@@ -4493,7 +4493,7 @@ static const TypeInfo spapr_machine_info = {
         spapr_machine_##suffix##_class_options(mc);                  \
         if (latest) {                                                \
             mc->alias = "pseries";                                   \
-            mc->is_default = 1;                                      \
+            mc->is_default = true;                                   \
         }                                                            \
     }                                                                \
     static const TypeInfo spapr_machine_##suffix##_info = {          \
hw/riscv/spike.c +1 -1
index 8823681783..6f03857660 100644
@@ -448,7 +448,7 @@ static void spike_machine_init(MachineClass *mc)
     mc->desc = "RISC-V Spike Board";
     mc->init = spike_board_init;
     mc->max_cpus = 1;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = SPIKE_V1_10_0_CPU;
 }
 
hw/s390x/s390-virtio-ccw.c +1 -1
index e759eb5f83..c4b291e434 100644
@@ -631,7 +631,7 @@ bool css_migration_enabled(void)
         mc->desc = "VirtIO-ccw based S390 machine v" verstr;                  \
         if (latest) {                                                         \
             mc->alias = "s390-ccw-virtio";                                    \
-            mc->is_default = 1;                                               \
+            mc->is_default = true;                                            \
         }                                                                     \
     }                                                                         \
     static void ccw_machine_##suffix##_instance_init(Object *obj)             \
hw/sh4/shix.c +1 -1
index 2fc2915428..68b14ee5e7 100644
@@ -82,7 +82,7 @@ static void shix_machine_init(MachineClass *mc)
 {
     mc->desc = "shix card";
     mc->init = shix_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = TYPE_SH7750R_CPU;
 }
 
hw/sparc/sun4m.c +1 -1
index 25e96db5ca..d6c9772f95 100644
@@ -1411,7 +1411,7 @@ static void ss5_class_init(ObjectClass *oc, void *data)
     mc->desc = "Sun4m platform, SPARCstation 5";
     mc->init = ss5_init;
     mc->block_default_type = IF_SCSI;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_boot_order = "c";
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
     mc->default_display = "tcx";
hw/sparc64/sun4u.c +1 -1
index b7ac42f7a5..d33e84f831 100644
@@ -816,7 +816,7 @@ static void sun4u_class_init(ObjectClass *oc, void *data)
     mc->init = sun4u_init;
     mc->block_default_type = IF_IDE;
     mc->max_cpus = 1; /* XXX for now */
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_boot_order = "c";
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-UltraSparc-IIi");
     mc->ignore_boot_device_suffixes = true;
hw/unicore32/puv3.c +1 -1
index 7e933de228..7f9c0238fe 100644
@@ -140,7 +140,7 @@ static void puv3_machine_init(MachineClass *mc)
 {
     mc->desc = "PKUnity Version-3 based on UniCore32";
     mc->init = puv3_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = UNICORE32_CPU_TYPE_NAME("UniCore-II");
 }
 
Signature · 1 line
2.21.1
Reviewed-by on v4 2/3
#11 lore raw

Re: [PATCH v4 2/3] hw: Make MachineClass::is_default a boolean type

Quoted 6 lines · Philippe Mathieu-Daudé

There's no good reason for it to be type int, change it to bool.

Quoted 336 lines

---
v4:
- fixed incorrect changes to max_cpus (Laurent)
- describe field

---
 include/hw/boards.h                      |  4 +++-
 hw/alpha/dp264.c                         |  2 +-
 hw/cris/axis_dev88.c                     |  2 +-
 hw/hppa/machine.c                        |  2 +-
 hw/i386/pc_piix.c                        | 10 +++++-----
 hw/lm32/lm32_boards.c                    |  2 +-
 hw/m68k/mcf5208.c                        |  2 +-
 hw/microblaze/petalogix_s3adsp1800_mmu.c |  2 +-
 hw/mips/mips_malta.c                     |  2 +-
 hw/moxie/moxiesim.c                      |  2 +-
 hw/nios2/10m50_devboard.c                |  2 +-
 hw/openrisc/openrisc_sim.c               |  2 +-
 hw/ppc/mac_oldworld.c                    |  2 +-
 hw/ppc/spapr.c                           |  2 +-
 hw/riscv/spike.c                         |  2 +-
 hw/s390x/s390-virtio-ccw.c               |  2 +-
 hw/sh4/shix.c                            |  2 +-
 hw/sparc/sun4m.c                         |  2 +-
 hw/sparc64/sun4u.c                       |  2 +-
 hw/unicore32/puv3.c                      |  2 +-
 20 files changed, 26 insertions(+), 24 deletions(-)
include/hw/boards.h +3 -1
index fb1b43d5b9..c3523a70e8 100644
@@ -107,6 +107,8 @@ typedef struct {
  * @max_cpus: maximum number of CPUs supported. Default: 1
  * @min_cpus: minimum number of CPUs supported. Default: 1
  * @default_cpus: number of CPUs instantiated if none are specified. Default: 1
+ * @is_default:
+ *    If true QEMU will use this machine by default if no '-M' option is given.
  * @get_hotplug_handler: this function is called during bus-less
  *    device hotplug. If defined it returns pointer to an instance
  *    of HotplugHandler object, which handles hotplug operation
@@ -200,7 +202,7 @@ struct MachineClass {
         no_sdcard:1,
         pci_allow_0_address:1,
         legacy_fw_cfg_order:1;
-    int is_default;
+    bool is_default;
     const char *default_machine_opts;
     const char *default_boot_order;
     const char *default_display;
hw/alpha/dp264.c +1 -1
index a8f9a89cc4..083a198a64 100644
@@ -181,7 +181,7 @@ static void clipper_machine_init(MachineClass *mc)
     mc->init = clipper_init;
     mc->block_default_type = IF_IDE;
     mc->max_cpus = 4;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = ALPHA_CPU_TYPE_NAME("ev67");
 }
 
hw/cris/axis_dev88.c +1 -1
index be7760476a..de7b49188b 100644
@@ -349,7 +349,7 @@ static void axisdev88_machine_init(MachineClass *mc)
 {
     mc->desc = "AXIS devboard 88";
     mc->init = axisdev88_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = CRIS_CPU_TYPE_NAME("crisv32");
 }
 
hw/hppa/machine.c +1 -1
index d8755ec422..83ae87f565 100644
@@ -295,7 +295,7 @@ static void machine_hppa_machine_init(MachineClass *mc)
     mc->block_default_type = IF_SCSI;
     mc->max_cpus = HPPA_MAX_CPUS;
     mc->default_cpus = 1;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_ram_size = 512 * MiB;
     mc->default_boot_order = "cd";
 }
hw/i386/pc_piix.c +5 -5
index fa12203079..9088db8fb6 100644
@@ -423,7 +423,7 @@ static void pc_i440fx_5_0_machine_options(MachineClass *m)
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_i440fx_machine_options(m);
     m->alias = "pc";
-    m->is_default = 1;
+    m->is_default = true;
     pcmc->default_cpu_version = 1;
 }
 
@@ -434,7 +434,7 @@ static void pc_i440fx_4_2_machine_options(MachineClass *m)
 {
     pc_i440fx_5_0_machine_options(m);
     m->alias = NULL;
-    m->is_default = 0;
+    m->is_default = false;
     compat_props_add(m->compat_props, hw_compat_4_2, hw_compat_4_2_len);
     compat_props_add(m->compat_props, pc_compat_4_2, pc_compat_4_2_len);
 }
@@ -446,7 +446,7 @@ static void pc_i440fx_4_1_machine_options(MachineClass *m)
 {
     pc_i440fx_4_2_machine_options(m);
     m->alias = NULL;
-    m->is_default = 0;
+    m->is_default = false;
     compat_props_add(m->compat_props, hw_compat_4_1, hw_compat_4_1_len);
     compat_props_add(m->compat_props, pc_compat_4_1, pc_compat_4_1_len);
 }
@@ -459,7 +459,7 @@ static void pc_i440fx_4_0_machine_options(MachineClass *m)
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_i440fx_4_1_machine_options(m);
     m->alias = NULL;
-    m->is_default = 0;
+    m->is_default = false;
     pcmc->default_cpu_version = CPU_VERSION_LEGACY;
     compat_props_add(m->compat_props, hw_compat_4_0, hw_compat_4_0_len);
     compat_props_add(m->compat_props, pc_compat_4_0, pc_compat_4_0_len);
@@ -473,7 +473,7 @@ static void pc_i440fx_3_1_machine_options(MachineClass *m)
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
 
     pc_i440fx_4_0_machine_options(m);
-    m->is_default = 0;
+    m->is_default = false;
     pcmc->do_not_add_smb_acpi = true;
     m->smbus_no_migration_support = true;
     m->alias = NULL;
hw/lm32/lm32_boards.c +1 -1
index 156b050abc..352f69532e 100644
@@ -286,7 +286,7 @@ static void lm32_evr_class_init(ObjectClass *oc, void *data)
 
     mc->desc = "LatticeMico32 EVR32 eval system";
     mc->init = lm32_evr_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = LM32_CPU_TYPE_NAME("lm32-full");
 }
 
hw/m68k/mcf5208.c +1 -1
index a999c21982..5f8f6e4475 100644
@@ -352,7 +352,7 @@ static void mcf5208evb_machine_init(MachineClass *mc)
 {
     mc->desc = "MCF5208EVB";
     mc->init = mcf5208evb_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = M68K_CPU_TYPE_NAME("m5208");
 }
 
hw/microblaze/petalogix_s3adsp1800_mmu.c +1 -1
index 849bafc186..0bb6cdea8d 100644
@@ -132,7 +132,7 @@ static void petalogix_s3adsp1800_machine_init(MachineClass *mc)
 {
     mc->desc = "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800";
     mc->init = petalogix_s3adsp1800_init;
-    mc->is_default = 1;
+    mc->is_default = true;
 }
 
 DEFINE_MACHINE("petalogix-s3adsp1800", petalogix_s3adsp1800_machine_init)
hw/mips/mips_malta.c +1 -1
index 34b76bb6a1..499eac8d33 100644
@@ -1442,7 +1442,7 @@ static void mips_malta_machine_init(MachineClass *mc)
     mc->init = mips_malta_init;
     mc->block_default_type = IF_IDE;
     mc->max_cpus = 16;
-    mc->is_default = 1;
+    mc->is_default = true;
 #ifdef TARGET_MIPS64
     mc->default_cpu_type = MIPS_CPU_TYPE_NAME("20Kc");
 #else
hw/moxie/moxiesim.c +1 -1
index 1d06e39fcb..51a98287b5 100644
@@ -150,7 +150,7 @@ static void moxiesim_machine_init(MachineClass *mc)
 {
     mc->desc = "Moxie simulator platform";
     mc->init = moxiesim_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = MOXIE_CPU_TYPE_NAME("MoxieLite");
 }
 
hw/nios2/10m50_devboard.c +1 -1
index ad8b2fc670..33dc2bf511 100644
@@ -120,7 +120,7 @@ static void nios2_10m50_ghrd_machine_init(struct MachineClass *mc)
 {
     mc->desc = "Altera 10M50 GHRD Nios II design";
     mc->init = nios2_10m50_ghrd_init;
-    mc->is_default = 1;
+    mc->is_default = true;
 }
 
 DEFINE_MACHINE("10m50-ghrd", nios2_10m50_ghrd_machine_init);
hw/openrisc/openrisc_sim.c +1 -1
index ad5371250f..d08ce61811 100644
@@ -176,7 +176,7 @@ static void openrisc_sim_machine_init(MachineClass *mc)
     mc->desc = "or1k simulation";
     mc->init = openrisc_sim_init;
     mc->max_cpus = 2;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = OPENRISC_CPU_TYPE_NAME("or1200");
 }
 
hw/ppc/mac_oldworld.c +1 -1
index 7318d7e9b4..1630663bc2 100644
@@ -438,7 +438,7 @@ static void heathrow_class_init(ObjectClass *oc, void *data)
     mc->block_default_type = IF_IDE;
     mc->max_cpus = MAX_CPUS;
 #ifndef TARGET_PPC64
-    mc->is_default = 1;
+    mc->is_default = true;
 #endif
     /* TOFIX "cad" when Mac floppy is implemented */
     mc->default_boot_order = "cd";
hw/ppc/spapr.c +1 -1
index c9b2e0a5e0..e3e3208cd8 100644
@@ -4493,7 +4493,7 @@ static const TypeInfo spapr_machine_info = {
         spapr_machine_##suffix##_class_options(mc);                  \
         if (latest) {                                                \
             mc->alias = "pseries";                                   \
-            mc->is_default = 1;                                      \
+            mc->is_default = true;                                   \
         }                                                            \
     }                                                                \
     static const TypeInfo spapr_machine_##suffix##_info = {          \
hw/riscv/spike.c +1 -1
index 8823681783..6f03857660 100644
@@ -448,7 +448,7 @@ static void spike_machine_init(MachineClass *mc)
     mc->desc = "RISC-V Spike Board";
     mc->init = spike_board_init;
     mc->max_cpus = 1;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = SPIKE_V1_10_0_CPU;
 }
 
hw/s390x/s390-virtio-ccw.c +1 -1
index e759eb5f83..c4b291e434 100644
@@ -631,7 +631,7 @@ bool css_migration_enabled(void)
         mc->desc = "VirtIO-ccw based S390 machine v" verstr;                  \
         if (latest) {                                                         \
             mc->alias = "s390-ccw-virtio";                                    \
-            mc->is_default = 1;                                               \
+            mc->is_default = true;                                            \
         }                                                                     \
     }                                                                         \
     static void ccw_machine_##suffix##_instance_init(Object *obj)             \
hw/sh4/shix.c +1 -1
index 2fc2915428..68b14ee5e7 100644
@@ -82,7 +82,7 @@ static void shix_machine_init(MachineClass *mc)
 {
     mc->desc = "shix card";
     mc->init = shix_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = TYPE_SH7750R_CPU;
 }
 
hw/sparc/sun4m.c +1 -1
index 25e96db5ca..d6c9772f95 100644
@@ -1411,7 +1411,7 @@ static void ss5_class_init(ObjectClass *oc, void *data)
     mc->desc = "Sun4m platform, SPARCstation 5";
     mc->init = ss5_init;
     mc->block_default_type = IF_SCSI;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_boot_order = "c";
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
     mc->default_display = "tcx";
hw/sparc64/sun4u.c +1 -1
index b7ac42f7a5..d33e84f831 100644
@@ -816,7 +816,7 @@ static void sun4u_class_init(ObjectClass *oc, void *data)
     mc->init = sun4u_init;
     mc->block_default_type = IF_IDE;
     mc->max_cpus = 1; /* XXX for now */
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_boot_order = "c";
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-UltraSparc-IIi");
     mc->ignore_boot_device_suffixes = true;
hw/unicore32/puv3.c +1 -2
index 7e933de228..7f9c0238fe 100644
@@ -140,7 +140,7 @@ static void puv3_machine_init(MachineClass *mc)
 {
     mc->desc = "PKUnity Version-3 based on UniCore32";
     mc->init = puv3_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = UNICORE32_CPU_TYPE_NAME("UniCore-II");
 }
 
--

2.21.1

Signature · 1 line
Marc-André Lureau
Reviewed-by on v4 2/3
#12 lore raw

Re: [PATCH v4 2/3] hw: Make MachineClass::is_default a boolean type

In reply to Philippe Mathieu-Daudé

Le 07/02/2020 à 17:19, Philippe Mathieu-Daudé a écrit :

Quoted 330 lines

There's no good reason for it to be type int, change it to bool.

---
v4:
- fixed incorrect changes to max_cpus (Laurent)
- describe field

---
 include/hw/boards.h                      |  4 +++-
 hw/alpha/dp264.c                         |  2 +-
 hw/cris/axis_dev88.c                     |  2 +-
 hw/hppa/machine.c                        |  2 +-
 hw/i386/pc_piix.c                        | 10 +++++-----
 hw/lm32/lm32_boards.c                    |  2 +-
 hw/m68k/mcf5208.c                        |  2 +-
 hw/microblaze/petalogix_s3adsp1800_mmu.c |  2 +-
 hw/mips/mips_malta.c                     |  2 +-
 hw/moxie/moxiesim.c                      |  2 +-
 hw/nios2/10m50_devboard.c                |  2 +-
 hw/openrisc/openrisc_sim.c               |  2 +-
 hw/ppc/mac_oldworld.c                    |  2 +-
 hw/ppc/spapr.c                           |  2 +-
 hw/riscv/spike.c                         |  2 +-
 hw/s390x/s390-virtio-ccw.c               |  2 +-
 hw/sh4/shix.c                            |  2 +-
 hw/sparc/sun4m.c                         |  2 +-
 hw/sparc64/sun4u.c                       |  2 +-
 hw/unicore32/puv3.c                      |  2 +-
 20 files changed, 26 insertions(+), 24 deletions(-)
include/hw/boards.h +3 -1
index fb1b43d5b9..c3523a70e8 100644
@@ -107,6 +107,8 @@ typedef struct {
  * @max_cpus: maximum number of CPUs supported. Default: 1
  * @min_cpus: minimum number of CPUs supported. Default: 1
  * @default_cpus: number of CPUs instantiated if none are specified. Default: 1
+ * @is_default:
+ *    If true QEMU will use this machine by default if no '-M' option is given.
  * @get_hotplug_handler: this function is called during bus-less
  *    device hotplug. If defined it returns pointer to an instance
  *    of HotplugHandler object, which handles hotplug operation
@@ -200,7 +202,7 @@ struct MachineClass {
         no_sdcard:1,
         pci_allow_0_address:1,
         legacy_fw_cfg_order:1;
-    int is_default;
+    bool is_default;
     const char *default_machine_opts;
     const char *default_boot_order;
     const char *default_display;
hw/alpha/dp264.c +1 -1
index a8f9a89cc4..083a198a64 100644
@@ -181,7 +181,7 @@ static void clipper_machine_init(MachineClass *mc)
     mc->init = clipper_init;
     mc->block_default_type = IF_IDE;
     mc->max_cpus = 4;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = ALPHA_CPU_TYPE_NAME("ev67");
 }
 
hw/cris/axis_dev88.c +1 -1
index be7760476a..de7b49188b 100644
@@ -349,7 +349,7 @@ static void axisdev88_machine_init(MachineClass *mc)
 {
     mc->desc = "AXIS devboard 88";
     mc->init = axisdev88_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = CRIS_CPU_TYPE_NAME("crisv32");
 }
 
hw/hppa/machine.c +1 -1
index d8755ec422..83ae87f565 100644
@@ -295,7 +295,7 @@ static void machine_hppa_machine_init(MachineClass *mc)
     mc->block_default_type = IF_SCSI;
     mc->max_cpus = HPPA_MAX_CPUS;
     mc->default_cpus = 1;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_ram_size = 512 * MiB;
     mc->default_boot_order = "cd";
 }
hw/i386/pc_piix.c +5 -5
index fa12203079..9088db8fb6 100644
@@ -423,7 +423,7 @@ static void pc_i440fx_5_0_machine_options(MachineClass *m)
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_i440fx_machine_options(m);
     m->alias = "pc";
-    m->is_default = 1;
+    m->is_default = true;
     pcmc->default_cpu_version = 1;
 }
 
@@ -434,7 +434,7 @@ static void pc_i440fx_4_2_machine_options(MachineClass *m)
 {
     pc_i440fx_5_0_machine_options(m);
     m->alias = NULL;
-    m->is_default = 0;
+    m->is_default = false;
     compat_props_add(m->compat_props, hw_compat_4_2, hw_compat_4_2_len);
     compat_props_add(m->compat_props, pc_compat_4_2, pc_compat_4_2_len);
 }
@@ -446,7 +446,7 @@ static void pc_i440fx_4_1_machine_options(MachineClass *m)
 {
     pc_i440fx_4_2_machine_options(m);
     m->alias = NULL;
-    m->is_default = 0;
+    m->is_default = false;
     compat_props_add(m->compat_props, hw_compat_4_1, hw_compat_4_1_len);
     compat_props_add(m->compat_props, pc_compat_4_1, pc_compat_4_1_len);
 }
@@ -459,7 +459,7 @@ static void pc_i440fx_4_0_machine_options(MachineClass *m)
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_i440fx_4_1_machine_options(m);
     m->alias = NULL;
-    m->is_default = 0;
+    m->is_default = false;
     pcmc->default_cpu_version = CPU_VERSION_LEGACY;
     compat_props_add(m->compat_props, hw_compat_4_0, hw_compat_4_0_len);
     compat_props_add(m->compat_props, pc_compat_4_0, pc_compat_4_0_len);
@@ -473,7 +473,7 @@ static void pc_i440fx_3_1_machine_options(MachineClass *m)
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
 
     pc_i440fx_4_0_machine_options(m);
-    m->is_default = 0;
+    m->is_default = false;
     pcmc->do_not_add_smb_acpi = true;
     m->smbus_no_migration_support = true;
     m->alias = NULL;
hw/lm32/lm32_boards.c +1 -1
index 156b050abc..352f69532e 100644
@@ -286,7 +286,7 @@ static void lm32_evr_class_init(ObjectClass *oc, void *data)
 
     mc->desc = "LatticeMico32 EVR32 eval system";
     mc->init = lm32_evr_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = LM32_CPU_TYPE_NAME("lm32-full");
 }
 
hw/m68k/mcf5208.c +1 -1
index a999c21982..5f8f6e4475 100644
@@ -352,7 +352,7 @@ static void mcf5208evb_machine_init(MachineClass *mc)
 {
     mc->desc = "MCF5208EVB";
     mc->init = mcf5208evb_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = M68K_CPU_TYPE_NAME("m5208");
 }
 
hw/microblaze/petalogix_s3adsp1800_mmu.c +1 -1
index 849bafc186..0bb6cdea8d 100644
@@ -132,7 +132,7 @@ static void petalogix_s3adsp1800_machine_init(MachineClass *mc)
 {
     mc->desc = "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800";
     mc->init = petalogix_s3adsp1800_init;
-    mc->is_default = 1;
+    mc->is_default = true;
 }
 
 DEFINE_MACHINE("petalogix-s3adsp1800", petalogix_s3adsp1800_machine_init)
hw/mips/mips_malta.c +1 -1
index 34b76bb6a1..499eac8d33 100644
@@ -1442,7 +1442,7 @@ static void mips_malta_machine_init(MachineClass *mc)
     mc->init = mips_malta_init;
     mc->block_default_type = IF_IDE;
     mc->max_cpus = 16;
-    mc->is_default = 1;
+    mc->is_default = true;
 #ifdef TARGET_MIPS64
     mc->default_cpu_type = MIPS_CPU_TYPE_NAME("20Kc");
 #else
hw/moxie/moxiesim.c +1 -1
index 1d06e39fcb..51a98287b5 100644
@@ -150,7 +150,7 @@ static void moxiesim_machine_init(MachineClass *mc)
 {
     mc->desc = "Moxie simulator platform";
     mc->init = moxiesim_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = MOXIE_CPU_TYPE_NAME("MoxieLite");
 }
 
hw/nios2/10m50_devboard.c +1 -1
index ad8b2fc670..33dc2bf511 100644
@@ -120,7 +120,7 @@ static void nios2_10m50_ghrd_machine_init(struct MachineClass *mc)
 {
     mc->desc = "Altera 10M50 GHRD Nios II design";
     mc->init = nios2_10m50_ghrd_init;
-    mc->is_default = 1;
+    mc->is_default = true;
 }
 
 DEFINE_MACHINE("10m50-ghrd", nios2_10m50_ghrd_machine_init);
hw/openrisc/openrisc_sim.c +1 -1
index ad5371250f..d08ce61811 100644
@@ -176,7 +176,7 @@ static void openrisc_sim_machine_init(MachineClass *mc)
     mc->desc = "or1k simulation";
     mc->init = openrisc_sim_init;
     mc->max_cpus = 2;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = OPENRISC_CPU_TYPE_NAME("or1200");
 }
 
hw/ppc/mac_oldworld.c +1 -1
index 7318d7e9b4..1630663bc2 100644
@@ -438,7 +438,7 @@ static void heathrow_class_init(ObjectClass *oc, void *data)
     mc->block_default_type = IF_IDE;
     mc->max_cpus = MAX_CPUS;
 #ifndef TARGET_PPC64
-    mc->is_default = 1;
+    mc->is_default = true;
 #endif
     /* TOFIX "cad" when Mac floppy is implemented */
     mc->default_boot_order = "cd";
hw/ppc/spapr.c +1 -1
index c9b2e0a5e0..e3e3208cd8 100644
@@ -4493,7 +4493,7 @@ static const TypeInfo spapr_machine_info = {
         spapr_machine_##suffix##_class_options(mc);                  \
         if (latest) {                                                \
             mc->alias = "pseries";                                   \
-            mc->is_default = 1;                                      \
+            mc->is_default = true;                                   \
         }                                                            \
     }                                                                \
     static const TypeInfo spapr_machine_##suffix##_info = {          \
hw/riscv/spike.c +1 -1
index 8823681783..6f03857660 100644
@@ -448,7 +448,7 @@ static void spike_machine_init(MachineClass *mc)
     mc->desc = "RISC-V Spike Board";
     mc->init = spike_board_init;
     mc->max_cpus = 1;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = SPIKE_V1_10_0_CPU;
 }
 
hw/s390x/s390-virtio-ccw.c +1 -1
index e759eb5f83..c4b291e434 100644
@@ -631,7 +631,7 @@ bool css_migration_enabled(void)
         mc->desc = "VirtIO-ccw based S390 machine v" verstr;                  \
         if (latest) {                                                         \
             mc->alias = "s390-ccw-virtio";                                    \
-            mc->is_default = 1;                                               \
+            mc->is_default = true;                                            \
         }                                                                     \
     }                                                                         \
     static void ccw_machine_##suffix##_instance_init(Object *obj)             \
hw/sh4/shix.c +1 -1
index 2fc2915428..68b14ee5e7 100644
@@ -82,7 +82,7 @@ static void shix_machine_init(MachineClass *mc)
 {
     mc->desc = "shix card";
     mc->init = shix_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = TYPE_SH7750R_CPU;
 }
 
hw/sparc/sun4m.c +1 -1
index 25e96db5ca..d6c9772f95 100644
@@ -1411,7 +1411,7 @@ static void ss5_class_init(ObjectClass *oc, void *data)
     mc->desc = "Sun4m platform, SPARCstation 5";
     mc->init = ss5_init;
     mc->block_default_type = IF_SCSI;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_boot_order = "c";
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
     mc->default_display = "tcx";
hw/sparc64/sun4u.c +1 -1
index b7ac42f7a5..d33e84f831 100644
@@ -816,7 +816,7 @@ static void sun4u_class_init(ObjectClass *oc, void *data)
     mc->init = sun4u_init;
     mc->block_default_type = IF_IDE;
     mc->max_cpus = 1; /* XXX for now */
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_boot_order = "c";
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-UltraSparc-IIi");
     mc->ignore_boot_device_suffixes = true;
hw/unicore32/puv3.c +0 -0
index 7e933de228..7f9c0238fe 100644

hw/unicore32/puv3.c static void puv3_machine_init(MachineClass *mc) · line 146

Quoted 8 lines
hw/unicore32/puv3.c +1 -1
@@ -140,7 +140,7 @@ static void puv3_machine_init(MachineClass *mc)
 {
     mc->desc = "PKUnity Version-3 based on UniCore32";
     mc->init = puv3_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = UNICORE32_CPU_TYPE_NAME("UniCore-II");
 }
 
Reviewed-by Acked-by on v4 2/3
#13 lore raw

Re: [PATCH v4 2/3] hw: Make MachineClass::is_default a boolean type

In reply to Philippe Mathieu-Daudé
Quoted 5 lines · Philippe Mathieu-Daudé

There's no good reason for it to be type int, change it to bool.

and ppc parts

Quoted 332 lines

---
v4:
- fixed incorrect changes to max_cpus (Laurent)
- describe field

---
 include/hw/boards.h                      |  4 +++-
 hw/alpha/dp264.c                         |  2 +-
 hw/cris/axis_dev88.c                     |  2 +-
 hw/hppa/machine.c                        |  2 +-
 hw/i386/pc_piix.c                        | 10 +++++-----
 hw/lm32/lm32_boards.c                    |  2 +-
 hw/m68k/mcf5208.c                        |  2 +-
 hw/microblaze/petalogix_s3adsp1800_mmu.c |  2 +-
 hw/mips/mips_malta.c                     |  2 +-
 hw/moxie/moxiesim.c                      |  2 +-
 hw/nios2/10m50_devboard.c                |  2 +-
 hw/openrisc/openrisc_sim.c               |  2 +-
 hw/ppc/mac_oldworld.c                    |  2 +-
 hw/ppc/spapr.c                           |  2 +-
 hw/riscv/spike.c                         |  2 +-
 hw/s390x/s390-virtio-ccw.c               |  2 +-
 hw/sh4/shix.c                            |  2 +-
 hw/sparc/sun4m.c                         |  2 +-
 hw/sparc64/sun4u.c                       |  2 +-
 hw/unicore32/puv3.c                      |  2 +-
 20 files changed, 26 insertions(+), 24 deletions(-)
include/hw/boards.h +3 -1
index fb1b43d5b9..c3523a70e8 100644
@@ -107,6 +107,8 @@ typedef struct {
  * @max_cpus: maximum number of CPUs supported. Default: 1
  * @min_cpus: minimum number of CPUs supported. Default: 1
  * @default_cpus: number of CPUs instantiated if none are specified. Default: 1
+ * @is_default:
+ *    If true QEMU will use this machine by default if no '-M' option is given.
  * @get_hotplug_handler: this function is called during bus-less
  *    device hotplug. If defined it returns pointer to an instance
  *    of HotplugHandler object, which handles hotplug operation
@@ -200,7 +202,7 @@ struct MachineClass {
         no_sdcard:1,
         pci_allow_0_address:1,
         legacy_fw_cfg_order:1;
-    int is_default;
+    bool is_default;
     const char *default_machine_opts;
     const char *default_boot_order;
     const char *default_display;
hw/alpha/dp264.c +1 -1
index a8f9a89cc4..083a198a64 100644
@@ -181,7 +181,7 @@ static void clipper_machine_init(MachineClass *mc)
     mc->init = clipper_init;
     mc->block_default_type = IF_IDE;
     mc->max_cpus = 4;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = ALPHA_CPU_TYPE_NAME("ev67");
 }
 
hw/cris/axis_dev88.c +1 -1
index be7760476a..de7b49188b 100644
@@ -349,7 +349,7 @@ static void axisdev88_machine_init(MachineClass *mc)
 {
     mc->desc = "AXIS devboard 88";
     mc->init = axisdev88_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = CRIS_CPU_TYPE_NAME("crisv32");
 }
 
hw/hppa/machine.c +1 -1
index d8755ec422..83ae87f565 100644
@@ -295,7 +295,7 @@ static void machine_hppa_machine_init(MachineClass *mc)
     mc->block_default_type = IF_SCSI;
     mc->max_cpus = HPPA_MAX_CPUS;
     mc->default_cpus = 1;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_ram_size = 512 * MiB;
     mc->default_boot_order = "cd";
 }
hw/i386/pc_piix.c +5 -5
index fa12203079..9088db8fb6 100644
@@ -423,7 +423,7 @@ static void pc_i440fx_5_0_machine_options(MachineClass *m)
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_i440fx_machine_options(m);
     m->alias = "pc";
-    m->is_default = 1;
+    m->is_default = true;
     pcmc->default_cpu_version = 1;
 }
 
@@ -434,7 +434,7 @@ static void pc_i440fx_4_2_machine_options(MachineClass *m)
 {
     pc_i440fx_5_0_machine_options(m);
     m->alias = NULL;
-    m->is_default = 0;
+    m->is_default = false;
     compat_props_add(m->compat_props, hw_compat_4_2, hw_compat_4_2_len);
     compat_props_add(m->compat_props, pc_compat_4_2, pc_compat_4_2_len);
 }
@@ -446,7 +446,7 @@ static void pc_i440fx_4_1_machine_options(MachineClass *m)
 {
     pc_i440fx_4_2_machine_options(m);
     m->alias = NULL;
-    m->is_default = 0;
+    m->is_default = false;
     compat_props_add(m->compat_props, hw_compat_4_1, hw_compat_4_1_len);
     compat_props_add(m->compat_props, pc_compat_4_1, pc_compat_4_1_len);
 }
@@ -459,7 +459,7 @@ static void pc_i440fx_4_0_machine_options(MachineClass *m)
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_i440fx_4_1_machine_options(m);
     m->alias = NULL;
-    m->is_default = 0;
+    m->is_default = false;
     pcmc->default_cpu_version = CPU_VERSION_LEGACY;
     compat_props_add(m->compat_props, hw_compat_4_0, hw_compat_4_0_len);
     compat_props_add(m->compat_props, pc_compat_4_0, pc_compat_4_0_len);
@@ -473,7 +473,7 @@ static void pc_i440fx_3_1_machine_options(MachineClass *m)
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
 
     pc_i440fx_4_0_machine_options(m);
-    m->is_default = 0;
+    m->is_default = false;
     pcmc->do_not_add_smb_acpi = true;
     m->smbus_no_migration_support = true;
     m->alias = NULL;
hw/lm32/lm32_boards.c +1 -1
index 156b050abc..352f69532e 100644
@@ -286,7 +286,7 @@ static void lm32_evr_class_init(ObjectClass *oc, void *data)
 
     mc->desc = "LatticeMico32 EVR32 eval system";
     mc->init = lm32_evr_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = LM32_CPU_TYPE_NAME("lm32-full");
 }
 
hw/m68k/mcf5208.c +1 -1
index a999c21982..5f8f6e4475 100644
@@ -352,7 +352,7 @@ static void mcf5208evb_machine_init(MachineClass *mc)
 {
     mc->desc = "MCF5208EVB";
     mc->init = mcf5208evb_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = M68K_CPU_TYPE_NAME("m5208");
 }
 
hw/microblaze/petalogix_s3adsp1800_mmu.c +1 -1
index 849bafc186..0bb6cdea8d 100644
@@ -132,7 +132,7 @@ static void petalogix_s3adsp1800_machine_init(MachineClass *mc)
 {
     mc->desc = "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800";
     mc->init = petalogix_s3adsp1800_init;
-    mc->is_default = 1;
+    mc->is_default = true;
 }
 
 DEFINE_MACHINE("petalogix-s3adsp1800", petalogix_s3adsp1800_machine_init)
hw/mips/mips_malta.c +1 -1
index 34b76bb6a1..499eac8d33 100644
@@ -1442,7 +1442,7 @@ static void mips_malta_machine_init(MachineClass *mc)
     mc->init = mips_malta_init;
     mc->block_default_type = IF_IDE;
     mc->max_cpus = 16;
-    mc->is_default = 1;
+    mc->is_default = true;
 #ifdef TARGET_MIPS64
     mc->default_cpu_type = MIPS_CPU_TYPE_NAME("20Kc");
 #else
hw/moxie/moxiesim.c +1 -1
index 1d06e39fcb..51a98287b5 100644
@@ -150,7 +150,7 @@ static void moxiesim_machine_init(MachineClass *mc)
 {
     mc->desc = "Moxie simulator platform";
     mc->init = moxiesim_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = MOXIE_CPU_TYPE_NAME("MoxieLite");
 }
 
hw/nios2/10m50_devboard.c +1 -1
index ad8b2fc670..33dc2bf511 100644
@@ -120,7 +120,7 @@ static void nios2_10m50_ghrd_machine_init(struct MachineClass *mc)
 {
     mc->desc = "Altera 10M50 GHRD Nios II design";
     mc->init = nios2_10m50_ghrd_init;
-    mc->is_default = 1;
+    mc->is_default = true;
 }
 
 DEFINE_MACHINE("10m50-ghrd", nios2_10m50_ghrd_machine_init);
hw/openrisc/openrisc_sim.c +1 -1
index ad5371250f..d08ce61811 100644
@@ -176,7 +176,7 @@ static void openrisc_sim_machine_init(MachineClass *mc)
     mc->desc = "or1k simulation";
     mc->init = openrisc_sim_init;
     mc->max_cpus = 2;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = OPENRISC_CPU_TYPE_NAME("or1200");
 }
 
hw/ppc/mac_oldworld.c +1 -1
index 7318d7e9b4..1630663bc2 100644
@@ -438,7 +438,7 @@ static void heathrow_class_init(ObjectClass *oc, void *data)
     mc->block_default_type = IF_IDE;
     mc->max_cpus = MAX_CPUS;
 #ifndef TARGET_PPC64
-    mc->is_default = 1;
+    mc->is_default = true;
 #endif
     /* TOFIX "cad" when Mac floppy is implemented */
     mc->default_boot_order = "cd";
hw/ppc/spapr.c +1 -1
index c9b2e0a5e0..e3e3208cd8 100644
@@ -4493,7 +4493,7 @@ static const TypeInfo spapr_machine_info = {
         spapr_machine_##suffix##_class_options(mc);                  \
         if (latest) {                                                \
             mc->alias = "pseries";                                   \
-            mc->is_default = 1;                                      \
+            mc->is_default = true;                                   \
         }                                                            \
     }                                                                \
     static const TypeInfo spapr_machine_##suffix##_info = {          \
hw/riscv/spike.c +1 -1
index 8823681783..6f03857660 100644
@@ -448,7 +448,7 @@ static void spike_machine_init(MachineClass *mc)
     mc->desc = "RISC-V Spike Board";
     mc->init = spike_board_init;
     mc->max_cpus = 1;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = SPIKE_V1_10_0_CPU;
 }
 
hw/s390x/s390-virtio-ccw.c +1 -1
index e759eb5f83..c4b291e434 100644
@@ -631,7 +631,7 @@ bool css_migration_enabled(void)
         mc->desc = "VirtIO-ccw based S390 machine v" verstr;                  \
         if (latest) {                                                         \
             mc->alias = "s390-ccw-virtio";                                    \
-            mc->is_default = 1;                                               \
+            mc->is_default = true;                                            \
         }                                                                     \
     }                                                                         \
     static void ccw_machine_##suffix##_instance_init(Object *obj)             \
hw/sh4/shix.c +1 -1
index 2fc2915428..68b14ee5e7 100644
@@ -82,7 +82,7 @@ static void shix_machine_init(MachineClass *mc)
 {
     mc->desc = "shix card";
     mc->init = shix_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = TYPE_SH7750R_CPU;
 }
 
hw/sparc/sun4m.c +1 -1
index 25e96db5ca..d6c9772f95 100644
@@ -1411,7 +1411,7 @@ static void ss5_class_init(ObjectClass *oc, void *data)
     mc->desc = "Sun4m platform, SPARCstation 5";
     mc->init = ss5_init;
     mc->block_default_type = IF_SCSI;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_boot_order = "c";
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
     mc->default_display = "tcx";
hw/sparc64/sun4u.c +1 -1
index b7ac42f7a5..d33e84f831 100644
@@ -816,7 +816,7 @@ static void sun4u_class_init(ObjectClass *oc, void *data)
     mc->init = sun4u_init;
     mc->block_default_type = IF_IDE;
     mc->max_cpus = 1; /* XXX for now */
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_boot_order = "c";
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-UltraSparc-IIi");
     mc->ignore_boot_device_suffixes = true;
hw/unicore32/puv3.c +1 -1
index 7e933de228..7f9c0238fe 100644
@@ -140,7 +140,7 @@ static void puv3_machine_init(MachineClass *mc)
 {
     mc->desc = "PKUnity Version-3 based on UniCore32";
     mc->init = puv3_init;
-    mc->is_default = 1;
+    mc->is_default = true;
     mc->default_cpu_type = UNICORE32_CPU_TYPE_NAME("UniCore-II");
 }
 
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
Acked-by on v4 2/3
#14 lore raw

Re: [PATCH v4 2/3] hw: Make MachineClass::is_default a boolean type

In reply to Philippe Mathieu-Daudé
Quoted 23 lines · On Fri, 7 Feb 2020 17:19:47 +0100 Philippe Mathieu-Daudé <[email protected]>…

There's no good reason for it to be type int, change it to bool.

---
v4:
- fixed incorrect changes to max_cpus (Laurent)
- describe field

---
 include/hw/boards.h                      |  4 +++-
 hw/alpha/dp264.c                         |  2 +-
 hw/cris/axis_dev88.c                     |  2 +-
 hw/hppa/machine.c                        |  2 +-
 hw/i386/pc_piix.c                        | 10 +++++-----
 hw/lm32/lm32_boards.c                    |  2 +-
 hw/m68k/mcf5208.c                        |  2 +-
 hw/microblaze/petalogix_s3adsp1800_mmu.c |  2 +-
 hw/mips/mips_malta.c                     |  2 +-
 hw/moxie/moxiesim.c                      |  2 +-
 hw/nios2/10m50_devboard.c                |  2 +-
 hw/openrisc/openrisc_sim.c               |  2 +-
 hw/ppc/mac_oldworld.c                    |  2 +-
Quoted 8 lines
 hw/ppc/spapr.c                           |  2 +-
 hw/riscv/spike.c                         |  2 +-
 hw/s390x/s390-virtio-ccw.c               |  2 +-
 hw/sh4/shix.c                            |  2 +-
 hw/sparc/sun4m.c                         |  2 +-
 hw/sparc64/sun4u.c                       |  2 +-
 hw/unicore32/puv3.c                      |  2 +-
 20 files changed, 26 insertions(+), 24 deletions(-)

s390 part:

Reviewed-by on v4 2/3
#15 lore raw

Re: [PATCH v4 2/3] hw: Make MachineClass::is_default a boolean type

In reply to Philippe Mathieu-Daudé
Quoted 10 lines · Philippe Mathieu-Daudé

There's no good reason for it to be type int, change it to bool.

---
v4:
- fixed incorrect changes to max_cpus (Laurent)
- describe field
---

[...]

Quoted 23 lines
hw/i386/pc_piix.c +2 -2
index fa12203079..9088db8fb6 100644
@@ -423,7 +423,7 @@ static void pc_i440fx_5_0_machine_options(MachineClass *m)
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_i440fx_machine_options(m);
     m->alias = "pc";
-    m->is_default = 1;
+    m->is_default = true;
     pcmc->default_cpu_version = 1;
 }
 
@@ -434,7 +434,7 @@ static void pc_i440fx_4_2_machine_options(MachineClass *m)
 {
     pc_i440fx_5_0_machine_options(m);
     m->alias = NULL;
-    m->is_default = 0;
+    m->is_default = false;
     compat_props_add(m->compat_props, hw_compat_4_2, hw_compat_4_2_len);
     compat_props_add(m->compat_props, pc_compat_4_2, pc_compat_4_2_len);
 }

hw/i386/pc_piix.c static void pc_i440fx_4_1_machine_options(MachineClass *m) · line 447

Quoted 2 lines
hw/i386/pc_piix.c +0 -0
@@ -446,7 +446,7 @@ static void pc_i440fx_4_1_machine_options(MachineClass *m)
 {
     pc_i440fx_4_2_machine_options(m);

Since we're calling pc_i440fx_4_2_machine_options() here...

hw/i386/pc_piix.c static void pc_i440fx_4_2_machine_options(MachineClass *m) · line 437

Quoted 3 lines
hw/i386/pc_piix.c +1 -1
     m->alias = NULL;
-    m->is_default = 0;
+    m->is_default = false;

... you could even remove this line now...

hw/i386/pc_piix.c static void pc_i440fx_4_0_machine_options(MachineClass *m) · line 462

Quoted 9 lines
hw/i386/pc_piix.c +1 -1
     compat_props_add(m->compat_props, hw_compat_4_1, hw_compat_4_1_len);
     compat_props_add(m->compat_props, pc_compat_4_1, pc_compat_4_1_len);
 }
@@ -459,7 +459,7 @@ static void pc_i440fx_4_0_machine_options(MachineClass *m)
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_i440fx_4_1_machine_options(m);
     m->alias = NULL;
-    m->is_default = 0;
+    m->is_default = false;

... and this one, too.

hw/i386/pc_piix.c static void pc_i440fx_3_1_machine_options(MachineClass *m) · line 476

Quoted 9 lines
hw/i386/pc_piix.c +1 -1
     pcmc->default_cpu_version = CPU_VERSION_LEGACY;
     compat_props_add(m->compat_props, hw_compat_4_0, hw_compat_4_0_len);
     compat_props_add(m->compat_props, pc_compat_4_0, pc_compat_4_0_len);
@@ -473,7 +473,7 @@ static void pc_i440fx_3_1_machine_options(MachineClass *m)
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
 
     pc_i440fx_4_0_machine_options(m);
-    m->is_default = 0;
+    m->is_default = false;

dito.

But that could also be done in a later patch, so:

#16 lore raw

PATCH v4 3/3 vl: Abort if multiple machines are registered as default

In reply to Philippe Mathieu-Daudé

It would be confusing to have multiple default machines. Abort if this ever occurs.

---
v2: Use assert() instead of human friendly message (Marc-André)
v3: Move the check to find_machine() (Michael)

Cc Marc-André Lureau <[email protected]>
Cc Laurent Vivier <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
---
 vl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
vl.c +4 -2
index 7dcb0879c4..ebc203af0d 100644
@@ -1184,16 +1184,18 @@ static MachineClass *find_machine(const char *name, GSList *machines)
 static MachineClass *find_default_machine(GSList *machines)
 {
     GSList *el;
+    MachineClass *default_machineclass = NULL;
 
     for (el = machines; el; el = el->next) {
         MachineClass *mc = el->data;
 
         if (mc->is_default) {
-            return mc;
+            assert(default_machineclass == NULL && "Multiple default machines");
+            default_machineclass = mc;
         }
     }
 
-    return NULL;
+    return default_machineclass;
 }
 
 static int machine_help_func(QemuOpts *opts, MachineState *machine)
Signature · 1 line
2.21.1
Reviewed-by on v4 3/3
#17 lore raw

Re: [PATCH v4 3/3] vl: Abort if multiple machines are registered as default

Quoted 4 lines · Philippe Mathieu-Daudé

It would be confusing to have multiple default machines. Abort if this ever occurs.

Quoted 8 lines

---
v2: Use assert() instead of human friendly message (Marc-André)
v3: Move the check to find_machine() (Michael)

Cc Marc-André Lureau <[email protected]>
Cc Laurent Vivier <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Quoted 32 lines
---
 vl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
vl.c +4 -3
index 7dcb0879c4..ebc203af0d 100644
@@ -1184,16 +1184,18 @@ static MachineClass *find_machine(const char *name, GSList *machines)
 static MachineClass *find_default_machine(GSList *machines)
 {
     GSList *el;
+    MachineClass *default_machineclass = NULL;
 
     for (el = machines; el; el = el->next) {
         MachineClass *mc = el->data;
 
         if (mc->is_default) {
-            return mc;
+            assert(default_machineclass == NULL && "Multiple default machines");
+            default_machineclass = mc;
         }
     }
 
-    return NULL;
+    return default_machineclass;
 }
 
 static int machine_help_func(QemuOpts *opts, MachineState *machine)
--

2.21.1

Signature · 1 line
Marc-André Lureau
Reviewed-by Tested-by on v4 3/3
#18 lore raw

Re: [PATCH v4 3/3] vl: Abort if multiple machines are registered as default

In reply to Philippe Mathieu-Daudé

Le 07/02/2020 à 17:19, Philippe Mathieu-Daudé a écrit :

Quoted 31 lines

It would be confusing to have multiple default machines. Abort if this ever occurs.

---
v2: Use assert() instead of human friendly message (Marc-André)
v3: Move the check to find_machine() (Michael)

Cc Marc-André Lureau <[email protected]>
Cc Laurent Vivier <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
---
 vl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
vl.c +1 -1
index 7dcb0879c4..ebc203af0d 100644
@@ -1184,16 +1184,18 @@ static MachineClass *find_machine(const char *name, GSList *machines)
 static MachineClass *find_default_machine(GSList *machines)
 {
     GSList *el;
+    MachineClass *default_machineclass = NULL;
 
     for (el = machines; el; el = el->next) {
         MachineClass *mc = el->data;
 
         if (mc->is_default) {
-            return mc;

vl.c static MachineClass *find_machine(const char *name, GSList *machines) · line 1201

Quoted 10 lines
vl.c +3 -1
+            assert(default_machineclass == NULL && "Multiple default machines");
+            default_machineclass = mc;
         }
     }
 
-    return NULL;
+    return default_machineclass;
 }
 
 static int machine_help_func(QemuOpts *opts, MachineState *machine)

I've tested "make check" actually fails when we have several default machines.

Thanks,
Laurent

Reviewed-by on v4 3/3
#19 lore raw

Re: [PATCH v4 3/3] vl: Abort if multiple machines are registered as default

In reply to Philippe Mathieu-Daudé
Quoted 4 lines · Philippe Mathieu-Daudé

It would be confusing to have multiple default machines. Abort if this ever occurs.

Quoted 36 lines

---
v2: Use assert() instead of human friendly message (Marc-André)
v3: Move the check to find_machine() (Michael)

Cc Marc-André Lureau <[email protected]>
Cc Laurent Vivier <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
---
 vl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
vl.c +4 -2
index 7dcb0879c4..ebc203af0d 100644
@@ -1184,16 +1184,18 @@ static MachineClass *find_machine(const char *name, GSList *machines)
 static MachineClass *find_default_machine(GSList *machines)
 {
     GSList *el;
+    MachineClass *default_machineclass = NULL;
 
     for (el = machines; el; el = el->next) {
         MachineClass *mc = el->data;
 
         if (mc->is_default) {
-            return mc;
+            assert(default_machineclass == NULL && "Multiple default machines");
+            default_machineclass = mc;
         }
     }
 
-    return NULL;
+    return default_machineclass;
 }
 
 static int machine_help_func(QemuOpts *opts, MachineState *machine)
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson