All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix
@ 2015-08-20 21:54 Eduardo Habkost
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 01/10] machine: MACHINE_TYPE_NAME macro Eduardo Habkost
                   ` (11 more replies)
  0 siblings, 12 replies; 40+ messages in thread
From: Eduardo Habkost @ 2015-08-20 21:54 UTC (permalink / raw)
  To: qemu-devel, Andreas Färber
  Cc: Peter Maydell, Marcel Apfelbaum, Alexander Graf,
	Christian Borntraeger, qemu-ppc, Cornelia Huck,
	Richard Henderson, David Gibson

The machine class names in QEMU are not consistent today. Some of them use the
"-machine" suffix, but some use completely different naming conventions. This
makes it difficult to implement machine class lookup without iterating through
the whole list of machine classes.

This series changes all machines to use "<machine name>-machine" as the class
name, so we can simply use object_class_by_name() in the future to lookup
machine classes. (This was not done yet because it will also require some
changes in the way aliases are handled.)

Cc: Alexander Graf <agraf@suse.de>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-ppc@nongnu.org
Cc: Richard Henderson <rth@twiddle.net>

Eduardo Habkost (10):
  machine: MACHINE_TYPE_NAME macro
  vexpress: Don't set name on abstract class
  vexpress: Rename machine classes to use MACHINE_TYPE_NAME
  arm: Rename virt machine class to use MACHINE_TYPE_NAME
  pseries: Rename machine class names to use MACHINE_TYPE_NAME
  s390-virtio: Rename machine class name to use MACHINE_TYPE_NAME
  s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME
  mac99: Use MACHINE_TYPE_NAME to encode class name
  machine: Ensure all TYPE_MACHINE subclasses have the right suffix
  machine: Set MachineClass::name automatically

 hw/arm/vexpress.c          |  7 ++-----
 hw/arm/virt.c              |  4 ++--
 hw/core/machine.c          | 12 ++++++++++++
 hw/ppc/mac_newworld.c      |  3 +--
 hw/ppc/spapr.c             | 12 ++++--------
 hw/s390x/s390-virtio-ccw.c |  2 +-
 hw/s390x/s390-virtio.c     |  4 ++--
 include/hw/boards.h        |  6 ++++++
 vl.c                       |  3 +--
 9 files changed, 31 insertions(+), 22 deletions(-)

-- 
2.1.0

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [Qemu-devel] [PATCH 01/10] machine: MACHINE_TYPE_NAME macro
  2015-08-20 21:54 [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix Eduardo Habkost
@ 2015-08-20 21:54 ` Eduardo Habkost
  2015-08-25  8:53   ` Marcel Apfelbaum
  2015-08-30  5:59   ` David Gibson
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 02/10] vexpress: Don't set name on abstract class Eduardo Habkost
                   ` (10 subsequent siblings)
  11 siblings, 2 replies; 40+ messages in thread
From: Eduardo Habkost @ 2015-08-20 21:54 UTC (permalink / raw)
  To: qemu-devel, Andreas Färber; +Cc: Marcel Apfelbaum, David Gibson

The macro will be useful to ensure the machine class names follow the
right format to make machine class lookup by class name work correctly.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 include/hw/boards.h | 6 ++++++
 vl.c                | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/hw/boards.h b/include/hw/boards.h
index 3f84afd..178517c 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -40,6 +40,12 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
 int qemu_register_machine(QEMUMachine *m);
 
 #define TYPE_MACHINE_SUFFIX "-machine"
+
+/* Machine class name that needs to be used for class-name-based machine
+ * type lookup to work.
+ */
+#define MACHINE_TYPE_NAME(machinename) (machinename TYPE_MACHINE_SUFFIX)
+
 #define TYPE_MACHINE "machine"
 #undef MACHINE  /* BSD defines it and QEMU does not use it */
 #define MACHINE(obj) \
diff --git a/vl.c b/vl.c
index 584ca88..b7ddfeb 100644
--- a/vl.c
+++ b/vl.c
@@ -1447,7 +1447,7 @@ static void qemu_machine_class_init(ObjectClass *oc, void *data)
 
 int qemu_register_machine(QEMUMachine *m)
 {
-    char *name = g_strconcat(m->name, TYPE_MACHINE_SUFFIX, NULL);
+    char *name = g_strdup_printf(MACHINE_TYPE_NAME("%s"), m->name);
     TypeInfo ti = {
         .name       = name,
         .parent     = TYPE_MACHINE,
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [Qemu-devel] [PATCH 02/10] vexpress: Don't set name on abstract class
  2015-08-20 21:54 [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix Eduardo Habkost
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 01/10] machine: MACHINE_TYPE_NAME macro Eduardo Habkost
@ 2015-08-20 21:54 ` Eduardo Habkost
  2015-08-30  6:42   ` David Gibson
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 03/10] vexpress: Rename machine classes to use MACHINE_TYPE_NAME Eduardo Habkost
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 40+ messages in thread
From: Eduardo Habkost @ 2015-08-20 21:54 UTC (permalink / raw)
  To: qemu-devel, Andreas Färber
  Cc: Peter Maydell, Marcel Apfelbaum, David Gibson

The MachineClass::name field won't be ever be used on TYPE_VEXPRESS, as
it is an abstract class and the machine class lookup code explicitly
skips abstract classes. We can remove it to make the code simpler.

Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/arm/vexpress.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index da21788..15e4ae9 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -747,7 +747,6 @@ static void vexpress_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
-    mc->name = TYPE_VEXPRESS_MACHINE;
     mc->desc = "ARM Versatile Express";
     mc->init = vexpress_common_init;
     mc->block_default_type = IF_SCSI;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [Qemu-devel] [PATCH 03/10] vexpress: Rename machine classes to use MACHINE_TYPE_NAME
  2015-08-20 21:54 [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix Eduardo Habkost
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 01/10] machine: MACHINE_TYPE_NAME macro Eduardo Habkost
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 02/10] vexpress: Don't set name on abstract class Eduardo Habkost
@ 2015-08-20 21:54 ` Eduardo Habkost
  2015-08-30  6:43   ` David Gibson
  2015-09-19  6:30   ` Andreas Färber
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 04/10] arm: Rename virt machine class " Eduardo Habkost
                   ` (8 subsequent siblings)
  11 siblings, 2 replies; 40+ messages in thread
From: Eduardo Habkost @ 2015-08-20 21:54 UTC (permalink / raw)
  To: qemu-devel, Andreas Färber
  Cc: Peter Maydell, Marcel Apfelbaum, David Gibson

Machine class names should use the "-machine" suffix to allow
class-name-based machine class lookup to work. Rename the vexpress
machine classes using the MACHINE_TYPE_NAME macro.

Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/arm/vexpress.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index 15e4ae9..a86979d 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -168,8 +168,8 @@ typedef struct {
 } VexpressMachineState;
 
 #define TYPE_VEXPRESS_MACHINE   "vexpress"
-#define TYPE_VEXPRESS_A9_MACHINE   "vexpress-a9"
-#define TYPE_VEXPRESS_A15_MACHINE   "vexpress-a15"
+#define TYPE_VEXPRESS_A9_MACHINE   MACHINE_TYPE_NAME("vexpress-a9")
+#define TYPE_VEXPRESS_A15_MACHINE   MACHINE_TYPE_NAME("vexpress-a15")
 #define VEXPRESS_MACHINE(obj) \
     OBJECT_CHECK(VexpressMachineState, (obj), TYPE_VEXPRESS_MACHINE)
 #define VEXPRESS_MACHINE_GET_CLASS(obj) \
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [Qemu-devel] [PATCH 04/10] arm: Rename virt machine class to use MACHINE_TYPE_NAME
  2015-08-20 21:54 [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix Eduardo Habkost
                   ` (2 preceding siblings ...)
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 03/10] vexpress: Rename machine classes to use MACHINE_TYPE_NAME Eduardo Habkost
@ 2015-08-20 21:54 ` Eduardo Habkost
  2015-08-30  6:43   ` David Gibson
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 05/10] pseries: Rename machine class names " Eduardo Habkost
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 40+ messages in thread
From: Eduardo Habkost @ 2015-08-20 21:54 UTC (permalink / raw)
  To: qemu-devel, Andreas Färber
  Cc: Peter Maydell, Marcel Apfelbaum, David Gibson

Machine class names should use the "-machine" suffix to allow
class-name-based machine class lookup to work. Rename the arm virt
machine class using the MACHINE_TYPE_NAME macro.

Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/arm/virt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index d5a8417..5ba4b80 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -81,7 +81,8 @@ typedef struct {
     bool secure;
 } VirtMachineState;
 
-#define TYPE_VIRT_MACHINE   "virt"
+#define VIRT_MACHINE_NAME   "virt"
+#define TYPE_VIRT_MACHINE   MACHINE_TYPE_NAME(VIRT_MACHINE_NAME)
 #define VIRT_MACHINE(obj) \
     OBJECT_CHECK(VirtMachineState, (obj), TYPE_VIRT_MACHINE)
 #define VIRT_MACHINE_GET_CLASS(obj) \
@@ -959,7 +960,7 @@ static void virt_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
-    mc->name = TYPE_VIRT_MACHINE;
+    mc->name = VIRT_MACHINE_NAME;
     mc->desc = "ARM Virtual Machine",
     mc->init = machvirt_init;
     mc->max_cpus = 8;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [Qemu-devel] [PATCH 05/10] pseries: Rename machine class names to use MACHINE_TYPE_NAME
  2015-08-20 21:54 [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix Eduardo Habkost
                   ` (3 preceding siblings ...)
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 04/10] arm: Rename virt machine class " Eduardo Habkost
@ 2015-08-20 21:54 ` Eduardo Habkost
  2015-08-30  6:45   ` David Gibson
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 06/10] s390-virtio: Rename machine class name " Eduardo Habkost
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 40+ messages in thread
From: Eduardo Habkost @ 2015-08-20 21:54 UTC (permalink / raw)
  To: qemu-devel, Andreas Färber
  Cc: Marcel Apfelbaum, qemu-ppc, Alexander Graf, David Gibson

Machine class names should use the "-machine" suffix to allow
class-name-based machine class lookup to work. Rename the the pseries
machine classes using the MACHINE_TYPE_NAME macro.

Cc: Alexander Graf <agraf@suse.de>
Cc: qemu-ppc@nongnu.org
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/ppc/spapr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index bf0c64f..012b6ed 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1925,7 +1925,7 @@ static void spapr_machine_2_1_class_init(ObjectClass *oc, void *data)
 }
 
 static const TypeInfo spapr_machine_2_1_info = {
-    .name          = TYPE_SPAPR_MACHINE "2.1",
+    .name          = MACHINE_TYPE_NAME("pseries-2.1"),
     .parent        = TYPE_SPAPR_MACHINE,
     .class_init    = spapr_machine_2_1_class_init,
     .instance_init = spapr_machine_2_1_instance_init,
@@ -1945,7 +1945,7 @@ static void spapr_machine_2_2_class_init(ObjectClass *oc, void *data)
 }
 
 static const TypeInfo spapr_machine_2_2_info = {
-    .name          = TYPE_SPAPR_MACHINE "2.2",
+    .name          = MACHINE_TYPE_NAME("pseries-2.2"),
     .parent        = TYPE_SPAPR_MACHINE,
     .class_init    = spapr_machine_2_2_class_init,
     .instance_init = spapr_machine_2_2_instance_init,
@@ -1965,7 +1965,7 @@ static void spapr_machine_2_3_class_init(ObjectClass *oc, void *data)
 }
 
 static const TypeInfo spapr_machine_2_3_info = {
-    .name          = TYPE_SPAPR_MACHINE "2.3",
+    .name          = MACHINE_TYPE_NAME("pseries-2.3"),
     .parent        = TYPE_SPAPR_MACHINE,
     .class_init    = spapr_machine_2_3_class_init,
     .instance_init = spapr_machine_2_3_instance_init,
@@ -1982,7 +1982,7 @@ static void spapr_machine_2_4_class_init(ObjectClass *oc, void *data)
 }
 
 static const TypeInfo spapr_machine_2_4_info = {
-    .name          = TYPE_SPAPR_MACHINE "2.4",
+    .name          = MACHINE_TYPE_NAME("pseries-2.4"),
     .parent        = TYPE_SPAPR_MACHINE,
     .class_init    = spapr_machine_2_4_class_init,
 };
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [Qemu-devel] [PATCH 06/10] s390-virtio: Rename machine class name to use MACHINE_TYPE_NAME
  2015-08-20 21:54 [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix Eduardo Habkost
                   ` (4 preceding siblings ...)
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 05/10] pseries: Rename machine class names " Eduardo Habkost
@ 2015-08-20 21:54 ` Eduardo Habkost
  2015-08-30  6:46   ` David Gibson
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 07/10] s390: Rename s390-ccw-virtio-2.4 " Eduardo Habkost
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 40+ messages in thread
From: Eduardo Habkost @ 2015-08-20 21:54 UTC (permalink / raw)
  To: qemu-devel, Andreas Färber
  Cc: Richard Henderson, Marcel Apfelbaum, Alexander Graf, David Gibson

