Skip to contentSkip to conversation

qmp: Report QOM type name on query-cpu-definitions

PATCH In review Eduardo Habkost 3 participants 5 messages Nov 16, 2016 – Nov 17, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qmp: Report QOM type name on query-cpu-definitions

The new typename attribute on query-cpu-definitions will be used to help management software use device-list-properties to check which properties can be set using -cpu or -global for the CPU model.

---
 qapi-schema.json            | 4 +++-
 target-arm/helper.c         | 1 +
 target-i386/cpu.c           | 1 +
 target-ppc/translate_init.c | 1 +
 target-s390x/cpu_models.c   | 1 +
 5 files changed, 7 insertions(+), 1 deletion(-)
qapi-schema.json +3 -1
index b0b4bf6..9a3bdd4 100644
@@ -3216,6 +3216,8 @@
 # @unavailable-features: #optional List of properties that prevent
 #                        the CPU model from running in the current
 #                        host. (since 2.8)
+# @typename: Type name that can be used as argument to @device-list-properties,
+#            to introspect properties configurable using -cpu or -global.
 #
 # @unavailable-features is a list of QOM property names that
 # represent CPU model attributes that prevent the CPU from running.
@@ -3237,7 +3239,7 @@
 ##
 { 'struct': 'CpuDefinitionInfo',
   'data': { 'name': 'str', '*migration-safe': 'bool', 'static': 'bool',
-            '*unavailable-features': [ 'str' ] } }
+            '*unavailable-features': [ 'str' ], 'typename': 'str' } }
 
 ##
 # @query-cpu-definitions:
target-arm/helper.c +1 -0
index b5b65ca..3fc01b5 100644
@@ -5207,6 +5207,7 @@ static void arm_cpu_add_definition(gpointer data, gpointer user_data)
     info = g_malloc0(sizeof(*info));
     info->name = g_strndup(typename,
                            strlen(typename) - strlen("-" TYPE_ARM_CPU));
+    info->q_typename = g_strdup(typename);
 
     entry = g_malloc0(sizeof(*entry));
     entry->value = info;
target-i386/cpu.c +1 -0
index 6eec5dc..725f6cb 100644
@@ -2239,6 +2239,7 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data)
     info->name = x86_cpu_class_get_model_name(cc);
     x86_cpu_class_check_missing_features(cc, &info->unavailable_features);
     info->has_unavailable_features = true;
+    info->q_typename = g_strdup(object_class_get_name(oc));
 
     entry = g_malloc0(sizeof(*entry));
     entry->value = info;
target-ppc/translate_init.c +1 -0
index 208fa1e..42b9274 100644
@@ -10305,6 +10305,7 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
 
         info = g_malloc0(sizeof(*info));
         info->name = g_strdup(alias->alias);
+        info->q_typename = g_strdup(object_class_get_name(oc));
 
         entry = g_malloc0(sizeof(*entry));
         entry->value = info;
target-s390x/cpu_models.c +1 -0
index c1e729d..5b66d33 100644
@@ -290,6 +290,7 @@ static void create_cpu_model_list(ObjectClass *klass, void *opaque)
     info->has_migration_safe = true;
     info->migration_safe = scc->is_migration_safe;
     info->q_static = scc->is_static;
+    info->q_typename = g_strdup(object_class_get_name(klass));
 
 
     entry = g_malloc0(sizeof(*entry));
Signature · 1 line
2.7.4
#1 lore raw
Quoted 19 lines · Eduardo Habkost

The new typename attribute on query-cpu-definitions will be used to help management software use device-list-properties to check which properties can be set using -cpu or -global for the CPU model.

---
 qapi-schema.json            | 4 +++-
 target-arm/helper.c         | 1 +
 target-i386/cpu.c           | 1 +
 target-ppc/translate_init.c | 1 +
 target-s390x/cpu_models.c   | 1 +
 5 files changed, 7 insertions(+), 1 deletion(-)
qapi-schema.json +0 -0
index b0b4bf6..9a3bdd4 100644

qapi-schema.json line 3220

Quoted 5 lines
qapi-schema.json +2 -0
@@ -3216,6 +3216,8 @@
 # @unavailable-features: #optional List of properties that prevent
 #                        the CPU model from running in the current
 #                        host. (since 2.8)
+# @typename: Type name that can be used as argument to @device-list-properties,
+#            to introspect properties configurable using -cpu or -global.

Missing a '(since 2.9)' designation.

Quoted 10 lines
qapi-schema.json +1 -1
 #
 # @unavailable-features is a list of QOM property names that
 # represent CPU model attributes that prevent the CPU from running.
@@ -3237,7 +3239,7 @@
 ##
 { 'struct': 'CpuDefinitionInfo',
   'data': { 'name': 'str', '*migration-safe': 'bool', 'static': 'bool',
-            '*unavailable-features': [ 'str' ] } }
+            '*unavailable-features': [ 'str' ], 'typename': 'str' } }
 
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#2 lore raw
Quoted 15 lines · Eric Blake
Quoted 14 lines · Eduardo Habkost

The new typename attribute on query-cpu-definitions will be used to help management software use device-list-properties to check which properties can be set using -cpu or -global for the CPU model.

