From: Eduardo Habkost <ehabkost@redhat.com> To: qemu-devel@nongnu.org Cc: Peter Maydell <peter.maydell@linaro.org>, Richard Henderson <rth@twiddle.net>, Igor Mammedov <imammedo@redhat.com>, Cornelia Huck <cohuck@redhat.com>, David Hildenbrand <david@redhat.com>, qemu-s390x@nongnu.org, Markus Armbruster <armbru@redhat.com> Subject: [Qemu-devel] [PATCH 1/7] cpu: Change return type of cpu_class_by_name() to CPUClass Date: Fri, 19 Apr 2019 03:14:23 -0300 [thread overview] Message-ID: <20190419061429.17695-2-ehabkost@redhat.com> (raw) In-Reply-To: <20190419061429.17695-1-ehabkost@redhat.com> The function always returns a CPU class. Change the return type to reflect that. I'm not changing the return type of CPUClass::class_by_name() yet, because many of its implementations will be eliminated by the next commits. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- Cc: Cornelia Huck <cohuck@redhat.com> Cc: David Hildenbrand <david@redhat.com> Cc: qemu-s390x@nongnu.org Cc: Markus Armbruster <armbru@redhat.com> --- include/qom/cpu.h | 2 +- exec.c | 8 +++----- qom/cpu.c | 4 ++-- target/s390x/cpu_models.c | 10 +++++----- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index d28c690b27..fefd5c26b0 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -676,7 +676,7 @@ void cpu_reset(CPUState *cpu); * * Returns: A #CPUClass or %NULL if not matching class is found. */ -ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model); +CPUClass *cpu_class_by_name(const char *typename, const char *cpu_model); /** * cpu_create: diff --git a/exec.c b/exec.c index efb1616ece..d303ac5f25 100644 --- a/exec.c +++ b/exec.c @@ -984,7 +984,6 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) const char *parse_cpu_option(const char *cpu_option) { - ObjectClass *oc; CPUClass *cc; gchar **model_pieces; const char *cpu_type; @@ -995,15 +994,14 @@ const char *parse_cpu_option(const char *cpu_option) exit(1); } - oc = cpu_class_by_name(CPU_RESOLVING_TYPE, model_pieces[0]); - if (oc == NULL) { + cc = cpu_class_by_name(CPU_RESOLVING_TYPE, model_pieces[0]); + if (cc == NULL) { error_report("unable to find CPU model '%s'", model_pieces[0]); g_strfreev(model_pieces); exit(EXIT_FAILURE); } - cpu_type = object_class_get_name(oc); - cc = CPU_CLASS(oc); + cpu_type = object_class_get_name(OBJECT_CLASS(cc)); cc->parse_features(cpu_type, model_pieces[1], &error_fatal); g_strfreev(model_pieces); return cpu_type; diff --git a/qom/cpu.c b/qom/cpu.c index a8d2958956..b971a56242 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -283,12 +283,12 @@ static bool cpu_common_has_work(CPUState *cs) return false; } -ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model) +CPUClass *cpu_class_by_name(const char *typename, const char *cpu_model) { CPUClass *cc = CPU_CLASS(object_class_by_name(typename)); assert(cpu_model && cc->class_by_name); - return cc->class_by_name(cpu_model); + return CPU_CLASS(cc->class_by_name(cpu_model)); } static void cpu_common_parse_features(const char *typename, char *features, diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index eb125d4d0d..391698595f 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -482,7 +482,7 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info, const QDict *qdict = NULL; const QDictEntry *e; Visitor *visitor; - ObjectClass *oc; + CPUClass *cc; S390CPU *cpu; Object *obj; @@ -494,16 +494,16 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info, } } - oc = cpu_class_by_name(TYPE_S390_CPU, info->name); - if (!oc) { + cc = cpu_class_by_name(TYPE_S390_CPU, info->name); + if (!cc) { error_setg(errp, "The CPU definition \'%s\' is unknown.", info->name); return; } - if (S390_CPU_CLASS(oc)->kvm_required && !kvm_enabled()) { + if (S390_CPU_CLASS(cc)->kvm_required && !kvm_enabled()) { error_setg(errp, "The CPU definition '%s' requires KVM", info->name); return; } - obj = object_new(object_class_get_name(oc)); + obj = object_new(object_class_get_name(OBJECT_CLASS(cc))); cpu = S390_CPU(obj); if (!cpu->model) { -- 2.18.0.rc1.1.g3f1ff2140
WARNING: multiple messages have this Message-ID (diff)
From: Eduardo Habkost <ehabkost@redhat.com> To: qemu-devel@nongnu.org Cc: Peter Maydell <peter.maydell@linaro.org>, David Hildenbrand <david@redhat.com>, Cornelia Huck <cohuck@redhat.com>, Markus Armbruster <armbru@redhat.com>, qemu-s390x@nongnu.org, Igor Mammedov <imammedo@redhat.com>, Richard Henderson <rth@twiddle.net> Subject: [Qemu-devel] [PATCH 1/7] cpu: Change return type of cpu_class_by_name() to CPUClass Date: Fri, 19 Apr 2019 03:14:23 -0300 [thread overview] Message-ID: <20190419061429.17695-2-ehabkost@redhat.com> (raw) Message-ID: <20190419061423.08ikpfF7wF9z3JeCpQqkYbtfs-CS-PbtzPZYPP3KejU@z> (raw) In-Reply-To: <20190419061429.17695-1-ehabkost@redhat.com> The function always returns a CPU class. Change the return type to reflect that. I'm not changing the return type of CPUClass::class_by_name() yet, because many of its implementations will be eliminated by the next commits. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- Cc: Cornelia Huck <cohuck@redhat.com> Cc: David Hildenbrand <david@redhat.com> Cc: qemu-s390x@nongnu.org Cc: Markus Armbruster <armbru@redhat.com> --- include/qom/cpu.h | 2 +- exec.c | 8 +++----- qom/cpu.c | 4 ++-- target/s390x/cpu_models.c | 10 +++++----- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index d28c690b27..fefd5c26b0 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -676,7 +676,7 @@ void cpu_reset(CPUState *cpu); * * Returns: A #CPUClass or %NULL if not matching class is found. */ -ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model); +CPUClass *cpu_class_by_name(const char *typename, const char *cpu_model); /** * cpu_create: diff --git a/exec.c b/exec.c index efb1616ece..d303ac5f25 100644 --- a/exec.c +++ b/exec.c @@ -984,7 +984,6 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) const char *parse_cpu_option(const char *cpu_option) { - ObjectClass *oc; CPUClass *cc; gchar **model_pieces; const char *cpu_type; @@ -995,15 +994,14 @@ const char *parse_cpu_option(const char *cpu_option) exit(1); } - oc = cpu_class_by_name(CPU_RESOLVING_TYPE, model_pieces[0]); - if (oc == NULL) { + cc = cpu_class_by_name(CPU_RESOLVING_TYPE, model_pieces[0]); + if (cc == NULL) { error_report("unable to find CPU model '%s'", model_pieces[0]); g_strfreev(model_pieces); exit(EXIT_FAILURE); } - cpu_type = object_class_get_name(oc); - cc = CPU_CLASS(oc); + cpu_type = object_class_get_name(OBJECT_CLASS(cc)); cc->parse_features(cpu_type, model_pieces[1], &error_fatal); g_strfreev(model_pieces); return cpu_type; diff --git a/qom/cpu.c b/qom/cpu.c index a8d2958956..b971a56242 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -283,12 +283,12 @@ static bool cpu_common_has_work(CPUState *cs) return false; } -ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model) +CPUClass *cpu_class_by_name(const char *typename, const char *cpu_model) { CPUClass *cc = CPU_CLASS(object_class_by_name(typename)); assert(cpu_model && cc->class_by_name); - return cc->class_by_name(cpu_model); + return CPU_CLASS(cc->class_by_name(cpu_model)); } static void cpu_common_parse_features(const char *typename, char *features, diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index eb125d4d0d..391698595f 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -482,7 +482,7 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info, const QDict *qdict = NULL; const QDictEntry *e; Visitor *visitor; - ObjectClass *oc; + CPUClass *cc; S390CPU *cpu; Object *obj; @@ -494,16 +494,16 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info, } } - oc = cpu_class_by_name(TYPE_S390_CPU, info->name); - if (!oc) { + cc = cpu_class_by_name(TYPE_S390_CPU, info->name); + if (!cc) { error_setg(errp, "The CPU definition \'%s\' is unknown.", info->name); return; } - if (S390_CPU_CLASS(oc)->kvm_required && !kvm_enabled()) { + if (S390_CPU_CLASS(cc)->kvm_required && !kvm_enabled()) { error_setg(errp, "The CPU definition '%s' requires KVM", info->name); return; } - obj = object_new(object_class_get_name(oc)); + obj = object_new(object_class_get_name(OBJECT_CLASS(cc))); cpu = S390_CPU(obj); if (!cpu->model) { -- 2.18.0.rc1.1.g3f1ff2140
next prev parent reply other threads:[~2019-04-19 6:14 UTC|newest] Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-04-19 6:14 [Qemu-devel] [PATCH 0/7] Delete 16 *_cpu_class_by_name() functions Eduardo Habkost 2019-04-19 6:14 ` Eduardo Habkost 2019-04-19 6:14 ` Eduardo Habkost [this message] 2019-04-19 6:14 ` [Qemu-devel] [PATCH 1/7] cpu: Change return type of cpu_class_by_name() to CPUClass Eduardo Habkost 2019-04-19 6:14 ` [Qemu-devel] [PATCH 2/7] riscv: Don't split CPU model string Eduardo Habkost 2019-04-19 6:14 ` Eduardo Habkost 2019-04-19 21:00 ` Alistair Francis 2019-04-19 21:00 ` Alistair Francis 2019-04-19 6:14 ` [Qemu-devel] [PATCH 3/7] arm: " Eduardo Habkost 2019-04-19 6:14 ` Eduardo Habkost 2019-04-19 6:14 ` [Qemu-devel] [PATCH 4/7] arm: Remove special case for "any" CPU model Eduardo Habkost 2019-04-19 6:14 ` Eduardo Habkost 2019-04-19 6:14 ` [Qemu-devel] [PATCH 5/7] cpu: Let architectures set CPU class name format Eduardo Habkost 2019-04-19 6:14 ` Eduardo Habkost 2019-05-06 11:42 ` Markus Armbruster 2019-05-08 5:52 ` Markus Armbruster 2019-04-19 6:14 ` [Qemu-devel] [PATCH 6/7] cpu: Set class name format for some architectures Eduardo Habkost 2019-04-19 6:14 ` Eduardo Habkost 2019-04-19 20:59 ` Alistair Francis 2019-04-19 20:59 ` Alistair Francis 2019-04-19 6:14 ` [Qemu-devel] [PATCH 7/7] cpu: Set fixed class name on " Eduardo Habkost 2019-04-19 6:14 ` Eduardo Habkost 2019-05-06 11:53 ` [Qemu-devel] [PATCH 0/7] Delete 16 *_cpu_class_by_name() functions Markus Armbruster 2019-05-06 19:53 ` Eduardo Habkost 2019-05-08 8:34 ` Markus Armbruster 2019-05-08 19:46 ` Eduardo Habkost 2019-05-09 5:55 ` Markus Armbruster 2019-05-09 15:46 ` Igor Mammedov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190419061429.17695-2-ehabkost@redhat.com \ --to=ehabkost@redhat.com \ --cc=armbru@redhat.com \ --cc=cohuck@redhat.com \ --cc=david@redhat.com \ --cc=imammedo@redhat.com \ --cc=peter.maydell@linaro.org \ --cc=qemu-devel@nongnu.org \ --cc=qemu-s390x@nongnu.org \ --cc=rth@twiddle.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).