Machine class names should use the "-machine" suffix to allow
class-name-based machine class lookup to work. Rename the s390-virtio
machine class using the MACHINE_TYPE_NAME macro.

Cc: Alexander Graf <agraf@suse.de>
Cc: Richard Henderson <rth@twiddle.net>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/s390x/s390-virtio.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index 1284e77..43d6ccb 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -52,7 +52,8 @@
 
 #define MAX_BLK_DEVS                    10
 #define ZIPL_FILENAME                   "s390-zipl.rom"
-#define TYPE_S390_MACHINE               "s390-machine"
+#define S390_MACHINE                    "s390-virtio"
+#define TYPE_S390_MACHINE               MACHINE_TYPE_NAME(S390_MACHINE)
 
 #define S390_TOD_CLOCK_VALUE_MISSING    0x00
 #define S390_TOD_CLOCK_VALUE_PRESENT    0x01
@@ -333,7 +334,7 @@ static void s390_machine_class_init(ObjectClass *oc, void *data)
     MachineClass *mc = MACHINE_CLASS(oc);
     NMIClass *nc = NMI_CLASS(oc);
 
-    mc->name = "s390-virtio";
+    mc->name = S390_MACHINE;
     mc->alias = "s390";
     mc->desc = "VirtIO based S390 machine";
     mc->init = s390_init;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [Qemu-devel] [PATCH 07/10] s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME
  2015-08-20 21:54 [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix Eduardo Habkost
                   ` (5 preceding siblings ...)
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 06/10] s390-virtio: Rename machine class name " Eduardo Habkost
@ 2015-08-20 21:54 ` Eduardo Habkost
  2015-08-30  6:46   ` David Gibson
  2015-09-04  8:52   ` Christian Borntraeger
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 08/10] mac99: Use MACHINE_TYPE_NAME to encode class name Eduardo Habkost
                   ` (4 subsequent siblings)
  11 siblings, 2 replies; 40+ messages in thread
From: Eduardo Habkost @ 2015-08-20 21:54 UTC (permalink / raw)
  To: qemu-devel, Andreas Färber
  Cc: Marcel Apfelbaum, Alexander Graf, Christian Borntraeger,
	Cornelia Huck, David Gibson, Richard Henderson

Machine class names should use the "-machine" suffix to allow
class-name-based machine class lookup to work. Rename the
s390-ccw-virtio-2.4 machine class using the MACHINE_TYPE_NAME macro.

Cc: Alexander Graf <agraf@suse.de>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Richard Henderson <rth@twiddle.net>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/s390x/s390-virtio-ccw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 4c51d1a..66e1478 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -293,7 +293,7 @@ static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data)
 }
 
 static const TypeInfo ccw_machine_2_4_info = {
-    .name          = TYPE_S390_CCW_MACHINE "2.4",
+    .name          = MACHINE_TYPE_NAME("s390-ccw-virtio-2.4"),
     .parent        = TYPE_S390_CCW_MACHINE,
     .class_init    = ccw_machine_2_4_class_init,
 };
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [Qemu-devel] [PATCH 08/10] mac99: Use MACHINE_TYPE_NAME to encode class name
  2015-08-20 21:54 [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix Eduardo Habkost
                   ` (6 preceding siblings ...)
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 07/10] s390: Rename s390-ccw-virtio-2.4 " Eduardo Habkost
@ 2015-08-20 21:54 ` Eduardo Habkost
  2015-08-30  6:46   ` David Gibson
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 09/10] machine: Ensure all TYPE_MACHINE subclasses have the right suffix Eduardo Habkost
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 40+ messages in thread
From: Eduardo Habkost @ 2015-08-20 21:54 UTC (permalink / raw)
  To: qemu-devel, Andreas Färber
  Cc: Marcel Apfelbaum, qemu-ppc, Alexander Graf, David Gibson

It will result in exactly the same class name, but it will make the code
consistent with the other classes.

