[01/10] machine: MACHINE_TYPE_NAME macro
diff mbox

Message ID 1440107676-17326-2-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost Aug. 20, 2015, 9:54 p.m. UTC
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(-)

Comments

Marcel Apfelbaum Aug. 25, 2015, 8:53 a.m. UTC | #1
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
David Gibson Aug. 30, 2015, 5:59 a.m. UTC | #2
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>

Patch
diff mbox

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,