Skip to contentSkip to conversation

ppc: function to setup latest class options

PATCH Applied Michael S. Tsirkin 5 participants 7 messages Feb 7, 2020 – Feb 8, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ppc: function to setup latest class options

We are going to add more init for the latest machine, so move the setup to a function so we don't have to change the DEFINE_SPAPR_MACHINE macro each time.

---
 hw/ppc/spapr.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +7 -2
index 02cf53fc5b..4cf2a992a5 100644
@@ -4428,6 +4428,12 @@ static const TypeInfo spapr_machine_info = {
     },
 };
 
+static void spapr_machine_latest_class_options(MachineClass *mc)
+{
+    mc->alias = "pseries";
+    mc->is_default = 1;
+}
+
 #define DEFINE_SPAPR_MACHINE(suffix, verstr, latest)                 \
     static void spapr_machine_##suffix##_class_init(ObjectClass *oc, \
                                                     void *data)      \
@@ -4435,8 +4441,7 @@ static const TypeInfo spapr_machine_info = {
         MachineClass *mc = MACHINE_CLASS(oc);                        \
         spapr_machine_##suffix##_class_options(mc);                  \
         if (latest) {                                                \
-            mc->alias = "pseries";                                   \
-            mc->is_default = 1;                                      \
+            spapr_machine_latest_class_options(mc);                  \
         }                                                            \
     }                                                                \
     static const TypeInfo spapr_machine_##suffix##_info = {          \
Signature · 1 line
MST
Reviewed-by on v1 1/1
#1 lore raw
Quoted 28 lines · Michael S. Tsirkin

We are going to add more init for the latest machine, so move the setup to a function so we don't have to change the DEFINE_SPAPR_MACHINE macro each time.

---
 hw/ppc/spapr.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +6 -0
index 02cf53fc5b..4cf2a992a5 100644
@@ -4428,6 +4428,12 @@ static const TypeInfo spapr_machine_info = {
     },
 };
 
+static void spapr_machine_latest_class_options(MachineClass *mc)
+{
+    mc->alias = "pseries";
+    mc->is_default = 1;
+}
+
 #define DEFINE_SPAPR_MACHINE(suffix, verstr, latest)                 \
     static void spapr_machine_##suffix##_class_init(ObjectClass *oc, \
                                                     void *data)      \

hw/ppc/spapr.c static const TypeInfo spapr_machine_info = { · line 4447

Quoted 9 lines
hw/ppc/spapr.c +1 -2
@@ -4435,8 +4441,7 @@ static const TypeInfo spapr_machine_info = {
         MachineClass *mc = MACHINE_CLASS(oc);                        \
         spapr_machine_##suffix##_class_options(mc);                  \
         if (latest) {                                                \
-            mc->alias = "pseries";                                   \
-            mc->is_default = 1;                                      \
+            spapr_machine_latest_class_options(mc);                  \
         }                                                            \
     }                                                                \
     static const TypeInfo spapr_machine_##suffix##_info = {          \
Reviewed-by on v1 1/1
#2 lore raw
In reply to Michael S. Tsirkin
Quoted 4 lines · On Fri, 7 Feb 2020 01:48:02 -0500 "Michael S. Tsirkin" <[email protected]> wrote:

We are going to add more init for the latest machine, so move the setup to a function so we don't have to change the DEFINE_SPAPR_MACHINE macro each time.

Not sure about the meaning of "change the DEFINE_SPAPR_MACHINE macro" but yes, if we don't put the additional init there, we would be forced to move it around each time to the new default machine init.

Quoted 2 lines

---

Quoted 30 lines
 hw/ppc/spapr.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +7 -2
index 02cf53fc5b..4cf2a992a5 100644
@@ -4428,6 +4428,12 @@ static const TypeInfo spapr_machine_info = {
     },
 };
 
+static void spapr_machine_latest_class_options(MachineClass *mc)
+{
+    mc->alias = "pseries";
+    mc->is_default = 1;
+}
+
 #define DEFINE_SPAPR_MACHINE(suffix, verstr, latest)                 \
     static void spapr_machine_##suffix##_class_init(ObjectClass *oc, \
                                                     void *data)      \