Cc: Alexander Graf <agraf@suse.de>
Cc: qemu-ppc@nongnu.org
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/ppc/mac_newworld.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index 77d5c81..a6b8209 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -517,7 +517,7 @@ static void core99_machine_class_init(ObjectClass *oc, void *data)
 }
 
 static const TypeInfo core99_machine_info = {
-    .name          = "mac99-machine",
+    .name          = MACHINE_TYPE_NAME("mac99"),
     .parent        = TYPE_MACHINE,
     .class_init    = core99_machine_class_init,
 };
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [Qemu-devel] [PATCH 09/10] machine: Ensure all TYPE_MACHINE subclasses have the right suffix
  2015-08-20 21:54 [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix Eduardo Habkost
                   ` (7 preceding siblings ...)
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 08/10] mac99: Use MACHINE_TYPE_NAME to encode class name Eduardo Habkost
@ 2015-08-20 21:54 ` Eduardo Habkost
  2015-08-25  8:53   ` Marcel Apfelbaum
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 10/10] machine: Set MachineClass::name automatically Eduardo Habkost
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 40+ messages in thread
From: Eduardo Habkost @ 2015-08-20 21:54 UTC (permalink / raw)
  To: qemu-devel, Andreas Färber; +Cc: Marcel Apfelbaum, David Gibson

Now that all non-abstract TYPE_MACHINE subclasses have the -machine
suffix, add an assert to ensure this will be always true.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/core/machine.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index ac4654e..e50c4b7 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -302,6 +302,14 @@ static void machine_class_init(ObjectClass *oc, void *data)
     mc->default_ram_size = 128 * M_BYTE;
 }
 
+static void machine_class_base_init(ObjectClass *oc, void *data)
+{
+    if (!object_class_is_abstract(oc)) {
+        const char *cname = object_class_get_name(oc);
+        assert(g_str_has_suffix(cname, TYPE_MACHINE_SUFFIX));
+    }
+}
+
 static void machine_initfn(Object *obj)
 {
     MachineState *ms = MACHINE(obj);
@@ -472,6 +480,7 @@ static const TypeInfo machine_info = {
     .abstract = true,
     .class_size = sizeof(MachineClass),
     .class_init    = machine_class_init,
+    .class_base_init = machine_class_base_init,
     .instance_size = sizeof(MachineState),
     .instance_init = machine_initfn,
     .instance_finalize = machine_finalize,
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [Qemu-devel] [PATCH 10/10] machine: Set MachineClass::name automatically
  2015-08-20 21:54 [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix Eduardo Habkost
                   ` (8 preceding siblings ...)
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 09/10] machine: Ensure all TYPE_MACHINE subclasses have the right suffix Eduardo Habkost
@ 2015-08-20 21:54 ` Eduardo Habkost
  2015-08-25  8:50   ` Marcel Apfelbaum
                     ` (2 more replies)
  2015-08-21 10:23 ` [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix Cornelia Huck
  2015-09-02 19:58 ` Eduardo Habkost
  11 siblings, 3 replies; 40+ messages in thread
From: Eduardo Habkost @ 2015-08-20 21:54 UTC (permalink / raw)
  To: qemu-devel, Andreas Färber; +Cc: Marcel Apfelbaum, David Gibson

Now all TYPE_MACHINE subclasses use MACHINE_TYPE_NAME to generate the
class name. So instead of requiring each subclass to set
MachineClass::name manually, we can now set it automatically at the
TYPE_MACHINE class_base_init() function.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/arm/vexpress.c      | 2 --
 hw/arm/virt.c          | 1 -
 hw/core/machine.c      | 3 +++
 hw/ppc/mac_newworld.c  | 1 -
 hw/ppc/spapr.c         | 4 ----
 hw/s390x/s390-virtio.c | 1 -
 vl.c                   | 1 -
 7 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index a86979d..55aed2b 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -758,7 +758,6 @@ static void vexpress_a9_class_init(ObjectClass *oc, void *data)
     MachineClass *mc = MACHINE_CLASS(oc);
     VexpressMachineClass *vmc = VEXPRESS_MACHINE_CLASS(oc);
 
-    mc->name = TYPE_VEXPRESS_A9_MACHINE;
     mc->desc = "ARM Versatile Express for Cortex-A9";
 
     vmc->daughterboard = &a9_daughterboard;;
@@ -769,7 +768,6 @@ static void vexpress_a15_class_init(ObjectClass *oc, void *data)
     MachineClass *mc = MACHINE_CLASS(oc);
     VexpressMachineClass *vmc = VEXPRESS_MACHINE_CLASS(oc);
 
-    mc->name = TYPE_VEXPRESS_A15_MACHINE;
     mc->desc = "ARM Versatile Express for Cortex-A15";
 
     vmc->daughterboard = &a15_daughterboard;
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 5ba4b80..af985f6 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -960,7 +960,6 @@ static void virt_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
-    mc->name = VIRT_MACHINE_NAME;
     mc->desc = "ARM Virtual Machine",
     mc->init = machvirt_init;
     mc->max_cpus = 8;
diff --git a/hw/core/machine.c b/hw/core/machine.c
index e50c4b7..a889d7a 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -305,8 +305,11 @@ static void machine_class_init(ObjectClass *oc, void *data)
 static void machine_class_base_init(ObjectClass *oc, void *data)
 {
     if (!object_class_is_abstract(oc)) {
+        MachineClass *mc = MACHINE_CLASS(oc);
         const char *cname = object_class_get_name(oc);
         assert(g_str_has_suffix(cname, TYPE_MACHINE_SUFFIX));
+        mc->name = g_strndup(cname,
+                            strlen(cname) - strlen(TYPE_MACHINE_SUFFIX));
     }
 }
 
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index a6b8209..70e7431 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -508,7 +508,6 @@ static void core99_machine_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
-    mc->name = "mac99";
     mc->desc = "Mac99 based PowerMAC";
     mc->init = ppc_core99_init;
     mc->max_cpus = MAX_CPUS;
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 012b6ed..05926a3 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1919,7 +1919,6 @@ static void spapr_machine_2_1_class_init(ObjectClass *oc, void *data)
         { /* end of list */ }
     };
 
-    mc->name = "pseries-2.1";
     mc->desc = "pSeries Logical Partition (PAPR compliant) v2.1";
     mc->compat_props = compat_props;
 }
@@ -1939,7 +1938,6 @@ static void spapr_machine_2_2_class_init(ObjectClass *oc, void *data)
     };
     MachineClass *mc = MACHINE_CLASS(oc);
 
-    mc->name = "pseries-2.2";
     mc->desc = "pSeries Logical Partition (PAPR compliant) v2.2";
     mc->compat_props = compat_props;
 }
@@ -1959,7 +1957,6 @@ static void spapr_machine_2_3_class_init(ObjectClass *oc, void *data)
     };
     MachineClass *mc = MACHINE_CLASS(oc);
 
-    mc->name = "pseries-2.3";
     mc->desc = "pSeries Logical Partition (PAPR compliant) v2.3";
     mc->compat_props = compat_props;
 }
@@ -1975,7 +1972,6 @@ static void spapr_machine_2_4_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
-    mc->name = "pseries-2.4";
     mc->desc = "pSeries Logical Partition (PAPR compliant) v2.4";
     mc->alias = "pseries";
     mc->is_default = 1;
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index 43d6ccb..35c0ce2 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -334,7 +334,6 @@ static void s390_machine_class_init(ObjectClass *oc, void *data)
     MachineClass *mc = MACHINE_CLASS(oc);
     NMIClass *nc = NMI_CLASS(oc);
 
-    mc->name = S390_MACHINE;
     mc->alias = "s390";
     mc->desc = "VirtIO based S390 machine";
     mc->init = s390_init;
diff --git a/vl.c b/vl.c
index b7ddfeb..870ee48 100644
--- a/vl.c
+++ b/vl.c
@@ -1432,7 +1432,6 @@ static void qemu_machine_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
     QEMUMachine *qm = data;
-    mc->name = qm->name;
     mc->desc = qm->desc;
     mc->init = qm->init;
     mc->kvm_type = qm->kvm_type;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix
  2015-08-20 21:54 [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix Eduardo Habkost
                   ` (9 preceding siblings ...)
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 10/10] machine: Set MachineClass::name automatically Eduardo Habkost
@ 2015-08-21 10:23 ` Cornelia Huck
  2015-08-21 15:44   ` Eduardo Habkost
  2015-09-02 19:58 ` Eduardo Habkost
  11 siblings, 1 reply; 40+ messages in thread
From: Cornelia Huck @ 2015-08-21 10:23 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Peter Maydell, Marcel Apfelbaum, Alexander Graf, qemu-devel,
	Christian Borntraeger, qemu-ppc, Richard Henderson,
	Andreas Färber, David Gibson

On Thu, 20 Aug 2015 14:54:26 -0700
Eduardo Habkost <ehabkost@redhat.com> wrote:

> The machine class names in QEMU are not consistent today. Some of them use the
> "-machine" suffix, but some use completely different naming conventions. This
> makes it difficult to implement machine class lookup without iterating through
> the whole list of machine classes.
> 
> This series changes all machines to use "<machine name>-machine" as the class
> name, so we can simply use object_class_by_name() in the future to lookup
> machine classes. (This was not done yet because it will also require some
> changes in the way aliases are handled.)

I've played around with the s390 machines a bit and it seems to do the
right thing using the same commandlines as before.

One question: info qom-tree shows the new machine class names - is
there anybody (other than a human looking at it) making use of that
information?

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix
  2015-08-21 10:23 ` [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix Cornelia Huck
@ 2015-08-21 15:44   ` Eduardo Habkost
  0 siblings, 0 replies; 40+ messages in thread
From: Eduardo Habkost @ 2015-08-21 15:44 UTC (permalink / raw)
  To: Cornelia Huck
  Cc: Peter Maydell, Marcel Apfelbaum, Alexander Graf, qemu-devel,
	Christian Borntraeger, qemu-ppc, Richard Henderson,
	Andreas Färber, David Gibson

On Fri, Aug 21, 2015 at 12:23:01PM +0200, Cornelia Huck wrote:
> On Thu, 20 Aug 2015 14:54:26 -0700
> Eduardo Habkost <ehabkost@redhat.com> wrote:
> 
> > The machine class names in QEMU are not consistent today. Some of them use the
> > "-machine" suffix, but some use completely different naming conventions. This
> > makes it difficult to implement machine class lookup without iterating through
> > the whole list of machine classes.
> > 
> > This series changes all machines to use "<machine name>-machine" as the class
> > name, so we can simply use object_class_by_name() in the future to lookup
> > machine classes. (This was not done yet because it will also require some
> > changes in the way aliases are handled.)
> 
> I've played around with the s390 machines a bit and it seems to do the
> right thing using the same commandlines as before.
> 
> One question: info qom-tree shows the new machine class names - is
> there anybody (other than a human looking at it) making use of that
> information?

I don't believe anybody is using it. It would be possible to use the
class name for something useful if machines were user-creatable objects,
but they aren't.

-- 
Eduardo

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 10/10] machine: Set MachineClass::name automatically
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 10/10] machine: Set MachineClass::name automatically Eduardo Habkost
@ 2015-08-25  8:50   ` Marcel Apfelbaum
  2015-08-26 15:02     ` Eduardo Habkost
  2015-09-04 15:46   ` Eduardo Habkost
  2015-09-19  6:23   ` Andreas Färber
  2 siblings, 1 reply; 40+ messages in thread
From: Marcel Apfelbaum @ 2015-08-25  8:50 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel, Andreas Färber
  Cc: Marcel Apfelbaum, David Gibson

On 08/21/2015 12:54 AM, Eduardo Habkost wrote:
> Now all TYPE_MACHINE subclasses use MACHINE_TYPE_NAME to generate the
> class name. So instead of requiring each subclass to set
> MachineClass::name manually, we can now set it automatically at the
> TYPE_MACHINE class_base_init() function.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>   hw/arm/vexpress.c      | 2 --
>   hw/arm/virt.c          | 1 -
>   hw/core/machine.c      | 3 +++
>   hw/ppc/mac_newworld.c  | 1 -
>   hw/ppc/spapr.c         | 4 ----
>   hw/s390x/s390-virtio.c | 1 -
>   vl.c                   | 1 -
>   7 files changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
> index a86979d..55aed2b 100644
> --- a/hw/arm/vexpress.c
> +++ b/hw/arm/vexpress.c
> @@ -758,7 +758,6 @@ static void vexpress_a9_class_init(ObjectClass *oc, void *data)
>       MachineClass *mc = MACHINE_CLASS(oc);
>       VexpressMachineClass *vmc = VEXPRESS_MACHINE_CLASS(oc);
>
> -    mc->name = TYPE_VEXPRESS_A9_MACHINE;
>       mc->desc = "ARM Versatile Express for Cortex-A9";
>
>       vmc->daughterboard = &a9_daughterboard;;
> @@ -769,7 +768,6 @@ static void vexpress_a15_class_init(ObjectClass *oc, void *data)
>       MachineClass *mc = MACHINE_CLASS(oc);
>       VexpressMachineClass *vmc = VEXPRESS_MACHINE_CLASS(oc);
>
> -    mc->name = TYPE_VEXPRESS_A15_MACHINE;
>       mc->desc = "ARM Versatile Express for Cortex-A15";
>
>       vmc->daughterboard = &a15_daughterboard;
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 5ba4b80..af985f6 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -960,7 +960,6 @@ static void virt_class_init(ObjectClass *oc, void *data)
>   {
>       MachineClass *mc = MACHINE_CLASS(oc);
>
> -    mc->name = VIRT_MACHINE_NAME;
>       mc->desc = "ARM Virtual Machine",
>       mc->init = machvirt_init;
>       mc->max_cpus = 8;
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index e50c4b7..a889d7a 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -305,8 +305,11 @@ static void machine_class_init(ObjectClass *oc, void *data)
>   static void machine_class_base_init(ObjectClass *oc, void *data)
>   {
>       if (!object_class_is_abstract(oc)) {
> +        MachineClass *mc = MACHINE_CLASS(oc);
>           const char *cname = object_class_get_name(oc);
>           assert(g_str_has_suffix(cname, TYPE_MACHINE_SUFFIX));
> +        mc->name = g_strndup(cname,
> +                            strlen(cname) - strlen(TYPE_MACHINE_SUFFIX));
>       }
>   }
>
> diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
> index a6b8209..70e7431 100644
> --- a/hw/ppc/mac_newworld.c
> +++ b/hw/ppc/mac_newworld.c
> @@ -508,7 +508,6 @@ static void core99_machine_class_init(ObjectClass *oc, void *data)
>   {
>       MachineClass *mc = MACHINE_CLASS(oc);
>
> -    mc->name = "mac99";
>       mc->desc = "Mac99 based PowerMAC";
>       mc->init = ppc_core99_init;
>       mc->max_cpus = MAX_CPUS;
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 012b6ed..05926a3 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1919,7 +1919,6 @@ static void spapr_machine_2_1_class_init(ObjectClass *oc, void *data)
>           { /* end of list */ }
>       };
>
> -    mc->name = "pseries-2.1";
>       mc->desc = "pSeries Logical Partition (PAPR compliant) v2.1";
>       mc->compat_props = compat_props;
>   }
> @@ -1939,7 +1938,6 @@ static void spapr_machine_2_2_class_init(ObjectClass *oc, void *data)
>       };
>       MachineClass *mc = MACHINE_CLASS(oc);
>
> -    mc->name = "pseries-2.2";
>       mc->desc = "pSeries Logical Partition (PAPR compliant) v2.2";
>       mc->compat_props = compat_props;
>   }
> @@ -1959,7 +1957,6 @@ static void spapr_machine_2_3_class_init(ObjectClass *oc, void *data)
>       };
>       MachineClass *mc = MACHINE_CLASS(oc);
>
> -    mc->name = "pseries-2.3";
>       mc->desc = "pSeries Logical Partition (PAPR compliant) v2.3";
>       mc->compat_props = compat_props;
>   }
> @@ -1975,7 +1972,6 @@ static void spapr_machine_2_4_class_init(ObjectClass *oc, void *data)
>   {
>       MachineClass *mc = MACHINE_CLASS(oc);
>
> -    mc->name = "pseries-2.4";
>       mc->desc = "pSeries Logical Partition (PAPR compliant) v2.4";
>       mc->alias = "pseries";
>       mc->is_default = 1;
> diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
> index 43d6ccb..35c0ce2 100644
> --- a/hw/s390x/s390-virtio.c
> +++ b/hw/s390x/s390-virtio.c
> @@ -334,7 +334,6 @@ static void s390_machine_class_init(ObjectClass *oc, void *data)
>       MachineClass *mc = MACHINE_CLASS(oc);
>       NMIClass *nc = NMI_CLASS(oc);
>
> -    mc->name = S390_MACHINE;
>       mc->alias = "s390";
>       mc->desc = "VirtIO based S390 machine";
>       mc->init = s390_init;
> diff --git a/vl.c b/vl.c
> index b7ddfeb..870ee48 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1432,7 +1432,6 @@ static void qemu_machine_class_init(ObjectClass *oc, void *data)
>   {
>       MachineClass *mc = MACHINE_CLASS(oc);
>       QEMUMachine *qm = data;
> -    mc->name = qm->name;
>       mc->desc = qm->desc;
>       mc->init = qm->init;
>       mc->kvm_type = qm->kvm_type;
>

Nice!

Please forget the possible stupid question, but what happens with
*all* other machine types? Why don't we have to remove the "name"
assignment from the other machine types too?

Thanks,
Marcel

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 01/10] machine: MACHINE_TYPE_NAME macro
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 01/10] machine: MACHINE_TYPE_NAME macro Eduardo Habkost
@ 2015-08-25  8:53   ` Marcel Apfelbaum
  2015-08-30  5:59   ` David Gibson
  1 sibling, 0 replies; 40+ messages in thread
From: Marcel Apfelbaum @ 2015-08-25  8:53 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel, Andreas Färber
  Cc: Marcel Apfelbaum, David Gibson

On 08/21/2015 12:54 AM, Eduardo Habkost wrote:
> The macro will be useful to ensure the machine class names follow the
> right format to make machine class lookup by class name work correctly.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>   include/hw/boards.h | 6 ++++++
>   vl.c                | 2 +-
>   2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/include/hw/boards.h b/include/hw/boards.h
> index 3f84afd..178517c 100644
> --- a/include/hw/boards.h
> +++ b/include/hw/boards.h
> @@ -40,6 +40,12 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
>   int qemu_register_machine(QEMUMachine *m);
>
>   #define TYPE_MACHINE_SUFFIX "-machine"
> +
> +/* Machine class name that needs to be used for class-name-based machine
> + * type lookup to work.
> + */
> +#define MACHINE_TYPE_NAME(machinename) (machinename TYPE_MACHINE_SUFFIX)
> +
>   #define TYPE_MACHINE "machine"
>   #undef MACHINE  /* BSD defines it and QEMU does not use it */
>   #define MACHINE(obj) \
> diff --git a/vl.c b/vl.c
> index 584ca88..b7ddfeb 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1447,7 +1447,7 @@ static void qemu_machine_class_init(ObjectClass *oc, void *data)
>
>   int qemu_register_machine(QEMUMachine *m)
>   {
> -    char *name = g_strconcat(m->name, TYPE_MACHINE_SUFFIX, NULL);
> +    char *name = g_strdup_printf(MACHINE_TYPE_NAME("%s"), m->name);
>       TypeInfo ti = {
>           .name       = name,
>           .parent     = TYPE_MACHINE,
>

Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>

Thanks,
Marcel

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 09/10] machine: Ensure all TYPE_MACHINE subclasses have the right suffix
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 09/10] machine: Ensure all TYPE_MACHINE subclasses have the right suffix Eduardo Habkost
@ 2015-08-25  8:53   ` Marcel Apfelbaum
  0 siblings, 0 replies; 40+ messages in thread
From: Marcel Apfelbaum @ 2015-08-25  8:53 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel, Andreas Färber
  Cc: Marcel Apfelbaum, David Gibson

On 08/21/2015 12:54 AM, Eduardo Habkost wrote:
> Now that all non-abstract TYPE_MACHINE subclasses have the -machine
> suffix, add an assert to ensure this will be always true.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>   hw/core/machine.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
>
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index ac4654e..e50c4b7 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -302,6 +302,14 @@ static void machine_class_init(ObjectClass *oc, void *data)
>       mc->default_ram_size = 128 * M_BYTE;
>   }
>
> +static void machine_class_base_init(ObjectClass *oc, void *data)
> +{
> +    if (!object_class_is_abstract(oc)) {
> +        const char *cname = object_class_get_name(oc);
> +        assert(g_str_has_suffix(cname, TYPE_MACHINE_SUFFIX));
> +    }
> +}
> +
>   static void machine_initfn(Object *obj)
>   {
>       MachineState *ms = MACHINE(obj);
> @@ -472,6 +480,7 @@ static const TypeInfo machine_info = {
>       .abstract = true,
>       .class_size = sizeof(MachineClass),
>       .class_init    = machine_class_init,
> +    .class_base_init = machine_class_base_init,
>       .instance_size = sizeof(MachineState),
>       .instance_init = machine_initfn,
>       .instance_finalize = machine_finalize,
>

Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>

Thanks,
Marcel

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 10/10] machine: Set MachineClass::name automatically
  2015-08-25  8:50   ` Marcel Apfelbaum
@ 2015-08-26 15:02     ` Eduardo Habkost
  2015-08-26 16:13       ` Marcel Apfelbaum
  0 siblings, 1 reply; 40+ messages in thread
From: Eduardo Habkost @ 2015-08-26 15:02 UTC (permalink / raw)
  To: Marcel Apfelbaum
  Cc: Marcel Apfelbaum, David Gibson, qemu-devel, Andreas Färber

On Tue, Aug 25, 2015 at 11:50:11AM +0300, Marcel Apfelbaum wrote:
> On 08/21/2015 12:54 AM, Eduardo Habkost wrote:
> >Now all TYPE_MACHINE subclasses use MACHINE_TYPE_NAME to generate the
> >class name. So instead of requiring each subclass to set
> >MachineClass::name manually, we can now set it automatically at the
> >TYPE_MACHINE class_base_init() function.
> >
> >Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> >---
> >  hw/arm/vexpress.c      | 2 --
> >  hw/arm/virt.c          | 1 -
> >  hw/core/machine.c      | 3 +++
> >  hw/ppc/mac_newworld.c  | 1 -
> >  hw/ppc/spapr.c         | 4 ----
> >  hw/s390x/s390-virtio.c | 1 -
> >  vl.c                   | 1 -
> >  7 files changed, 3 insertions(+), 10 deletions(-)
[...]
> >diff --git a/vl.c b/vl.c
> >index b7ddfeb..870ee48 100644
> >--- a/vl.c
> >+++ b/vl.c
> >@@ -1432,7 +1432,6 @@ static void qemu_machine_class_init(ObjectClass *oc, void *data)
> >  {
> >      MachineClass *mc = MACHINE_CLASS(oc);
> >      QEMUMachine *qm = data;
> >-    mc->name = qm->name;
> >      mc->desc = qm->desc;
> >      mc->init = qm->init;
> >      mc->kvm_type = qm->kvm_type;
> >
> 
> Nice!
> 
> Please forget the possible stupid question, but what happens with
> *all* other machine types? Why don't we have to remove the "name"
> assignment from the other machine types too?

Unless I made a mistake and missed something when grepping the code, all
machine-types were changed. Most of them use qemu_register_machine()
(which uses qemu_machine_class_init(), changed above).

-- 
Eduardo

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 10/10] machine: Set MachineClass::name automatically
  2015-08-26 15:02     ` Eduardo Habkost
@ 2015-08-26 16:13       ` Marcel Apfelbaum
  0 siblings, 0 replies; 40+ messages in thread
From: Marcel Apfelbaum @ 2015-08-26 16:13 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Marcel Apfelbaum, David Gibson, qemu-devel, Andreas Färber

On 08/26/2015 06:02 PM, Eduardo Habkost wrote:
> On Tue, Aug 25, 2015 at 11:50:11AM +0300, Marcel Apfelbaum wrote:
>> On 08/21/2015 12:54 AM, Eduardo Habkost wrote:
>>> Now all TYPE_MACHINE subclasses use MACHINE_TYPE_NAME to generate the
>>> class name. So instead of requiring each subclass to set
>>> MachineClass::name manually, we can now set it automatically at the
>>> TYPE_MACHINE class_base_init() function.
>>>
>>> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
>>> ---
>>>   hw/arm/vexpress.c      | 2 --
>>>   hw/arm/virt.c          | 1 -
>>>   hw/core/machine.c      | 3 +++
>>>   hw/ppc/mac_newworld.c  | 1 -
>>>   hw/ppc/spapr.c         | 4 ----
>>>   hw/s390x/s390-virtio.c | 1 -
>>>   vl.c                   | 1 -
>>>   7 files changed, 3 insertions(+), 10 deletions(-)
> [...]
>>> diff --git a/vl.c b/vl.c
>>> index b7ddfeb..870ee48 100644
>>> --- a/vl.c
>>> +++ b/vl.c
>>> @@ -1432,7 +1432,6 @@ static void qemu_machine_class_init(ObjectClass *oc, void *data)
>>>   {
>>>       MachineClass *mc = MACHINE_CLASS(oc);
>>>       QEMUMachine *qm = data;
>>> -    mc->name = qm->name;
>>>       mc->desc = qm->desc;
>>>       mc->init = qm->init;
>>>       mc->kvm_type = qm->kvm_type;
>>>
>>
>> Nice!
>>
>> Please forget the possible stupid question, but what happens with
>> *all* other machine types? Why don't we have to remove the "name"
>> assignment from the other machine types too?
>
> Unless I made a mistake and missed something when grepping the code, all
> machine-types were changed. Most of them use qemu_register_machine()
> (which uses qemu_machine_class_init(), changed above).
>
OK, thanks for the answer.


Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>

Thanks,
Marcel

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 01/10] machine: MACHINE_TYPE_NAME macro
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 01/10] machine: MACHINE_TYPE_NAME macro Eduardo Habkost
  2015-08-25  8:53   ` Marcel Apfelbaum
@ 2015-08-30  5:59   ` David Gibson
  1 sibling, 0 replies; 40+ messages in thread
From: David Gibson @ 2015-08-30  5:59 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: Marcel Apfelbaum, qemu-devel, Andreas Färber

[-- Attachment #1: Type: text/plain, Size: 529 bytes --]

On Thu, Aug 20, 2015 at 02:54:27PM -0700, Eduardo Habkost wrote:
> The macro will be useful to ensure the machine class names follow the
> right format to make machine class lookup by class name work correctly.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

-- 
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

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 02/10] vexpress: Don't set name on abstract class
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 02/10] vexpress: Don't set name on abstract class Eduardo Habkost
@ 2015-08-30  6:42   ` David Gibson
  0 siblings, 0 replies; 40+ messages in thread
From: David Gibson @ 2015-08-30  6:42 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Peter Maydell, Marcel Apfelbaum, qemu-devel, Andreas Färber

[-- Attachment #1: Type: text/plain, Size: 646 bytes --]

On Thu, Aug 20, 2015 at 02:54:28PM -0700, Eduardo Habkost wrote:
> The MachineClass::name field won't be ever be used on TYPE_VEXPRESS, as
> it is an abstract class and the machine class lookup code explicitly
> skips abstract classes. We can remove it to make the code simpler.
> 
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

-- 
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

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 03/10] vexpress: Rename machine classes to use MACHINE_TYPE_NAME
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 03/10] vexpress: Rename machine classes to use MACHINE_TYPE_NAME Eduardo Habkost
@ 2015-08-30  6:43   ` David Gibson
  2015-09-19  6:30   ` Andreas Färber
  1 sibling, 0 replies; 40+ messages in thread
