Skip to contentSkip to conversation

spapr: Make machine naming conventions closer to those for PC

PATCH In review David Gibson 3 participants 5 messages Aug 13, 2014 – Aug 14, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spapr: Make machine naming conventions closer to those for PC

As of qemu-2.1, spapr/pseries, has a set of versioned machine classes to represent the machine type as it appeared to the guest in different qemu versions. This allows for safe migration of guests between current and future qemu versions.

In PC, however, the default plain "pc" machine type is just an alias for the most recent versioned machine type. In sPAPR at the moment, it names the base machine class from which the versioned types are derived.

The PC approach is preferable; it makes it clearer which explicit version is the current one. Additionally updating the "current" machine as the base class makes it even more likely than otherwise to incorrectly alter the versioned machines' behaviour when updating the current machine.

Therefore this patch changes sPAPR to the PC approach - the base class becomes abstract, and plain "pseries" becomes an alias for the most recent versioned machine class.

---
 hw/ppc/spapr.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +3 -2
index d01978f..2785dbc 100644
@@ -1583,7 +1583,6 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
 
     mc->name = "pseries";
     mc->desc = "pSeries Logical Partition (PAPR compliant)";
-    mc->is_default = 1;
     mc->init = ppc_spapr_init;
     mc->reset = ppc_spapr_reset;
     mc->block_default_type = IF_SCSI;