@@ -4435,8 +4441,7 @@ static const TypeInfo spapr_machine_info = {
         MachineClass *mc = MACHINE_CLASS(oc);                        \
         spapr_machine_##suffix##_class_options(mc);                  \
         if (latest) {                                                \
-            mc->alias = "pseries";                                   \
-            mc->is_default = 1;                                      \
+            spapr_machine_latest_class_options(mc);                  \
         }                                                            \
     }                                                                \
     static const TypeInfo spapr_machine_##suffix##_info = {          \
#3 lore raw
In reply to Michael S. Tsirkin
Quoted 14 lines · Michael S. Tsirkin

We are going to add more init for the latest machine, so move the setup to a function so we don't have to change the DEFINE_SPAPR_MACHINE macro each time.

---
  hw/ppc/spapr.c | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +0 -0
index 02cf53fc5b..4cf2a992a5 100644

hw/ppc/spapr.c static const TypeInfo spapr_machine_info = { · line 4434

Quoted 7 lines
hw/ppc/spapr.c +4 -0
@@ -4428,6 +4428,12 @@ static const TypeInfo spapr_machine_info = {
      },
  };
 
+static void spapr_machine_latest_class_options(MachineClass *mc)
+{
+    mc->alias = "pseries";
+    mc->is_default = 1;

But we can have only 1 default per QEMU binary... How PPC manage having multiple defaults? The first or last listed is choosen as default?

Quoted 16 lines
hw/ppc/spapr.c +3 -2
+}
+
  #define DEFINE_SPAPR_MACHINE(suffix, verstr, latest)                 \
      static void spapr_machine_##suffix##_class_init(ObjectClass *oc, \
                                                      void *data)      \
@@ -4435,8 +4441,7 @@ static const TypeInfo spapr_machine_info = {
          MachineClass *mc = MACHINE_CLASS(oc);                        \
          spapr_machine_##suffix##_class_options(mc);                  \
          if (latest) {                                                \
-            mc->alias = "pseries";                                   \
-            mc->is_default = 1;                                      \
+            spapr_machine_latest_class_options(mc);                  \
          }                                                            \
      }                                                                \
      static const TypeInfo spapr_machine_##suffix##_info = {          \
#4 lore raw
Quoted 18 lines · On Fri, 7 Feb 2020 11:35:47 +0100 Philippe Mathieu-Daudé <[email protected]>…
Quoted 17 lines · Michael S. Tsirkin

We are going to add more init for the latest machine, so move the setup to a function so we don't have to change the DEFINE_SPAPR_MACHINE macro each time.

---
  hw/ppc/spapr.c | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +0 -0
index 02cf53fc5b..4cf2a992a5 100644
@@ -4428,6 +4428,12 @@ static const TypeInfo spapr_machine_info = {
      },
  };
 
Quoted 8 lines

hw/ppc/spapr.c static const TypeInfo spapr_machine_info = { · line 4434

Quoted 4 lines
hw/ppc/spapr.c +4 -0
+static void spapr_machine_latest_class_options(MachineClass *mc)
+{
+    mc->alias = "pseries";
+    mc->is_default = 1;

But we can have only 1 default per QEMU binary... How PPC manage having multiple defaults? The first or last listed is choosen as default?

IIUC it isn't about putting multiple defaults here. It is about putting any additional init for the default machine type that we cannot put in spapr_machine_class_init(), instead of putting it in the versioned init function, eg. spapr_machine_5_0_class_options(). Otherwise this would force us to carry the change when we add a new machine version.

Quoted 18 lines
Quoted 16 lines
hw/ppc/spapr.c +3 -2
+}
+
  #define DEFINE_SPAPR_MACHINE(suffix, verstr, latest)                 \
      static void spapr_machine_##suffix##_class_init(ObjectClass *oc, \
                                                      void *data)      \