From: David Gibson @ 2015-08-30  6:43 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Peter Maydell, Marcel Apfelbaum, qemu-devel, Andreas Färber

[-- Attachment #1: Type: text/plain, Size: 618 bytes --]

On Thu, Aug 20, 2015 at 02:54:29PM -0700, Eduardo Habkost wrote:
> Machine class names should use the "-machine" suffix to allow
> class-name-based machine class lookup to work. Rename the vexpress
> machine classes using the MACHINE_TYPE_NAME macro.
> 
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

-- 
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

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 04/10] arm: Rename virt machine class to use MACHINE_TYPE_NAME
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 04/10] arm: Rename virt machine class " Eduardo Habkost
@ 2015-08-30  6:43   ` David Gibson
  0 siblings, 0 replies; 40+ messages in thread
From: David Gibson @ 2015-08-30  6:43 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Peter Maydell, Marcel Apfelbaum, qemu-devel, Andreas Färber

[-- Attachment #1: Type: text/plain, Size: 616 bytes --]

On Thu, Aug 20, 2015 at 02:54:30PM -0700, Eduardo Habkost wrote:
> Machine class names should use the "-machine" suffix to allow
> class-name-based machine class lookup to work. Rename the arm virt
> machine class using the MACHINE_TYPE_NAME macro.
> 
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

-- 
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

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 05/10] pseries: Rename machine class names to use MACHINE_TYPE_NAME
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 05/10] pseries: Rename machine class names " Eduardo Habkost
@ 2015-08-30  6:45   ` David Gibson
  0 siblings, 0 replies; 40+ messages in thread
From: David Gibson @ 2015-08-30  6:45 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Alexander Graf, Marcel Apfelbaum, qemu-ppc, qemu-devel,
	Andreas Färber

