[RFC,5/5] target-i386: Report QOM class name for CPU definitions

Submitted by Eduardo Habkost on April 30, 2014, 8:29 p.m.

Details

Message ID 1398889773-14652-6-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost April 30, 2014, 8:29 p.m.
The new qom-type attributed will be used to indicate that the object-add
QMP command can be used to create CPU objects. This will let management
code to create multiple CPU objects from different classes and CPU
models and query for their information using QOM properties (like the
"feature-words" properties) in a single QEMU instance, instead of having
to re-run QEMU once for each CPU model.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qapi-schema.json  | 6 +++++-
 target-i386/cpu.c | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/qapi-schema.json b/qapi-schema.json
index 0b00427..7d8bec5 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3438,11 +3438,15 @@ 
 # Virtual CPU definition.
 #
 # @name: the name of the CPU definition
+# @qom-type: the name of the QOM class for the CPU model. The presence
+#            of this attribute indicates that CPU objects can be created
+#            using object-add.
+#            (since: 2.1.0)
 #
 # Since: 1.2.0
 ##
 { 'type': 'CpuDefinitionInfo',
-  'data': { 'name': 'str' } }
+  'data': { 'name': 'str', '*qom-type': 'str' } }
 
 ##
 # @query-cpu-definitions:
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 2417fc8..897caa4 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1828,6 +1828,8 @@  CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
         def = &builtin_x86_defs[i];
         info = g_malloc0(sizeof(*info));
         info->name = g_strdup(def->name);
+        info->has_qom_type = true;
+        info->qom_type = x86_cpu_type_name(def->name);
 
         entry = g_malloc0(sizeof(*entry));
         entry->value = info;