@@ -4435,8 +4441,7 @@ static const TypeInfo spapr_machine_info = {
          MachineClass *mc = MACHINE_CLASS(oc);                        \
          spapr_machine_##suffix##_class_options(mc);                  \
          if (latest) {                                                \
-            mc->alias = "pseries";                                   \
-            mc->is_default = 1;                                      \
+            spapr_machine_latest_class_options(mc);                  \
          }                                                            \
      }                                                                \
      static const TypeInfo spapr_machine_##suffix##_info = {          \
#5 lore raw
Quoted 30 lines · Greg Kurz
Quoted 18 lines · On Fri, 7 Feb 2020 11:35:47 +0100 Philippe Mathieu-Daudé <[email protected]>…
Quoted 17 lines · Michael S. Tsirkin

We are going to add more init for the latest machine, so move the setup to a function so we don't have to change the DEFINE_SPAPR_MACHINE macro each time.

---
  hw/ppc/spapr.c | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +0 -0
index 02cf53fc5b..4cf2a992a5 100644
@@ -4428,6 +4428,12 @@ static const TypeInfo spapr_machine_info = {
      },
  };
 
Quoted 8 lines

hw/ppc/spapr.c static const TypeInfo spapr_machine_info = { · line 4434

Quoted 4 lines
hw/ppc/spapr.c +4 -0
+static void spapr_machine_latest_class_options(MachineClass *mc)
+{
+    mc->alias = "pseries";
+    mc->is_default = 1;

But we can have only 1 default per QEMU binary... How PPC manage having multiple defaults? The first or last listed is choosen as default?

Quoted 5 lines

IIUC it isn't about putting multiple defaults here. It is about putting any additional init for the default machine type that we cannot put in spapr_machine_class_init(), instead of putting it in the versioned init function, eg. spapr_machine_5_0_class_options(). Otherwise this would force us to carry the change when we add a new machine version.

Maybe it's cleaner to pass the latest flag to spapr_machine_latest_class_options? Rename it spapr_machine_default_class_options? This way we don't need to bother clearing is_default in other
machine types, we'll only set it for the latest one.

Quoted 18 lines
Quoted 18 lines
Quoted 16 lines
hw/ppc/spapr.c +3 -2
+}
+
  #define DEFINE_SPAPR_MACHINE(suffix, verstr, latest)                 \
      static void spapr_machine_##suffix##_class_init(ObjectClass *oc, \
                                                      void *data)      \
@@ -4435,8 +4441,7 @@ static const TypeInfo spapr_machine_info = {
          MachineClass *mc = MACHINE_CLASS(oc);                        \
          spapr_machine_##suffix##_class_options(mc);                  \
          if (latest) {                                                \
-            mc->alias = "pseries";                                   \
-            mc->is_default = 1;                                      \
+            spapr_machine_latest_class_options(mc);                  \
          }                                                            \
      }                                                                \
      static const TypeInfo spapr_machine_##suffix##_info = {          \
Applied
#6 lore raw
In reply to Michael S. Tsirkin
Quoted 5 lines · Michael S. Tsirkin

We are going to add more init for the latest machine, so move the setup to a function so we don't have to change the DEFINE_SPAPR_MACHINE macro each time.

Applied to ppc-for-5.0.

Quoted 31 lines
---
 hw/ppc/spapr.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +7 -2
index 02cf53fc5b..4cf2a992a5 100644
@@ -4428,6 +4428,12 @@ static const TypeInfo spapr_machine_info = {
     },
 };
 
+static void spapr_machine_latest_class_options(MachineClass *mc)
+{
+    mc->alias = "pseries";
+    mc->is_default = 1;
+}
+
 #define DEFINE_SPAPR_MACHINE(suffix, verstr, latest)                 \
     static void spapr_machine_##suffix##_class_init(ObjectClass *oc, \
                                                     void *data)      \
@@ -4435,8 +4441,7 @@ static const TypeInfo spapr_machine_info = {
         MachineClass *mc = MACHINE_CLASS(oc);                        \
         spapr_machine_##suffix##_class_options(mc);                  \
         if (latest) {                                                \
-            mc->alias = "pseries";                                   \
-            mc->is_default = 1;                                      \
+            spapr_machine_latest_class_options(mc);                  \
         }                                                            \
     }                                                                \
     static const TypeInfo spapr_machine_##suffix##_info = {          \
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