[-- Attachment #1: Type: text/plain, Size: 2604 bytes --]

On Thu, Aug 20, 2015 at 02:54:31PM -0700, Eduardo Habkost wrote:
> Machine class names should use the "-machine" suffix to allow
> class-name-based machine class lookup to work. Rename the the pseries
> machine classes using the MACHINE_TYPE_NAME macro.
> 
> Cc: Alexander Graf <agraf@suse.de>
> Cc: qemu-ppc@nongnu.org
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

I'm also happy to take this through by spapr-next tree if that's
useful to do.

> ---
>  hw/ppc/spapr.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index bf0c64f..012b6ed 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1925,7 +1925,7 @@ static void spapr_machine_2_1_class_init(ObjectClass *oc, void *data)
>  }
>  
>  static const TypeInfo spapr_machine_2_1_info = {
> -    .name          = TYPE_SPAPR_MACHINE "2.1",
> +    .name          = MACHINE_TYPE_NAME("pseries-2.1"),
>      .parent        = TYPE_SPAPR_MACHINE,
>      .class_init    = spapr_machine_2_1_class_init,
>      .instance_init = spapr_machine_2_1_instance_init,
> @@ -1945,7 +1945,7 @@ static void spapr_machine_2_2_class_init(ObjectClass *oc, void *data)
>  }
>  
>  static const TypeInfo spapr_machine_2_2_info = {
> -    .name          = TYPE_SPAPR_MACHINE "2.2",
> +    .name          = MACHINE_TYPE_NAME("pseries-2.2"),
>      .parent        = TYPE_SPAPR_MACHINE,
>      .class_init    = spapr_machine_2_2_class_init,
>      .instance_init = spapr_machine_2_2_instance_init,
> @@ -1965,7 +1965,7 @@ static void spapr_machine_2_3_class_init(ObjectClass *oc, void *data)
>  }
>  
>  static const TypeInfo spapr_machine_2_3_info = {
> -    .name          = TYPE_SPAPR_MACHINE "2.3",
> +    .name          = MACHINE_TYPE_NAME("pseries-2.3"),
>      .parent        = TYPE_SPAPR_MACHINE,
>      .class_init    = spapr_machine_2_3_class_init,
>      .instance_init = spapr_machine_2_3_instance_init,
> @@ -1982,7 +1982,7 @@ static void spapr_machine_2_4_class_init(ObjectClass *oc, void *data)
>  }
>  
>  static const TypeInfo spapr_machine_2_4_info = {
> -    .name          = TYPE_SPAPR_MACHINE "2.4",
> +    .name          = MACHINE_TYPE_NAME("pseries-2.4"),
>      .parent        = TYPE_SPAPR_MACHINE,
>      .class_init    = spapr_machine_2_4_class_init,
>  };

-- 
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

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 06/10] s390-virtio: Rename machine class name to use MACHINE_TYPE_NAME
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 06/10] s390-virtio: Rename machine class name " Eduardo Habkost
@ 2015-08-30  6:46   ` David Gibson
  0 siblings, 0 replies; 40+ messages in thread
From: David Gibson @ 2015-08-30  6:46 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Alexander Graf, Richard Henderson, Marcel Apfelbaum, qemu-devel,
	Andreas Färber

[-- Attachment #1: Type: text/plain, Size: 1694 bytes --]

On Thu, Aug 20, 2015 at 02:54:32PM -0700, Eduardo Habkost wrote:
> Machine class names should use the "-machine" suffix to allow
> class-name-based machine class lookup to work. Rename the s390-virtio
> machine class using the MACHINE_TYPE_NAME macro.
> 
> Cc: Alexander Graf <agraf@suse.de>
> Cc: Richard Henderson <rth@twiddle.net>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  hw/s390x/s390-virtio.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
> index 1284e77..43d6ccb 100644
> --- a/hw/s390x/s390-virtio.c
> +++ b/hw/s390x/s390-virtio.c
> @@ -52,7 +52,8 @@
>  
>  #define MAX_BLK_DEVS                    10
>  #define ZIPL_FILENAME                   "s390-zipl.rom"
> -#define TYPE_S390_MACHINE               "s390-machine"
> +#define S390_MACHINE                    "s390-virtio"
> +#define TYPE_S390_MACHINE               MACHINE_TYPE_NAME(S390_MACHINE)
>  
>  #define S390_TOD_CLOCK_VALUE_MISSING    0x00
>  #define S390_TOD_CLOCK_VALUE_PRESENT    0x01
> @@ -333,7 +334,7 @@ static void s390_machine_class_init(ObjectClass *oc, void *data)
>      MachineClass *mc = MACHINE_CLASS(oc);
>      NMIClass *nc = NMI_CLASS(oc);
>  
> -    mc->name = "s390-virtio";
> +    mc->name = S390_MACHINE;
>      mc->alias = "s390";
>      mc->desc = "VirtIO based S390 machine";
>      mc->init = s390_init;

-- 
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

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 07/10] s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 07/10] s390: Rename s390-ccw-virtio-2.4 " Eduardo Habkost
@ 2015-08-30  6:46   ` David Gibson
  2015-09-04  8:52   ` Christian Borntraeger
  1 sibling, 0 replies; 40+ messages in thread
From: David Gibson @ 2015-08-30  6:46 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Marcel Apfelbaum, Alexander Graf, qemu-devel,
	Christian Borntraeger, Cornelia Huck, Andreas Färber,
	Richard Henderson

[-- Attachment #1: Type: text/plain, Size: 1422 bytes --]

On Thu, Aug 20, 2015 at 02:54:33PM -0700, Eduardo Habkost wrote:
> Machine class names should use the "-machine" suffix to allow
> class-name-based machine class lookup to work. Rename the
> s390-ccw-virtio-2.4 machine class using the MACHINE_TYPE_NAME macro.
> 
> Cc: Alexander Graf <agraf@suse.de>
> Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Richard Henderson <rth@twiddle.net>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  hw/s390x/s390-virtio-ccw.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
> index 4c51d1a..66e1478 100644
> --- a/hw/s390x/s390-virtio-ccw.c
> +++ b/hw/s390x/s390-virtio-ccw.c
> @@ -293,7 +293,7 @@ static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data)
>  }
>  
>  static const TypeInfo ccw_machine_2_4_info = {
> -    .name          = TYPE_S390_CCW_MACHINE "2.4",
> +    .name          = MACHINE_TYPE_NAME("s390-ccw-virtio-2.4"),
>      .parent        = TYPE_S390_CCW_MACHINE,
>      .class_init    = ccw_machine_2_4_class_init,
>  };

-- 
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

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 08/10] mac99: Use MACHINE_TYPE_NAME to encode class name
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 08/10] mac99: Use MACHINE_TYPE_NAME to encode class name Eduardo Habkost
@ 2015-08-30  6:46   ` David Gibson
  0 siblings, 0 replies; 40+ messages in thread
From: David Gibson @ 2015-08-30  6:46 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Alexander Graf, Marcel Apfelbaum, qemu-ppc, qemu-devel,
	Andreas Färber

[-- Attachment #1: Type: text/plain, Size: 1157 bytes --]

On Thu, Aug 20, 2015 at 02:54:34PM -0700, Eduardo Habkost wrote:
> It will result in exactly the same class name, but it will make the code
> consistent with the other classes.
> 
> Cc: Alexander Graf <agraf@suse.de>
> Cc: qemu-ppc@nongnu.org
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  hw/ppc/mac_newworld.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
> index 77d5c81..a6b8209 100644
> --- a/hw/ppc/mac_newworld.c
> +++ b/hw/ppc/mac_newworld.c
> @@ -517,7 +517,7 @@ static void core99_machine_class_init(ObjectClass *oc, void *data)
>  }
>  
>  static const TypeInfo core99_machine_info = {
> -    .name          = "mac99-machine",
> +    .name          = MACHINE_TYPE_NAME("mac99"),
>      .parent        = TYPE_MACHINE,
>      .class_init    = core99_machine_class_init,
>  };

-- 
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

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix
  2015-08-20 21:54 [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix Eduardo Habkost
                   ` (10 preceding siblings ...)
  2015-08-21 10:23 ` [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix Cornelia Huck
@ 2015-09-02 19:58 ` Eduardo Habkost
  2015-09-03  7:39   ` Cornelia Huck
  2015-09-06 19:25   ` Andreas Färber
  11 siblings, 2 replies; 40+ messages in thread
From: Eduardo Habkost @ 2015-09-02 19:58 UTC (permalink / raw)
  To: qemu-devel, Andreas Färber
  Cc: Peter Maydell, Marcel Apfelbaum, Alexander Graf,
	Christian Borntraeger, qemu-ppc, Cornelia Huck, David Gibson,
	Richard Henderson

Ping?

Andreas, should this go through your QOM tree?

On Thu, Aug 20, 2015 at 02:54:26PM -0700, Eduardo Habkost wrote:
> The machine class names in QEMU are not consistent today. Some of them use the
> "-machine" suffix, but some use completely different naming conventions. This
> makes it difficult to implement machine class lookup without iterating through
> the whole list of machine classes.
> 
> This series changes all machines to use "<machine name>-machine" as the class
> name, so we can simply use object_class_by_name() in the future to lookup
> machine classes. (This was not done yet because it will also require some
> changes in the way aliases are handled.)
> 
> Cc: Alexander Graf <agraf@suse.de>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: qemu-ppc@nongnu.org
> Cc: Richard Henderson <rth@twiddle.net>
> 
> Eduardo Habkost (10):
>   machine: MACHINE_TYPE_NAME macro
>   vexpress: Don't set name on abstract class
>   vexpress: Rename machine classes to use MACHINE_TYPE_NAME
>   arm: Rename virt machine class to use MACHINE_TYPE_NAME
>   pseries: Rename machine class names to use MACHINE_TYPE_NAME
>   s390-virtio: Rename machine class name to use MACHINE_TYPE_NAME
>   s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME
>   mac99: Use MACHINE_TYPE_NAME to encode class name
>   machine: Ensure all TYPE_MACHINE subclasses have the right suffix
>   machine: Set MachineClass::name automatically
> 
>  hw/arm/vexpress.c          |  7 ++-----
>  hw/arm/virt.c              |  4 ++--
>  hw/core/machine.c          | 12 ++++++++++++
>  hw/ppc/mac_newworld.c      |  3 +--
>  hw/ppc/spapr.c             | 12 ++++--------
>  hw/s390x/s390-virtio-ccw.c |  2 +-
>  hw/s390x/s390-virtio.c     |  4 ++--
>  include/hw/boards.h        |  6 ++++++
>  vl.c                       |  3 +--
>  9 files changed, 31 insertions(+), 22 deletions(-)
> 
> -- 
> 2.1.0
> 
> 

-- 
Eduardo

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix
  2015-09-02 19:58 ` Eduardo Habkost
@ 2015-09-03  7:39   ` Cornelia Huck
  2015-09-06 19:25   ` Andreas Färber
  1 sibling, 0 replies; 40+ messages in thread
From: Cornelia Huck @ 2015-09-03  7:39 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Peter Maydell, Marcel Apfelbaum, Alexander Graf, qemu-devel,
	Christian Borntraeger, qemu-ppc, David Gibson,
	Andreas Färber, Richard Henderson

On Wed, 2 Sep 2015 16:58:45 -0300
Eduardo Habkost <ehabkost@redhat.com> wrote:

> Ping?

In case that helps:

Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>

> 
> Andreas, should this go through your QOM tree?
> 
> On Thu, Aug 20, 2015 at 02:54:26PM -0700, Eduardo Habkost wrote:
> > The machine class names in QEMU are not consistent today. Some of them use the
> > "-machine" suffix, but some use completely different naming conventions. This
> > makes it difficult to implement machine class lookup without iterating through
> > the whole list of machine classes.
> > 
> > This series changes all machines to use "<machine name>-machine" as the class
> > name, so we can simply use object_class_by_name() in the future to lookup
> > machine classes. (This was not done yet because it will also require some
> > changes in the way aliases are handled.)
> > 
> > Cc: Alexander Graf <agraf@suse.de>
> > Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> > Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
> > Cc: Peter Maydell <peter.maydell@linaro.org>
> > Cc: qemu-ppc@nongnu.org
> > Cc: Richard Henderson <rth@twiddle.net>
> > 
> > Eduardo Habkost (10):
> >   machine: MACHINE_TYPE_NAME macro
> >   vexpress: Don't set name on abstract class
> >   vexpress: Rename machine classes to use MACHINE_TYPE_NAME
> >   arm: Rename virt machine class to use MACHINE_TYPE_NAME
> >   pseries: Rename machine class names to use MACHINE_TYPE_NAME
> >   s390-virtio: Rename machine class name to use MACHINE_TYPE_NAME
> >   s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME
> >   mac99: Use MACHINE_TYPE_NAME to encode class name
> >   machine: Ensure all TYPE_MACHINE subclasses have the right suffix
> >   machine: Set MachineClass::name automatically
> > 
> >  hw/arm/vexpress.c          |  7 ++-----
> >  hw/arm/virt.c              |  4 ++--
> >  hw/core/machine.c          | 12 ++++++++++++
> >  hw/ppc/mac_newworld.c      |  3 +--
> >  hw/ppc/spapr.c             | 12 ++++--------
> >  hw/s390x/s390-virtio-ccw.c |  2 +-
> >  hw/s390x/s390-virtio.c     |  4 ++--
> >  include/hw/boards.h        |  6 ++++++
> >  vl.c                       |  3 +--
> >  9 files changed, 31 insertions(+), 22 deletions(-)
> > 
> > -- 
> > 2.1.0
> > 
> > 
> 

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 07/10] s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 07/10] s390: Rename s390-ccw-virtio-2.4 " Eduardo Habkost
  2015-08-30  6:46   ` David Gibson
@ 2015-09-04  8:52   ` Christian Borntraeger
  2015-09-04 14:54     ` Eduardo Habkost
  1 sibling, 1 reply; 40+ messages in thread
From: Christian Borntraeger @ 2015-09-04  8:52 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel, Andreas Färber
  Cc: Cornelia Huck, Richard Henderson, David Gibson, Alexander Graf,
	Marcel Apfelbaum

Am 20.08.2015 um 23:54 schrieb Eduardo Habkost:
> Machine class names should use the "-machine" suffix to allow
> class-name-based machine class lookup to work. Rename the
> s390-ccw-virtio-2.4 machine class using the MACHINE_TYPE_NAME macro.
> 
> Cc: Alexander Graf <agraf@suse.de>
> Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Richard Henderson <rth@twiddle.net>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  hw/s390x/s390-virtio-ccw.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
> index 4c51d1a..66e1478 100644
> --- a/hw/s390x/s390-virtio-ccw.c
> +++ b/hw/s390x/s390-virtio-ccw.c
> @@ -293,7 +293,7 @@ static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data)
>  }
> 
>  static const TypeInfo ccw_machine_2_4_info = {
> -    .name          = TYPE_S390_CCW_MACHINE "2.4",
> +    .name          = MACHINE_TYPE_NAME("s390-ccw-virtio-2.4"),
>      .parent        = TYPE_S390_CCW_MACHINE,
>      .class_init    = ccw_machine_2_4_class_init,
>  };
> 

Since yesterday you also need to adopt the 2.5 machine....

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 07/10] s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME
  2015-09-04  8:52   ` Christian Borntraeger
