Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
qom: add cpu_generic_init_unrealized()
cpu_generic_init() without realized=true.
Gives board code an opportunity to change
CPU properties.

Signed-off-by: Michael Davidsaver <mdavidsaver@gmail.com>
  • Loading branch information
mdavidsaver committed Feb 20, 2016
1 parent c3bce9d commit 82823fb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
12 changes: 12 additions & 0 deletions include/qom/cpu.h
Expand Up @@ -550,6 +550,18 @@ ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model);
*/
CPUState *cpu_generic_init(const char *typename, const char *cpu_model);

/**
* cpu_generic_init_unrealized:
* @typename: The CPU base type.
* @cpu_model: The model string including optional parameters.
*
* Instantiates a CPU, processes optional parameters but does not realize it.
*
* Returns: A #CPUState or %NULL if an error occurred.
*/
CPUState *cpu_generic_init_unrealized(const char *typename,
const char *cpu_model);

/**
* cpu_has_work:
* @cpu: The vCPU to check.
Expand Down
23 changes: 17 additions & 6 deletions qom/cpu.c
Expand Up @@ -42,6 +42,23 @@ bool cpu_exists(int64_t id)
}

CPUState *cpu_generic_init(const char *typename, const char *cpu_model)
{
CPUState *cpu = cpu_generic_init_unrealized(typename, cpu_model);
if (cpu) {
Error *err = NULL;
object_property_set_bool(OBJECT(cpu), true, "realized", &err);

if (err != NULL) {
error_report_err(err);
object_unref(OBJECT(cpu));
return NULL;
}
}
return cpu;
}

CPUState *cpu_generic_init_unrealized(const char *typename,
const char *cpu_model)
{
char *str, *name, *featurestr;
CPUState *cpu;
Expand All @@ -64,13 +81,7 @@ CPUState *cpu_generic_init(const char *typename, const char *cpu_model)
featurestr = strtok(NULL, ",");
cc->parse_features(cpu, featurestr, &err);
g_free(str);
if (err != NULL) {
goto out;
}

object_property_set_bool(OBJECT(cpu), true, "realized", &err);

out:
if (err != NULL) {
error_report_err(err);
object_unref(OBJECT(cpu));
Expand Down

0 comments on commit 82823fb

Please sign in to comment.