From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Igor Mammedov" <imammedo@redhat.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [RFC 3/6] target-i386: Simplify cpu_x86_find_by_name() logic
Date: Fri, 4 Jan 2013 17:56:19 -0200 [thread overview]
Message-ID: <1357329382-20944-4-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1357329382-20944-1-git-send-email-ehabkost@redhat.com>
Move the check for "host" to beginning of function, so instead of a
confusing if/else-if/else mess we now have just two obvious if/else
blocks:
1) Special case for "host";
2) General case for CPU model lookup on x86_defs list.
This way, we will be able to easily move those two parts to separate
class instance_init functions.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
target-i386/cpu.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 6c75327..a2ac3c3 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1250,20 +1250,24 @@ static void cpudef_2_x86_cpu(X86CPU *cpu, x86_def_t *def, Error **errp)
static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *name)
{
- x86_def_t *def;
- for (def = x86_defs; def; def = def->next) {
- if (name && !strcmp(name, def->name)) {
- break;
- }
- }
if (kvm_enabled() && name && strcmp(name, "host") == 0) {
#ifdef CONFIG_KVM
kvm_cpu_fill_host(x86_cpu_def);
#endif
- } else if (!def) {
- return -1;
} else {
+ x86_def_t *def;
+
+ for (def = x86_defs; def; def = def->next) {
+ if (name && !strcmp(name, def->name)) {
+ break;
+ }
+ }
+
+ if (!def) {
+ return -1;
+ }
+
memcpy(x86_cpu_def, def, sizeof(*def));
/* sysenter isn't supported on compatibility mode on AMD, syscall
* isn't supported in compatibility mode on Intel.
--
1.7.11.7
next prev parent reply other threads:[~2013-01-04 19:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-04 19:56 [Qemu-devel] [RFC 0/6] x86 CPU subclasses, v4 Eduardo Habkost
2013-01-04 19:56 ` [Qemu-devel] [RFC 1/6] target-i386: Move CPU object creation to cpu.c Eduardo Habkost
2013-01-04 19:56 ` [Qemu-devel] [RFC 2/6] target-i386: Make cpu_x86_create() get Error argument Eduardo Habkost
2013-01-04 19:56 ` Eduardo Habkost [this message]
2013-01-04 19:56 ` [Qemu-devel] [RFC 4/6] target-i386: Set feature string parsing results directly on CPU object Eduardo Habkost
2013-01-04 19:56 ` [Qemu-devel] [RFC 5/6] target-i386: Move kvm_features/hypervisor initialization to cpu_x86_find_by_name() Eduardo Habkost
2013-01-04 19:56 ` [Qemu-devel] [RFC 6/6] target-i386: CPU model subclasses Eduardo Habkost
2013-01-04 22:08 ` Eduardo Habkost
2013-01-04 22:07 ` [Qemu-devel] [RFC 0/6] x86 CPU subclasses, v4 Eduardo Habkost
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=1357329382-20944-4-git-send-email-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=afaerber@suse.de \
--cc=imammedo@redhat.com \
--cc=qemu-devel@nongnu.org \
/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: link
Be 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).