@ 2015-09-04 14:54     ` Eduardo Habkost
  2015-09-04 14:56       ` Andreas Färber
  0 siblings, 1 reply; 40+ messages in thread
From: Eduardo Habkost @ 2015-09-04 14:54 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: Marcel Apfelbaum, Alexander Graf, qemu-devel, Cornelia Huck,
	Richard Henderson, Andreas Färber, David Gibson

On Fri, Sep 04, 2015 at 10:52:22AM +0200, Christian Borntraeger wrote:
> Am 20.08.2015 um 23:54 schrieb Eduardo Habkost:
> > Machine class names should use the "-machine" suffix to allow
> > class-name-based machine class lookup to work. Rename the
> > s390-ccw-virtio-2.4 machine class using the MACHINE_TYPE_NAME macro.
> > 
> > Cc: Alexander Graf <agraf@suse.de>
> > Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
> > Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> > Cc: Richard Henderson <rth@twiddle.net>
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > ---
> >  hw/s390x/s390-virtio-ccw.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
> > index 4c51d1a..66e1478 100644
> > --- a/hw/s390x/s390-virtio-ccw.c
> > +++ b/hw/s390x/s390-virtio-ccw.c
> > @@ -293,7 +293,7 @@ static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data)
> >  }
> > 
> >  static const TypeInfo ccw_machine_2_4_info = {
> > -    .name          = TYPE_S390_CCW_MACHINE "2.4",
> > +    .name          = MACHINE_TYPE_NAME("s390-ccw-virtio-2.4"),
> >      .parent        = TYPE_S390_CCW_MACHINE,
> >      .class_init    = ccw_machine_2_4_class_init,
> >  };
> > 
> 
> Since yesterday you also need to adopt the 2.5 machine....

Thanks for for noting! I will rebase and resubmit.

-- 
Eduardo

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 07/10] s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME
  2015-09-04 14:54     ` Eduardo Habkost
@ 2015-09-04 14:56       ` Andreas Färber
  2015-09-04 15:06         ` Eduardo Habkost
  0 siblings, 1 reply; 40+ messages in thread
From: Andreas Färber @ 2015-09-04 14:56 UTC (permalink / raw)
  To: Eduardo Habkost, Christian Borntraeger
  Cc: Marcel Apfelbaum, Alexander Graf, qemu-devel, Cornelia Huck,
	David Gibson, Richard Henderson

Am 04.09.2015 um 16:54 schrieb Eduardo Habkost:
> On Fri, Sep 04, 2015 at 10:52:22AM +0200, Christian Borntraeger wrote:
>> Am 20.08.2015 um 23:54 schrieb Eduardo Habkost:
>>> Machine class names should use the "-machine" suffix to allow
>>> class-name-based machine class lookup to work. Rename the
>>> s390-ccw-virtio-2.4 machine class using the MACHINE_TYPE_NAME macro.
>>>
>>> Cc: Alexander Graf <agraf@suse.de>
>>> Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
>>> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
>>> Cc: Richard Henderson <rth@twiddle.net>
>>> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
>>> ---
>>>  hw/s390x/s390-virtio-ccw.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
>>> index 4c51d1a..66e1478 100644
>>> --- a/hw/s390x/s390-virtio-ccw.c
>>> +++ b/hw/s390x/s390-virtio-ccw.c
>>> @@ -293,7 +293,7 @@ static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data)
>>>  }
>>>
>>>  static const TypeInfo ccw_machine_2_4_info = {
>>> -    .name          = TYPE_S390_CCW_MACHINE "2.4",
>>> +    .name          = MACHINE_TYPE_NAME("s390-ccw-virtio-2.4"),
>>>      .parent        = TYPE_S390_CCW_MACHINE,
>>>      .class_init    = ccw_machine_2_4_class_init,
>>>  };
>>>
>>
>> Since yesterday you also need to adopt the 2.5 machine....
> 
> Thanks for for noting! I will rebase and resubmit.

If it's just a single line addition I can edit that when applying.
Anything else in need of changes?

Regards,
Andreas

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 07/10] s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME
  2015-09-04 14:56       ` Andreas Färber
@ 2015-09-04 15:06         ` Eduardo Habkost
  2015-09-04 15:42           ` Eduardo Habkost
  0 siblings, 1 reply; 40+ messages in thread
From: Eduardo Habkost @ 2015-09-04 15:06 UTC (permalink / raw)
  To: Andreas Färber
  Cc: Marcel Apfelbaum, qemu-devel, Alexander Graf,
	Christian Borntraeger, Cornelia Huck, Richard Henderson,
	David Gibson

On Fri, Sep 04, 2015 at 04:56:35PM +0200, Andreas Färber wrote:
> Am 04.09.2015 um 16:54 schrieb Eduardo Habkost:
> > On Fri, Sep 04, 2015 at 10:52:22AM +0200, Christian Borntraeger wrote:
> >> Am 20.08.2015 um 23:54 schrieb Eduardo Habkost:
> >>> Machine class names should use the "-machine" suffix to allow
> >>> class-name-based machine class lookup to work. Rename the
> >>> s390-ccw-virtio-2.4 machine class using the MACHINE_TYPE_NAME macro.
> >>>
> >>> Cc: Alexander Graf <agraf@suse.de>
> >>> Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
> >>> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> >>> Cc: Richard Henderson <rth@twiddle.net>
> >>> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> >>> ---
> >>>  hw/s390x/s390-virtio-ccw.c | 2 +-
> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>> diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
> >>> index 4c51d1a..66e1478 100644
> >>> --- a/hw/s390x/s390-virtio-ccw.c
> >>> +++ b/hw/s390x/s390-virtio-ccw.c
> >>> @@ -293,7 +293,7 @@ static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data)
> >>>  }
> >>>
> >>>  static const TypeInfo ccw_machine_2_4_info = {
> >>> -    .name          = TYPE_S390_CCW_MACHINE "2.4",
> >>> +    .name          = MACHINE_TYPE_NAME("s390-ccw-virtio-2.4"),
> >>>      .parent        = TYPE_S390_CCW_MACHINE,
> >>>      .class_init    = ccw_machine_2_4_class_init,
> >>>  };
> >>>
> >>
> >> Since yesterday you also need to adopt the 2.5 machine....
> > 
> > Thanks for for noting! I will rebase and resubmit.
> 
> If it's just a single line addition I can edit that when applying.

Thanks!

> Anything else in need of changes?

That's the only needed change, unless other machine classes were added
since I have submitted this patch. But missing a few classes won't break
bisectability, and can be fixed by a follow-up patch if necessary.

-- 
Eduardo

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 07/10] s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME
  2015-09-04 15:06         ` Eduardo Habkost
@ 2015-09-04 15:42           ` Eduardo Habkost
  0 siblings, 0 replies; 40+ messages in thread
From: Eduardo Habkost @ 2015-09-04 15:42 UTC (permalink / raw)
  To: Andreas Färber
  Cc: Marcel Apfelbaum, Alexander Graf, qemu-devel,
	Christian Borntraeger, Cornelia Huck, David Gibson,
	Richard Henderson

On Fri, Sep 04, 2015 at 12:06:04PM -0300, Eduardo Habkost wrote:
> On Fri, Sep 04, 2015 at 04:56:35PM +0200, Andreas Färber wrote:
> > Am 04.09.2015 um 16:54 schrieb Eduardo Habkost:
> > > On Fri, Sep 04, 2015 at 10:52:22AM +0200, Christian Borntraeger wrote:
> > >> Am 20.08.2015 um 23:54 schrieb Eduardo Habkost:
> > >>> Machine class names should use the "-machine" suffix to allow
> > >>> class-name-based machine class lookup to work. Rename the
> > >>> s390-ccw-virtio-2.4 machine class using the MACHINE_TYPE_NAME macro.
> > >>>
> > >>> Cc: Alexander Graf <agraf@suse.de>
> > >>> Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
> > >>> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> > >>> Cc: Richard Henderson <rth@twiddle.net>
> > >>> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > >>> ---
> > >>>  hw/s390x/s390-virtio-ccw.c | 2 +-
> > >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> > >>>
> > >>> diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
> > >>> index 4c51d1a..66e1478 100644
> > >>> --- a/hw/s390x/s390-virtio-ccw.c
> > >>> +++ b/hw/s390x/s390-virtio-ccw.c
> > >>> @@ -293,7 +293,7 @@ static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data)
> > >>>  }
> > >>>
> > >>>  static const TypeInfo ccw_machine_2_4_info = {
> > >>> -    .name          = TYPE_S390_CCW_MACHINE "2.4",
> > >>> +    .name          = MACHINE_TYPE_NAME("s390-ccw-virtio-2.4"),
> > >>>      .parent        = TYPE_S390_CCW_MACHINE,
> > >>>      .class_init    = ccw_machine_2_4_class_init,
> > >>>  };
> > >>>
> > >>
> > >> Since yesterday you also need to adopt the 2.5 machine....
> > > 
> > > Thanks for for noting! I will rebase and resubmit.
> > 
> > If it's just a single line addition I can edit that when applying.
> 
> Thanks!
> 
> > Anything else in need of changes?
> 
> That's the only needed change, unless other machine classes were added
> since I have submitted this patch. But missing a few classes won't break
> bisectability, and can be fixed by a follow-up patch if necessary.