---
 qapi-schema.json            | 4 +++-
 target-arm/helper.c         | 1 +
 target-i386/cpu.c           | 1 +
 target-ppc/translate_init.c | 1 +
 target-s390x/cpu_models.c   | 1 +
 5 files changed, 7 insertions(+), 1 deletion(-)
Quoted 12 lines

qapi-schema.json line 3220

Quoted 10 lines
qapi-schema.json +2 -0
index b0b4bf6..9a3bdd4 100644
@@ -3216,6 +3216,8 @@
 # @unavailable-features: #optional List of properties that prevent
 #                        the CPU model from running in the current
 #                        host. (since 2.8)
+# @typename: Type name that can be used as argument to @device-list-properties,
+#            to introspect properties configurable using -cpu or -global.

Missing a '(since 2.9)' designation.

Oops. I will add it the next version. Thanks!

Quoted 16 lines
Quoted 11 lines
qapi-schema.json +1 -1
 #
 # @unavailable-features is a list of QOM property names that
 # represent CPU model attributes that prevent the CPU from running.
@@ -3237,7 +3239,7 @@
 ##
 { 'struct': 'CpuDefinitionInfo',
   'data': { 'name': 'str', '*migration-safe': 'bool', 'static': 'bool',
-            '*unavailable-features': [ 'str' ] } }
+            '*unavailable-features': [ 'str' ], 'typename': 'str' } }
 
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Signature · 1 line
Eduardo
Reviewed-by on v1 1/1
#3 lore raw
In reply to Eduardo Habkost
Quoted 77 lines · Eduardo Habkost

The new typename attribute on query-cpu-definitions will be used to help management software use device-list-properties to check which properties can be set using -cpu or -global for the CPU model.

---
 qapi-schema.json            | 4 +++-
 target-arm/helper.c         | 1 +
 target-i386/cpu.c           | 1 +
 target-ppc/translate_init.c | 1 +
 target-s390x/cpu_models.c   | 1 +
 5 files changed, 7 insertions(+), 1 deletion(-)
qapi-schema.json +3 -1
index b0b4bf6..9a3bdd4 100644
@@ -3216,6 +3216,8 @@
 # @unavailable-features: #optional List of properties that prevent
 #                        the CPU model from running in the current
 #                        host. (since 2.8)
+# @typename: Type name that can be used as argument to @device-list-properties,
+#            to introspect properties configurable using -cpu or -global.
 #
 # @unavailable-features is a list of QOM property names that
 # represent CPU model attributes that prevent the CPU from running.
@@ -3237,7 +3239,7 @@
 ##
 { 'struct': 'CpuDefinitionInfo',
   'data': { 'name': 'str', '*migration-safe': 'bool', 'static': 'bool',
-            '*unavailable-features': [ 'str' ] } }
+            '*unavailable-features': [ 'str' ], 'typename': 'str' } }
 
 ##
 # @query-cpu-definitions:
target-arm/helper.c +1 -0
index b5b65ca..3fc01b5 100644
@@ -5207,6 +5207,7 @@ static void arm_cpu_add_definition(gpointer data, gpointer user_data)
     info = g_malloc0(sizeof(*info));
     info->name = g_strndup(typename,
                            strlen(typename) - strlen("-" TYPE_ARM_CPU));
+    info->q_typename = g_strdup(typename);
 
     entry = g_malloc0(sizeof(*entry));
     entry->value = info;
target-i386/cpu.c +1 -0
index 6eec5dc..725f6cb 100644
@@ -2239,6 +2239,7 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data)
     info->name = x86_cpu_class_get_model_name(cc);
     x86_cpu_class_check_missing_features(cc, &info->unavailable_features);
     info->has_unavailable_features = true;
+    info->q_typename = g_strdup(object_class_get_name(oc));
 
     entry = g_malloc0(sizeof(*entry));
     entry->value = info;
target-ppc/translate_init.c +1 -0
index 208fa1e..42b9274 100644
@@ -10305,6 +10305,7 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
 
         info = g_malloc0(sizeof(*info));
         info->name = g_strdup(alias->alias);
+        info->q_typename = g_strdup(object_class_get_name(oc));
 
         entry = g_malloc0(sizeof(*entry));
         entry->value = info;
target-s390x/cpu_models.c +0 -0
index c1e729d..5b66d33 100644

target-s390x/cpu_models.c static void create_cpu_model_list(ObjectClass *klass, void *opaque) · line 296

Quoted 7 lines
target-s390x/cpu_models.c +1 -0
@@ -290,6 +290,7 @@ static void create_cpu_model_list(ObjectClass *klass, void *opaque)
     info->has_migration_safe = true;
     info->migration_safe = scc->is_migration_safe;
     info->q_static = scc->is_static;
+    info->q_typename = g_strdup(object_class_get_name(klass));
 
 
     entry = g_malloc0(sizeof(*entry));

A bit sad that the QOM type name needs to be computed in target-dependent code.

With Eric's doc fix:

#4 lore raw

On Thu, Nov 17, 2016 at 01:38:54PM +0100, Markus Armbruster wrote:
[...]

Quoted 2 lines

A bit sad that the QOM type name needs to be computed in target-dependent code.

I plan to provide a generic implementation of
query-cpu-definitions later, to fix this.

Quoted 3 lines

With Eric's doc fix:

Thanks!

Signature · 1 line
Eduardo