diff options
author | Igor Mammedov <imammedo@redhat.com> | 2017-09-13 18:04:54 +0200 |
---|---|---|
committer | Eduardo Habkost <ehabkost@redhat.com> | 2017-09-19 09:09:32 -0300 |
commit | 4482e05cbbb7e50e476f6a9500cf0b38913bd939 (patch) | |
tree | c2135cfd57c8f7fe0c50ddf19e43e98479383c08 /qom | |
parent | 3c72234c98004a01d79a24f78b07053cfebd0f22 (diff) |
cpu: make cpu_generic_init() abort QEMU on error
Almost every user of cpu_generic_init() checks for
returned NULL and then reports failure in a custom way
and aborts process.
Some users assume that call can't fail and don't check
for failure, though they should have checked for it.
In either cases cpu_generic_init() failure is fatal,
so instead of checking for failure and reporting
it various ways, make cpu_generic_init() report
errors in consistent way and terminate QEMU on failure.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <1505318697-77161-3-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'qom')
-rw-r--r-- | qom/cpu.c | 19 |
1 files changed, 5 insertions, 14 deletions
@@ -62,7 +62,7 @@ CPUState *cpu_create(const char *typename) if (err != NULL) { error_report_err(err); object_unref(OBJECT(cpu)); - return NULL; + exit(EXIT_FAILURE); } return cpu; } @@ -71,7 +71,6 @@ const char *cpu_parse_cpu_model(const char *typename, const char *cpu_model) { ObjectClass *oc; CPUClass *cc; - Error *err = NULL; gchar **model_pieces; const char *cpu_type; @@ -79,18 +78,15 @@ const char *cpu_parse_cpu_model(const char *typename, const char *cpu_model) oc = cpu_class_by_name(typename, model_pieces[0]); if (oc == NULL) { + error_report("unable to find CPU model '%s'", model_pieces[0]); g_strfreev(model_pieces); - return NULL; + exit(EXIT_FAILURE); } cpu_type = object_class_get_name(oc); cc = CPU_CLASS(oc); - cc->parse_features(cpu_type, model_pieces[1], &err); + cc->parse_features(cpu_type, model_pieces[1], &error_fatal); g_strfreev(model_pieces); - if (err != NULL) { - error_report_err(err); - return NULL; - } return cpu_type; } @@ -99,12 +95,7 @@ CPUState *cpu_generic_init(const char *typename, const char *cpu_model) /* TODO: all callers of cpu_generic_init() need to be converted to * call cpu_parse_features() only once, before calling cpu_generic_init(). */ - const char *cpu_type = cpu_parse_cpu_model(typename, cpu_model); - - if (cpu_type) { - return cpu_create(cpu_type); - } - return NULL; + return cpu_create(cpu_parse_cpu_model(typename, cpu_model)); } bool cpu_paging_enabled(const CPUState *cpu) |