@@ -1598,6 +1597,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
 static const TypeInfo spapr_machine_info = {
     .name          = TYPE_SPAPR_MACHINE,
     .parent        = TYPE_MACHINE,
+    .abstract      = true,
     .instance_size = sizeof(sPAPRMachineState),
     .instance_init = spapr_machine_initfn,
     .class_init    = spapr_machine_class_init,
@@ -1613,7 +1613,8 @@ static void spapr_machine_2_1_class_init(ObjectClass *oc, void *data)
 
     mc->name = "pseries-2.1";
     mc->desc = "pSeries Logical Partition (PAPR compliant) v2.1";
-    mc->is_default = 0;
+    mc->alias = "pseries";
+    mc->is_default = 1;
 }
 
 static const TypeInfo spapr_machine_2_1_info = {
Signature · 1 line
1.9.3
#1 lore raw
Quoted 28 lines · David Gibson

As of qemu-2.1, spapr/pseries, has a set of versioned machine classes to represent the machine type as it appeared to the guest in different qemu versions. This allows for safe migration of guests between current and future qemu versions.

In PC, however, the default plain "pc" machine type is just an alias for the most recent versioned machine type. In sPAPR at the moment, it names the base machine class from which the versioned types are derived.

The PC approach is preferable; it makes it clearer which explicit version is the current one. Additionally updating the "current" machine as the base class makes it even more likely than otherwise to incorrectly alter the versioned machines' behaviour when updating the current machine.

Therefore this patch changes sPAPR to the PC approach - the base class becomes abstract, and plain "pseries" becomes an alias for the most recent versioned machine class.

---
 hw/ppc/spapr.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +0 -0
index d01978f..2785dbc 100644

hw/ppc/spapr.c static void spapr_machine_class_init(ObjectClass *oc, void *data) · line 1588

Quoted 7 lines
hw/ppc/spapr.c +0 -1
@@ -1583,7 +1583,6 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
 
     mc->name = "pseries";
     mc->desc = "pSeries Logical Partition (PAPR compliant)";
-    mc->is_default = 1;
     mc->init = ppc_spapr_init;
     mc->reset = ppc_spapr_reset;
     mc->block_default_type = IF_SCSI;

I suspect many of these assignments are actually overwritten by the derived machine types' class init function. Without that, mc->name = "pseries" would clash with the mc->alias = "pseries" below, wouldn't i?

Care to trim the redundant assignments?

Quoted 18 lines
hw/ppc/spapr.c +3 -1
@@ -1598,6 +1597,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
 static const TypeInfo spapr_machine_info = {
     .name          = TYPE_SPAPR_MACHINE,
     .parent        = TYPE_MACHINE,
+    .abstract      = true,
     .instance_size = sizeof(sPAPRMachineState),
     .instance_init = spapr_machine_initfn,
     .class_init    = spapr_machine_class_init,
@@ -1613,7 +1613,8 @@ static void spapr_machine_2_1_class_init(ObjectClass *oc, void *data)
 
     mc->name = "pseries-2.1";
     mc->desc = "pSeries Logical Partition (PAPR compliant) v2.1";
-    mc->is_default = 0;
+    mc->alias = "pseries";
+    mc->is_default = 1;
 }
 
 static const TypeInfo spapr_machine_2_1_info = {
#2 lore raw
Quoted 31 lines · Markus Armbruster
Quoted 29 lines · David Gibson

As of qemu-2.1, spapr/pseries, has a set of versioned machine classes to represent the machine type as it appeared to the guest in different qemu versions. This allows for safe migration of guests between current and future qemu versions.

In PC, however, the default plain "pc" machine type is just an alias for the most recent versioned machine type. In sPAPR at the moment, it names the base machine class from which the versioned types are derived.

The PC approach is preferable; it makes it clearer which explicit version is the current one. Additionally updating the "current" machine as the base class makes it even more likely than otherwise to incorrectly alter the versioned machines' behaviour when updating the current machine.

Therefore this patch changes sPAPR to the PC approach - the base class becomes abstract, and plain "pseries" becomes an alias for the most recent versioned machine class.

---
 hw/ppc/spapr.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +0 -0
index d01978f..2785dbc 100644
@@ -1583,7 +1583,6 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
 
Quoted 11 lines

hw/ppc/spapr.c static void spapr_machine_class_init(ObjectClass *oc, void *data) · line 1588

Quoted 6 lines
hw/ppc/spapr.c +0 -1
     mc->name = "pseries";
     mc->desc = "pSeries Logical Partition (PAPR compliant)";
-    mc->is_default = 1;
     mc->init = ppc_spapr_init;
     mc->reset = ppc_spapr_reset;
     mc->block_default_type = IF_SCSI;

I suspect many of these assignments are actually overwritten by the derived machine types' class init function. Without that, mc->name = "pseries" would clash with the mc->alias = "pseries" below, wouldn't i?

Less than you'd think, since there's basically only one derived machine type variant so far.

mc->name does need to change though, I'll rework.

Quoted 21 lines

Care to trim the redundant assignments?

Quoted 18 lines
hw/ppc/spapr.c +3 -1
@@ -1598,6 +1597,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
 static const TypeInfo spapr_machine_info = {
     .name          = TYPE_SPAPR_MACHINE,
     .parent        = TYPE_MACHINE,
+    .abstract      = true,
     .instance_size = sizeof(sPAPRMachineState),
     .instance_init = spapr_machine_initfn,
     .class_init    = spapr_machine_class_init,
@@ -1613,7 +1613,8 @@ static void spapr_machine_2_1_class_init(ObjectClass *oc, void *data)
 
     mc->name = "pseries-2.1";
     mc->desc = "pSeries Logical Partition (PAPR compliant) v2.1";
-    mc->is_default = 0;
+    mc->alias = "pseries";
+    mc->is_default = 1;
 }
 
 static const TypeInfo spapr_machine_2_1_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
#3 lore raw
In reply to David Gibson

Hi,

Am 13.08.2014 03:23, schrieb David Gibson:

Quoted 44 lines

As of qemu-2.1, spapr/pseries, has a set of versioned machine classes to represent the machine type as it appeared to the guest in different qemu versions. This allows for safe migration of guests between current and future qemu versions.

In PC, however, the default plain "pc" machine type is just an alias for the most recent versioned machine type. In sPAPR at the moment, it names the base machine class from which the versioned types are derived.

The PC approach is preferable; it makes it clearer which explicit version is the current one. Additionally updating the "current" machine as the base class makes it even more likely than otherwise to incorrectly alter the versioned machines' behaviour when updating the current machine.

Therefore this patch changes sPAPR to the PC approach - the base class becomes abstract, and plain "pseries" becomes an alias for the most recent versioned machine class.

---
 hw/ppc/spapr.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +1 -1
index d01978f..2785dbc 100644
@@ -1583,7 +1583,6 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
 
     mc->name = "pseries";
     mc->desc = "pSeries Logical Partition (PAPR compliant)";
-    mc->is_default = 1;
     mc->init = ppc_spapr_init;
     mc->reset = ppc_spapr_reset;
     mc->block_default_type = IF_SCSI;
@@ -1598,6 +1597,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
 static const TypeInfo spapr_machine_info = {
     .name          = TYPE_SPAPR_MACHINE,
     .parent        = TYPE_MACHINE,
+    .abstract      = true,
     .instance_size = sizeof(sPAPRMachineState),
     .instance_init = spapr_machine_initfn,
     .class_init    = spapr_machine_class_init,

hw/ppc/spapr.c static void spapr_machine_2_1_class_init(ObjectClass *oc, void *data) · line 1620

Quoted 9 lines
hw/ppc/spapr.c +2 -1
@@ -1613,7 +1613,8 @@ static void spapr_machine_2_1_class_init(ObjectClass *oc, void *data)
 
     mc->name = "pseries-2.1";
     mc->desc = "pSeries Logical Partition (PAPR compliant) v2.1";
-    mc->is_default = 0;
+    mc->alias = "pseries";
+    mc->is_default = 1;
 }
 
 static const TypeInfo spapr_machine_2_1_info = {

This looks wrong to me. With 2.1 released, the default should be a 2.2 machine, not 2.1.

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#4 lore raw
Quoted 55 lines · Andreas Färber

Hi,

Am 13.08.2014 03:23, schrieb David Gibson:

Quoted 52 lines

As of qemu-2.1, spapr/pseries, has a set of versioned machine classes to represent the machine type as it appeared to the guest in different qemu versions. This allows for safe migration of guests between current and future qemu versions.

In PC, however, the default plain "pc" machine type is just an alias for the most recent versioned machine type. In sPAPR at the moment, it names the base machine class from which the versioned types are derived.

The PC approach is preferable; it makes it clearer which explicit version is the current one. Additionally updating the "current" machine as the base class makes it even more likely than otherwise to incorrectly alter the versioned machines' behaviour when updating the current machine.

Therefore this patch changes sPAPR to the PC approach - the base class becomes abstract, and plain "pseries" becomes an alias for the most recent versioned machine class.

---
 hw/ppc/spapr.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +3 -2
index d01978f..2785dbc 100644
@@ -1583,7 +1583,6 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
 
     mc->name = "pseries";
     mc->desc = "pSeries Logical Partition (PAPR compliant)";
-    mc->is_default = 1;
     mc->init = ppc_spapr_init;
     mc->reset = ppc_spapr_reset;
     mc->block_default_type = IF_SCSI;
@@ -1598,6 +1597,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
 static const TypeInfo spapr_machine_info = {
     .name          = TYPE_SPAPR_MACHINE,
     .parent        = TYPE_MACHINE,
+    .abstract      = true,
     .instance_size = sizeof(sPAPRMachineState),
     .instance_init = spapr_machine_initfn,
     .class_init    = spapr_machine_class_init,
@@ -1613,7 +1613,8 @@ static void spapr_machine_2_1_class_init(ObjectClass *oc, void *data)
 
     mc->name = "pseries-2.1";
     mc->desc = "pSeries Logical Partition (PAPR compliant) v2.1";
-    mc->is_default = 0;
+    mc->alias = "pseries";
+    mc->is_default = 1;
 }
 
Quoted 4 lines

hw/ppc/spapr.c static void spapr_machine_2_1_class_init(ObjectClass *oc, void *data) · line 1620

Quoted 1 line
hw/ppc/spapr.c +0 -0
 static const TypeInfo spapr_machine_2_1_info = {

This looks wrong to me. With 2.1 released, the default should be a 2.2 machine, not 2.1.

Ah, yes, I guess so.

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