I have just double-checked that there are no other machine classes that
need to be renamed. For reference, this is the patch that needs to be
squashed into this one:

diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index db5dc26..5bbafe0 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -319,7 +319,7 @@ static void ccw_machine_2_5_class_init(ObjectClass *oc, void *data)
 }
 
 static const TypeInfo ccw_machine_2_5_info = {
-    .name          = TYPE_S390_CCW_MACHINE "2.5",
+    .name          = MACHINE_TYPE_NAME("s390-ccw-virtio-2.5"),
     .parent        = TYPE_S390_CCW_MACHINE,
     .class_init    = ccw_machine_2_5_class_init,
 };

-- 
Eduardo

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 10/10] machine: Set MachineClass::name automatically
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 10/10] machine: Set MachineClass::name automatically Eduardo Habkost
  2015-08-25  8:50   ` Marcel Apfelbaum
@ 2015-09-04 15:46   ` Eduardo Habkost
  2015-09-19  6:23   ` Andreas Färber
  2 siblings, 0 replies; 40+ messages in thread
From: Eduardo Habkost @ 2015-09-04 15:46 UTC (permalink / raw)
  To: qemu-devel, Andreas Färber; +Cc: David Gibson, Marcel Apfelbaum

On Thu, Aug 20, 2015 at 02:54:36PM -0700, Eduardo Habkost wrote:
> Now all TYPE_MACHINE subclasses use MACHINE_TYPE_NAME to generate the
> class name. So instead of requiring each subclass to set
> MachineClass::name manually, we can now set it automatically at the
> TYPE_MACHINE class_base_init() function.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

The s390-virtio-ccw machines are missing from this patch. The following
patch can be squashed into this one.

If a more formal follow-up patch or v2 patch is preferred, please let me
know.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 5bbafe0..fb0e742 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -297,7 +297,6 @@ static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data)
         { /* end of list */ }
     };
 
-    mc->name = "s390-ccw-virtio-2.4";
     mc->desc = "VirtIO-ccw based S390 machine v2.4";
     mc->compat_props = compat_props;
 }
@@ -312,7 +311,6 @@ static void ccw_machine_2_5_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
-    mc->name = "s390-ccw-virtio-2.5";
     mc->alias = "s390-ccw-virtio";
     mc->desc = "VirtIO-ccw based S390 machine v2.5";
     mc->is_default = 1;
-- 
Eduardo

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix
  2015-09-02 19:58 ` Eduardo Habkost
  2015-09-03  7:39   ` Cornelia Huck
@ 2015-09-06 19:25   ` Andreas Färber
  2015-09-07  9:05     ` Marcel Apfelbaum
  1 sibling, 1 reply; 40+ messages in thread
From: Andreas Färber @ 2015-09-06 19:25 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Peter Maydell, Marcel Apfelbaum, Alexander Graf,
	Christian Borntraeger, qemu-ppc, Cornelia Huck,
	Richard Henderson, David Gibson

Am 02.09.2015 um 21:58 schrieb Eduardo Habkost:
> Ping?
> 
> Andreas, should this go through your QOM tree?

Long-term I would prefer a separate machine maintainer (Marcel?) to
handle this, but as discussed in Seattle, I'm applying this series to
qom-next and will look at the follow-up series next.

https://github.com/afaerber/qemu-cpu/commits/qom-next

Thanks,
Andreas

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix
  2015-09-06 19:25   ` Andreas Färber
@ 2015-09-07  9:05     ` Marcel Apfelbaum
  0 siblings, 0 replies; 40+ messages in thread
From: Marcel Apfelbaum @ 2015-09-07  9:05 UTC (permalink / raw)
  To: Andreas Färber, Eduardo Habkost, qemu-devel
  Cc: Peter Maydell, Marcel Apfelbaum, Alexander Graf,
	Christian Borntraeger, qemu-ppc, Cornelia Huck,
	Richard Henderson, David Gibson

On 09/06/2015 10:25 PM, Andreas Färber wrote:
> Am 02.09.2015 um 21:58 schrieb Eduardo Habkost:
>> Ping?
>>
>> Andreas, should this go through your QOM tree?
>
> Long-term I would prefer a separate machine maintainer (Marcel?)
Hi Andreas,

I can be the machine maintainer, sure.
I should start maintaining contribution anyway, this could be a start.

Thanks,
Marcel




  to
> handle this, but as discussed in Seattle, I'm applying this series to
> qom-next and will look at the follow-up series next.
>
> https://github.com/afaerber/qemu-cpu/commits/qom-next
>
> Thanks,
> Andreas
>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 10/10] machine: Set MachineClass::name automatically
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 10/10] machine: Set MachineClass::name automatically Eduardo Habkost
  2015-08-25  8:50   ` Marcel Apfelbaum
  2015-09-04 15:46   ` Eduardo Habkost
@ 2015-09-19  6:23   ` Andreas Färber
  2015-09-19  6:39     ` Andreas Färber
  2 siblings, 1 reply; 40+ messages in thread
From: Andreas Färber @ 2015-09-19  6:23 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel; +Cc: David Gibson, Marcel Apfelbaum

Am 20.08.2015 um 23:54 schrieb Eduardo Habkost:
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 5ba4b80..af985f6 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -960,7 +960,6 @@ static void virt_class_init(ObjectClass *oc, void *data)
>  {
>      MachineClass *mc = MACHINE_CLASS(oc);
>  
> -    mc->name = VIRT_MACHINE_NAME;
>      mc->desc = "ARM Virtual Machine",
>      mc->init = machvirt_init;
>      mc->max_cpus = 8;

I am going to squash the following cleanup reverting 04/10 change:

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 49eb4fa..6bf0d6d 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -83,8 +83,7 @@ typedef struct {
     bool highmem;
 } VirtMachineState;

-#define VIRT_MACHINE_NAME   "virt"
-#define TYPE_VIRT_MACHINE   MACHINE_TYPE_NAME(VIRT_MACHINE_NAME)
+#define TYPE_VIRT_MACHINE   MACHINE_TYPE_NAME("virt")
 #define VIRT_MACHINE(obj) \
     OBJECT_CHECK(VirtMachineState, (obj), TYPE_VIRT_MACHINE)
 #define VIRT_MACHINE_GET_CLASS(obj) \

Regards,
Andreas

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 03/10] vexpress: Rename machine classes to use MACHINE_TYPE_NAME
  2015-08-20 21:54 ` [Qemu-devel] [PATCH 03/10] vexpress: Rename machine classes to use MACHINE_TYPE_NAME Eduardo Habkost
  2015-08-30  6:43   ` David Gibson
@ 2015-09-19  6:30   ` Andreas Färber
  2015-09-19  6:37     ` Andreas Färber
  1 sibling, 1 reply; 40+ messages in thread
From: Andreas Färber @ 2015-09-19  6:30 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel; +Cc: Peter Maydell, David Gibson, Marcel Apfelbaum

Am 20.08.2015 um 23:54 schrieb Eduardo Habkost:
> Machine class names should use the "-machine" suffix to allow
> class-name-based machine class lookup to work. Rename the vexpress
> machine classes using the MACHINE_TYPE_NAME macro.
> 
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  hw/arm/vexpress.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
> index 15e4ae9..a86979d 100644
> --- a/hw/arm/vexpress.c
> +++ b/hw/arm/vexpress.c
> @@ -168,8 +168,8 @@ typedef struct {
>  } VexpressMachineState;
>  
>  #define TYPE_VEXPRESS_MACHINE   "vexpress"
> -#define TYPE_VEXPRESS_A9_MACHINE   "vexpress-a9"
> -#define TYPE_VEXPRESS_A15_MACHINE   "vexpress-a15"
> +#define TYPE_VEXPRESS_A9_MACHINE   MACHINE_TYPE_NAME("vexpress-a9")
> +#define TYPE_VEXPRESS_A15_MACHINE   MACHINE_TYPE_NAME("vexpress-a15")
>  #define VEXPRESS_MACHINE(obj) \
>      OBJECT_CHECK(VexpressMachineState, (obj), TYPE_VEXPRESS_MACHINE)
>  #define VEXPRESS_MACHINE_GET_CLASS(obj) \

This is temporarily changing MachineClass::name to ...-machine. Fixing
as follows, as was done for virt in 04/10:

diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index eafa2ab..ecbfeb1 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -168,8 +168,10 @@ typedef struct {
 } VexpressMachineState;

 #define TYPE_VEXPRESS_MACHINE   "vexpress"
-#define TYPE_VEXPRESS_A9_MACHINE   MACHINE_TYPE_NAME("vexpress-a9")
-#define TYPE_VEXPRESS_A15_MACHINE   MACHINE_TYPE_NAME("vexpress-a15")
+#define VEXPRESS_A9_MACHINE_NAME "vexpress-a9"
+#define VEXPRESS_A15_MACHINE_NAME "vexpress-a15"
+#define TYPE_VEXPRESS_A9_MACHINE
MACHINE_TYPE_NAME(VEXPRESS_A9_MACHINE_NAME)
+#define TYPE_VEXPRESS_A15_MACHINE
MACHINE_TYPE_NAME(VEXPRESS_A15_MACHINE_NAME)
 #define VEXPRESS_MACHINE(obj) \
     OBJECT_CHECK(VexpressMachineState, (obj), TYPE_VEXPRESS_MACHINE)
 #define VEXPRESS_MACHINE_GET_CLASS(obj) \
@@ -786,13 +788,13 @@ static const TypeInfo vexpress_info = {
 };

 static const TypeInfo vexpress_a9_info = {
-    .name = TYPE_VEXPRESS_A9_MACHINE,
+    .name = VEXPRESS_A9_MACHINE_NAME,
     .parent = TYPE_VEXPRESS_MACHINE,
     .class_init = vexpress_a9_class_init,
 };

 static const TypeInfo vexpress_a15_info = {
-    .name = TYPE_VEXPRESS_A15_MACHINE,
+    .name = VEXPRESS_A15_MACHINE_NAME,
     .parent = TYPE_VEXPRESS_MACHINE,
     .class_init = vexpress_a15_class_init,
 };

To be reverted in 10/10.

Regards,
Andreas

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 03/10] vexpress: Rename machine classes to use MACHINE_TYPE_NAME
  2015-09-19  6:30   ` Andreas Färber
