diff options
author | Matthew Rosato <mjrosato@linux.vnet.ibm.com> | 2016-03-04 12:34:34 -0500 |
---|---|---|
committer | Timothy Pearson <tpearson@raptorengineering.com> | 2019-11-29 19:49:36 -0600 |
commit | c7f581f89a104e5aba8d0d957ea118df653ffb22 (patch) | |
tree | dc3264e1f13cf75654fd09563093c8d74748329d /target-s390x/helper.c | |
parent | 07ed2da5fab572a66a646c269a73634051d86ae6 (diff) | |
download | hqemu-c7f581f89a104e5aba8d0d957ea118df653ffb22.zip hqemu-c7f581f89a104e5aba8d0d957ea118df653ffb22.tar.gz |
s390x/cpu: Add error handling to cpu creation
Check for and propogate errors during s390 cpu creation.
Signed-off-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
Message-Id: <1457112875-5209-7-git-send-email-mjrosato@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Diffstat (limited to 'target-s390x/helper.c')
-rw-r--r-- | target-s390x/helper.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/target-s390x/helper.c b/target-s390x/helper.c index 838bdd9..76d5fbe 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -65,14 +65,51 @@ void s390x_cpu_timer(void *opaque) } #endif -S390CPU *cpu_s390x_init(const char *cpu_model) +S390CPU *cpu_s390x_create(const char *cpu_model, Error **errp) { S390CPU *cpu; cpu = S390_CPU(object_new(TYPE_S390_CPU)); - object_property_set_bool(OBJECT(cpu), true, "realized", NULL); + return cpu; +} + +S390CPU *s390x_new_cpu(const char *cpu_model, int64_t id, Error **errp) +{ + S390CPU *cpu; + Error *err = NULL; + + cpu = cpu_s390x_create(cpu_model, &err); + if (err != NULL) { + goto out; + } + + object_property_set_int(OBJECT(cpu), id, "id", &err); + if (err != NULL) { + goto out; + } + object_property_set_bool(OBJECT(cpu), true, "realized", &err); +out: + if (err) { + error_propagate(errp, err); + object_unref(OBJECT(cpu)); + cpu = NULL; + } + return cpu; +} + +S390CPU *cpu_s390x_init(const char *cpu_model) +{ + Error *err = NULL; + S390CPU *cpu; + /* Use to track CPU ID for linux-user only */ + static int64_t next_cpu_id; + + cpu = s390x_new_cpu(cpu_model, next_cpu_id++, &err); + if (err) { + error_report_err(err); + } return cpu; } |