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 4/6] target-i386: Set feature string parsing results directly on CPU object
Date: Fri, 4 Jan 2013 17:56:20 -0200 [thread overview]
Message-ID: <1357329382-20944-5-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1357329382-20944-1-git-send-email-ehabkost@redhat.com>
Note that this is temporary: just like we would eventually kill usage of
x86_def_t inside cpu_x86_parse_featurestr(), we will eventually kill
usage of X86CPU inside that function as well.
This will help us keep the x86_def_t usage restricted to the CPU object
creation code.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
target-i386/cpu.c | 37 +++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index a2ac3c3..54be18c 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1303,7 +1303,7 @@ static void cpu_x86_set_props(X86CPU *cpu, QDict *features, Error **errp)
/* Parse "+feature,-feature,feature=foo" CPU feature string
*/
-static int cpu_x86_parse_featurestr(x86_def_t *x86_cpu_def, char *features,
+static int cpu_x86_parse_featurestr(X86CPU *cpu, char *features,
QDict **props)
{
char *featurestr; /* Single 'key=value" string being parsed */
@@ -1374,7 +1374,7 @@ static int cpu_x86_parse_featurestr(x86_def_t *x86_cpu_def, char *features,
fprintf(stderr, "bad numerical value %s\n", val);
goto error;
}
- x86_cpu_def->tsc_khz = tsc_freq / 1000;
+ cpu->env.tsc_khz = tsc_freq / 1000;
} else if (!strcmp(featurestr, "hv_spinlocks")) {
char *err;
numvalue = strtoul(val, &err, 0);
@@ -1400,20 +1400,20 @@ static int cpu_x86_parse_featurestr(x86_def_t *x86_cpu_def, char *features,
goto error;
}
}
- x86_cpu_def->features |= plus_features;
- x86_cpu_def->ext_features |= plus_ext_features;
- x86_cpu_def->ext2_features |= plus_ext2_features;
- x86_cpu_def->ext3_features |= plus_ext3_features;
- x86_cpu_def->kvm_features |= plus_kvm_features;
- x86_cpu_def->svm_features |= plus_svm_features;
- x86_cpu_def->cpuid_7_0_ebx_features |= plus_7_0_ebx_features;
- x86_cpu_def->features &= ~minus_features;
- x86_cpu_def->ext_features &= ~minus_ext_features;
- x86_cpu_def->ext2_features &= ~minus_ext2_features;
- x86_cpu_def->ext3_features &= ~minus_ext3_features;
- x86_cpu_def->kvm_features &= ~minus_kvm_features;
- x86_cpu_def->svm_features &= ~minus_svm_features;
- x86_cpu_def->cpuid_7_0_ebx_features &= ~minus_7_0_ebx_features;
+ cpu->env.cpuid_features |= plus_features;
+ cpu->env.cpuid_ext_features |= plus_ext_features;
+ cpu->env.cpuid_ext2_features |= plus_ext2_features;
+ cpu->env.cpuid_ext3_features |= plus_ext3_features;
+ cpu->env.cpuid_kvm_features |= plus_kvm_features;
+ cpu->env.cpuid_svm_features |= plus_svm_features;
+ cpu->env.cpuid_7_0_ebx_features |= plus_7_0_ebx_features;
+ cpu->env.cpuid_features &= ~minus_features;
+ cpu->env.cpuid_ext_features &= ~minus_ext_features;
+ cpu->env.cpuid_ext2_features &= ~minus_ext2_features;
+ cpu->env.cpuid_ext3_features &= ~minus_ext3_features;
+ cpu->env.cpuid_kvm_features &= ~minus_kvm_features;
+ cpu->env.cpuid_svm_features &= ~minus_svm_features;
+ cpu->env.cpuid_7_0_ebx_features &= ~minus_7_0_ebx_features;
g_strfreev(feat_array);
return 0;
@@ -1561,12 +1561,13 @@ X86CPU *cpu_x86_create(const char *cpu_model, Error **errp)
&def->ext3_features, &def->kvm_features,
&def->svm_features, &def->cpuid_7_0_ebx_features);
- if (cpu_x86_parse_featurestr(def, features, &props) < 0) {
+ cpudef_2_x86_cpu(cpu, def, &error);
+
+ if (cpu_x86_parse_featurestr(cpu, features, &props) < 0) {
error_setg(&error, "Invalid cpu_model string format: %s", cpu_model);
goto out;
}
- cpudef_2_x86_cpu(cpu, def, &error);
cpu_x86_set_props(cpu, props, &error);
out:
--
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 ` [Qemu-devel] [RFC 3/6] target-i386: Simplify cpu_x86_find_by_name() logic Eduardo Habkost
2013-01-04 19:56 ` Eduardo Habkost [this message]
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-5-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).