@ 2015-09-19  6:37     ` Andreas Färber
  0 siblings, 0 replies; 40+ messages in thread
From: Andreas Färber @ 2015-09-19  6:37 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel; +Cc: Peter Maydell, Marcel Apfelbaum, David Gibson

Am 19.09.2015 um 08:30 schrieb Andreas Färber:
> Am 20.08.2015 um 23:54 schrieb Eduardo Habkost:
>> Machine class names should use the "-machine" suffix to allow
>> class-name-based machine class lookup to work. Rename the vexpress
>> machine classes using the MACHINE_TYPE_NAME macro.
>>
>> Cc: Peter Maydell <peter.maydell@linaro.org>
>> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
>> ---
>>  hw/arm/vexpress.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
>> index 15e4ae9..a86979d 100644
>> --- a/hw/arm/vexpress.c
>> +++ b/hw/arm/vexpress.c
>> @@ -168,8 +168,8 @@ typedef struct {
>>  } VexpressMachineState;
>>  
>>  #define TYPE_VEXPRESS_MACHINE   "vexpress"
>> -#define TYPE_VEXPRESS_A9_MACHINE   "vexpress-a9"
>> -#define TYPE_VEXPRESS_A15_MACHINE   "vexpress-a15"
>> +#define TYPE_VEXPRESS_A9_MACHINE   MACHINE_TYPE_NAME("vexpress-a9")
>> +#define TYPE_VEXPRESS_A15_MACHINE   MACHINE_TYPE_NAME("vexpress-a15")
>>  #define VEXPRESS_MACHINE(obj) \
>>      OBJECT_CHECK(VexpressMachineState, (obj), TYPE_VEXPRESS_MACHINE)
>>  #define VEXPRESS_MACHINE_GET_CLASS(obj) \
> 
> This is temporarily changing MachineClass::name to ...-machine. Fixing
> as follows, as was done for virt in 04/10:
> 
> diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
> index eafa2ab..ecbfeb1 100644
> --- a/hw/arm/vexpress.c
> +++ b/hw/arm/vexpress.c
> @@ -168,8 +168,10 @@ typedef struct {
>  } VexpressMachineState;
> 
>  #define TYPE_VEXPRESS_MACHINE   "vexpress"
> -#define TYPE_VEXPRESS_A9_MACHINE   MACHINE_TYPE_NAME("vexpress-a9")
> -#define TYPE_VEXPRESS_A15_MACHINE   MACHINE_TYPE_NAME("vexpress-a15")
> +#define VEXPRESS_A9_MACHINE_NAME "vexpress-a9"
> +#define VEXPRESS_A15_MACHINE_NAME "vexpress-a15"
> +#define TYPE_VEXPRESS_A9_MACHINE
> MACHINE_TYPE_NAME(VEXPRESS_A9_MACHINE_NAME)
> +#define TYPE_VEXPRESS_A15_MACHINE
> MACHINE_TYPE_NAME(VEXPRESS_A15_MACHINE_NAME)
>  #define VEXPRESS_MACHINE(obj) \
>      OBJECT_CHECK(VexpressMachineState, (obj), TYPE_VEXPRESS_MACHINE)
>  #define VEXPRESS_MACHINE_GET_CLASS(obj) \
> @@ -786,13 +788,13 @@ static const TypeInfo vexpress_info = {
>  };
> 
>  static const TypeInfo vexpress_a9_info = {
> -    .name = TYPE_VEXPRESS_A9_MACHINE,
> +    .name = VEXPRESS_A9_MACHINE_NAME,
>      .parent = TYPE_VEXPRESS_MACHINE,
>      .class_init = vexpress_a9_class_init,
>  };
> 
>  static const TypeInfo vexpress_a15_info = {
> -    .name = TYPE_VEXPRESS_A15_MACHINE,
> +    .name = VEXPRESS_A15_MACHINE_NAME,
>      .parent = TYPE_VEXPRESS_MACHINE,
>      .class_init = vexpress_a15_class_init,
>  };

Doh, wrong place, not my time of day...

diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index ecbfeb1..2bcd312 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -760,7 +760,7 @@ static void vexpress_a9_class_init(ObjectClass *oc,
void *da
ta)
     MachineClass *mc = MACHINE_CLASS(oc);
     VexpressMachineClass *vmc = VEXPRESS_MACHINE_CLASS(oc);

-    mc->name = TYPE_VEXPRESS_A9_MACHINE;
+    mc->name = VEXPRESS_A9_MACHINE_NAME;
     mc->desc = "ARM Versatile Express for Cortex-A9";

     vmc->daughterboard = &a9_daughterboard;
@@ -771,7 +771,7 @@ static void vexpress_a15_class_init(ObjectClass *oc,
void *data)
     MachineClass *mc = MACHINE_CLASS(oc);
     VexpressMachineClass *vmc = VEXPRESS_MACHINE_CLASS(oc);

-    mc->name = TYPE_VEXPRESS_A15_MACHINE;
+    mc->name = VEXPRESS_A15_MACHINE_NAME;
     mc->desc = "ARM Versatile Express for Cortex-A15";

     vmc->daughterboard = &a15_daughterboard;
@@ -788,13 +788,13 @@ static const TypeInfo vexpress_info = {
 };

 static const TypeInfo vexpress_a9_info = {
-    .name = VEXPRESS_A9_MACHINE_NAME,
+    .name = TYPE_VEXPRESS_A9_MACHINE,
     .parent = TYPE_VEXPRESS_MACHINE,
     .class_init = vexpress_a9_class_init,
 };

 static const TypeInfo vexpress_a15_info = {
-    .name = VEXPRESS_A15_MACHINE_NAME,
+    .name = TYPE_VEXPRESS_A15_MACHINE,
     .parent = TYPE_VEXPRESS_MACHINE,
     .class_init = vexpress_a15_class_init,
 };

Andreas

> 
> To be reverted in 10/10.
> 
> Regards,
> Andreas
> 


-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [Qemu-devel] [PATCH 10/10] machine: Set MachineClass::name automatically
  2015-09-19  6:23   ` Andreas Färber
@ 2015-09-19  6:39     ` Andreas Färber
  0 siblings, 0 replies; 40+ messages in thread
From: Andreas Färber @ 2015-09-19  6:39 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel; +Cc: Marcel Apfelbaum, David Gibson

Am 19.09.2015 um 08:23 schrieb Andreas Färber:
> Am 20.08.2015 um 23:54 schrieb Eduardo Habkost:
>> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
>> index 5ba4b80..af985f6 100644
>> --- a/hw/arm/virt.c
>> +++ b/hw/arm/virt.c
>> @@ -960,7 +960,6 @@ static void virt_class_init(ObjectClass *oc, void *data)
>>  {
>>      MachineClass *mc = MACHINE_CLASS(oc);
>>  
>> -    mc->name = VIRT_MACHINE_NAME;
>>      mc->desc = "ARM Virtual Machine",
>>      mc->init = machvirt_init;
>>      mc->max_cpus = 8;
> 
> I am going to squash the following cleanup reverting 04/10 change:
> 
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 49eb4fa..6bf0d6d 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -83,8 +83,7 @@ typedef struct {
>      bool highmem;
>  } VirtMachineState;
> 
> -#define VIRT_MACHINE_NAME   "virt"
> -#define TYPE_VIRT_MACHINE   MACHINE_TYPE_NAME(VIRT_MACHINE_NAME)
> +#define TYPE_VIRT_MACHINE   MACHINE_TYPE_NAME("virt")
>  #define VIRT_MACHINE(obj) \
>      OBJECT_CHECK(VirtMachineState, (obj), TYPE_VIRT_MACHINE)
>  #define VIRT_MACHINE_GET_CLASS(obj) \

And for my corresponding 03/10 change:

diff --cc hw/arm/vexpress.c
index 2bcd312,f8c46aa..0000000
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@@ -168,10 -168,10 +168,8 @@@ typedef struct
  } VexpressMachineState;

  #define TYPE_VEXPRESS_MACHINE   "vexpress"
--#define VEXPRESS_A9_MACHINE_NAME "vexpress-a9"
--#define VEXPRESS_A15_MACHINE_NAME "vexpress-a15"
--#define TYPE_VEXPRESS_A9_MACHINE
MACHINE_TYPE_NAME(VEXPRESS_A9_MACHINE_NAME)
--#define TYPE_VEXPRESS_A15_MACHINE
MACHINE_TYPE_NAME(VEXPRESS_A15_MACHINE_NAME)
++#define TYPE_VEXPRESS_A9_MACHINE   MACHINE_TYPE_NAME("vexpress-a9")
++#define TYPE_VEXPRESS_A15_MACHINE   MACHINE_TYPE_NAME("vexpress-a15")
  #define VEXPRESS_MACHINE(obj) \
      OBJECT_CHECK(VexpressMachineState, (obj), TYPE_VEXPRESS_MACHINE)
  #define VEXPRESS_MACHINE_GET_CLASS(obj) \

> 
> Regards,
> Andreas
> 


-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2015-09-19  6:39 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-20 21:54 [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix Eduardo Habkost
2015-08-20 21:54 ` [Qemu-devel] [PATCH 01/10] machine: MACHINE_TYPE_NAME macro Eduardo Habkost
2015-08-25  8:53   ` Marcel Apfelbaum
2015-08-30  5:59   ` David Gibson
2015-08-20 21:54 ` [Qemu-devel] [PATCH 02/10] vexpress: Don't set name on abstract class Eduardo Habkost
2015-08-30  6:42   ` David Gibson
2015-08-20 21:54 ` [Qemu-devel] [PATCH 03/10] vexpress: Rename machine classes to use MACHINE_TYPE_NAME Eduardo Habkost
2015-08-30  6:43   ` David Gibson
2015-09-19  6:30   ` Andreas Färber
2015-09-19  6:37     ` Andreas Färber
2015-08-20 21:54 ` [Qemu-devel] [PATCH 04/10] arm: Rename virt machine class " Eduardo Habkost
2015-08-30  6:43   ` David Gibson
2015-08-20 21:54 ` [Qemu-devel] [PATCH 05/10] pseries: Rename machine class names " Eduardo Habkost
2015-08-30  6:45   ` David Gibson
2015-08-20 21:54 ` [Qemu-devel] [PATCH 06/10] s390-virtio: Rename machine class name " Eduardo Habkost
2015-08-30  6:46   ` David Gibson
2015-08-20 21:54 ` [Qemu-devel] [PATCH 07/10] s390: Rename s390-ccw-virtio-2.4 " Eduardo Habkost
2015-08-30  6:46   ` David Gibson
2015-09-04  8:52   ` Christian Borntraeger
2015-09-04 14:54     ` Eduardo Habkost
2015-09-04 14:56       ` Andreas Färber
2015-09-04 15:06         ` Eduardo Habkost
2015-09-04 15:42           ` Eduardo Habkost
2015-08-20 21:54 ` [Qemu-devel] [PATCH 08/10] mac99: Use MACHINE_TYPE_NAME to encode class name Eduardo Habkost
2015-08-30  6:46   ` David Gibson
2015-08-20 21:54 ` [Qemu-devel] [PATCH 09/10] machine: Ensure all TYPE_MACHINE subclasses have the right suffix Eduardo Habkost
2015-08-25  8:53   ` Marcel Apfelbaum
2015-08-20 21:54 ` [Qemu-devel] [PATCH 10/10] machine: Set MachineClass::name automatically Eduardo Habkost
2015-08-25  8:50   ` Marcel Apfelbaum
2015-08-26 15:02     ` Eduardo Habkost
2015-08-26 16:13       ` Marcel Apfelbaum
2015-09-04 15:46   ` Eduardo Habkost
2015-09-19  6:23   ` Andreas Färber
2015-09-19  6:39     ` Andreas Färber
2015-08-21 10:23 ` [Qemu-devel] [PATCH 00/10] Fix machine class names to use the "-machine" suffix Cornelia Huck
2015-08-21 15:44   ` Eduardo Habkost
2015-09-02 19:58 ` Eduardo Habkost
2015-09-03  7:39   ` Cornelia Huck
2015-09-06 19:25   ` Andreas Färber
2015-09-07  9:05     ` Marcel Apfelbaum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.