Skip to content

Commit

Permalink
i386: Improve query-cpu-model-expansion full mode
Browse files Browse the repository at this point in the history
This keeps the same results on type=static expansion, but make
type=full expansion return every single QOM property on the CPU
object that have a different value from the "base' CPU model,
plus all the CPU feature flag properties.

Cc: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <20170222190029.17243-4-ehabkost@redhat.com>
Tested-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
  • Loading branch information
ehabkost committed Feb 27, 2017
1 parent f99fd7c commit b8097de
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions target/i386/cpu.c
Expand Up @@ -2419,6 +2419,34 @@ static void x86_cpu_to_dict(X86CPU *cpu, QDict *props)
}
}

/* Convert CPU model data from X86CPU object to a property dictionary
* that can recreate exactly the same CPU model, including every
* writeable QOM property.
*/
static void x86_cpu_to_dict_full(X86CPU *cpu, QDict *props)
{
ObjectPropertyIterator iter;
ObjectProperty *prop;

object_property_iter_init(&iter, OBJECT(cpu));
while ((prop = object_property_iter_next(&iter))) {
/* skip read-only or write-only properties */
if (!prop->get || !prop->set) {
continue;
}

/* "hotplugged" is the only property that is configurable
* on the command-line but will be set differently on CPUs
* created using "-cpu ... -smp ..." and by CPUs created
* on the fly by x86_cpu_from_model() for querying. Skip it.
*/
if (!strcmp(prop->name, "hotplugged")) {
continue;
}
x86_cpu_expand_prop(cpu, props, prop->name);
}
}

static void object_apply_props(Object *obj, QDict *props, Error **errp)
{
const QDictEntry *prop;
Expand Down Expand Up @@ -2489,21 +2517,21 @@ arch_query_cpu_model_expansion(CpuModelExpansionType type,
goto out;
}

props = qdict_new();

switch (type) {
case CPU_MODEL_EXPANSION_TYPE_STATIC:
/* Static expansion will be based on "base" only */
base_name = "base";
x86_cpu_to_dict(xc, props);
break;
case CPU_MODEL_EXPANSION_TYPE_FULL:
/* As we don't return every single property, full expansion needs
* to keep the original model name+props, and add extra
* properties on top of that.
*/
base_name = model->name;
if (model->has_props && model->props) {
props = qdict_clone_shallow(qobject_to_qdict(model->props));
}
x86_cpu_to_dict_full(xc, props);
break;
default:
error_setg(&err, "Unsupportted expansion type");
Expand Down

0 comments on commit b8097de

Please sign in to comment.