From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, ehabkost@redhat.com, sw@weilnetz.de,
mtosatti@redhat.com, blauwirbel@gmail.com, avi@redhat.com,
jan.kiszka@siemens.com, pbonzini@redhat.com, afaerber@suse.de
Subject: [Qemu-devel] [PATCH qom-next 2/5] target-i386: add cpu-model property to x86_cpu
Date: Tue, 22 May 2012 12:35:51 +0200 [thread overview]
Message-ID: <1337682954-20618-3-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1337682954-20618-1-git-send-email-imammedo@redhat.com>
it's probably intermidiate step till cpu modeled as
sub-classes. After then we probably could drop it.
However it still could be used for overiding default
cpu subclasses definition, and probably renamed to
something like 'features'.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
cpu-defs.h | 2 +-
hw/pc.c | 10 ----------
target-i386/cpu.c | 34 ++++++++++++++++++++++++++++++++++
target-i386/helper.c | 16 ++++++++++++----
4 files changed, 47 insertions(+), 15 deletions(-)
diff --git a/cpu-defs.h b/cpu-defs.h
index f49e950..8f4623c 100644
--- a/cpu-defs.h
+++ b/cpu-defs.h
@@ -221,7 +221,7 @@ typedef struct CPUWatchpoint {
struct QemuCond *halt_cond; \
int thread_kicked; \
struct qemu_work_item *queued_work_first, *queued_work_last; \
- const char *cpu_model_str; \
+ char *cpu_model_str; \
struct KVMState *kvm_state; \
struct kvm_run *kvm_run; \
int kvm_fd; \
diff --git a/hw/pc.c b/hw/pc.c
index 6ad1c0d..00d738d 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -939,7 +939,6 @@ static X86CPU *pc_new_cpu(const char *cpu_model)
cpu = cpu_x86_init(cpu_model);
if (cpu == NULL) {
- fprintf(stderr, "Unable to find x86 CPU definition\n");
exit(1);
}
env = &cpu->env;
@@ -955,15 +954,6 @@ void pc_cpus_init(const char *cpu_model)
{
int i;
- /* init CPUs */
- if (cpu_model == NULL) {
-#ifdef TARGET_X86_64
- cpu_model = "qemu64";
-#else
- cpu_model = "qemu32";
-#endif
- }
-
for(i = 0; i < smp_cpus; i++) {
pc_new_cpu(cpu_model);
}
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index c7c23bf..538892d 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1729,6 +1729,27 @@ static void mce_init(X86CPU *cpu)
}
}
+static char *x86_get_cpu_model(Object *obj, Error **errp)
+{
+ X86CPU *cpu = X86_CPU(obj);
+ CPUX86State *env = &cpu->env;
+ return g_strdup(env->cpu_model_str);
+}
+
+static void x86_set_cpu_model(Object *obj, const char *value, Error **errp)
+{
+ X86CPU *cpu = X86_CPU(obj);
+ CPUX86State *env = &cpu->env;
+
+ g_free((gpointer)env->cpu_model_str);
+ env->cpu_model_str = g_strdup(value);
+
+ if (cpu_x86_register(cpu, env->cpu_model_str) < 0) {
+ fprintf(stderr, "Unable to find x86 CPU definition\n");
+ error_set(errp, QERR_INVALID_PARAMETER_COMBINATION);
+ }
+}
+
void x86_cpu_realize(Object *obj, Error **errp)
{
X86CPU *cpu = X86_CPU(obj);
@@ -1769,7 +1790,20 @@ static void x86_cpu_initfn(Object *obj)
x86_cpuid_get_tsc_freq,
x86_cpuid_set_tsc_freq, NULL, NULL, NULL);
+ object_property_add_str(obj, "cpu-model",
+ x86_get_cpu_model, x86_set_cpu_model, NULL);
+
env->cpuid_apic_id = env->cpu_index;
+
+ /* init various static tables used in TCG mode */
+ if (tcg_enabled() && !inited) {
+ inited = 1;
+ optimize_flags_init();
+#ifndef CONFIG_USER_ONLY
+ prev_debug_excp_handler =
+ cpu_set_debug_excp_handler(breakpoint_handler);
+#endif
+ }
}
static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
diff --git a/target-i386/helper.c b/target-i386/helper.c
index 94f95b7..6fc67a9 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -1160,12 +1160,10 @@ int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector,
X86CPU *cpu_x86_init(const char *cpu_model)
{
X86CPU *cpu;
- CPUX86State *env;
+ Error *errp = NULL;
static int inited;
cpu = X86_CPU(object_new(TYPE_X86_CPU));
- env = &cpu->env;
- env->cpu_model_str = cpu_model;
/* init various static tables used in TCG mode */
if (tcg_enabled() && !inited) {
@@ -1176,7 +1174,17 @@ X86CPU *cpu_x86_init(const char *cpu_model)
cpu_set_debug_excp_handler(breakpoint_handler);
#endif
}
- if (cpu_x86_register(cpu, cpu_model) < 0) {
+
+ if (cpu_model) {
+ object_property_set_str(OBJECT(cpu), cpu_model, "cpu-model", &errp);
+ } else {
+#ifdef TARGET_X86_64
+ object_property_set_str(OBJECT(cpu), "qemu64", "cpu-model", &errp);
+#else
+ object_property_set_str(OBJECT(cpu), "qemu32", "cpu-model", &errp);
+#endif
+ }
+ if (errp) {
object_delete(OBJECT(cpu));
return NULL;
}
--
1.7.7.6
next prev parent reply other threads:[~2012-05-22 10:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-22 10:35 [Qemu-devel] [PATCH qom-next 0/5] target-i386: re-factor CPU creation/initialization to QOM Igor Mammedov
2012-05-22 10:35 ` [Qemu-devel] [PATCH qom-next 1/5] target-i386: move cpu halted decision into x86_cpu_reset Igor Mammedov
2012-05-22 10:59 ` Peter Maydell
2012-05-22 12:34 ` Igor Mammedov
2012-05-22 10:35 ` Igor Mammedov [this message]
2012-05-22 10:35 ` [Qemu-devel] [PATCH qom-next 3/5] pc: move apic_mapped initialization into common apic init code Igor Mammedov
2012-05-22 10:48 ` Jan Kiszka
2012-05-22 12:42 ` Igor Mammedov
2012-05-22 14:24 ` Andreas Färber
2012-05-22 14:35 ` Jan Kiszka
2012-05-22 15:47 ` Paolo Bonzini
2012-05-23 9:17 ` Igor Mammedov
2012-05-22 10:51 ` Jan Kiszka
2012-05-22 10:35 ` [Qemu-devel] [PATCH qom-next 4/5] target-i386: make initialize CPU in QOM way Igor Mammedov
2012-05-22 10:56 ` Jan Kiszka
2012-05-22 12:47 ` Igor Mammedov
2012-05-22 10:35 ` [Qemu-devel] [PATCH qom-next 5/5] target-i386: move reset callback to cpu.c 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=1337682954-20618-3-git-send-email-imammedo@redhat.com \
--to=imammedo@redhat.com \
--cc=afaerber@suse.de \
--cc=aliguori@us.ibm.com \
--cc=avi@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=ehabkost@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sw@weilnetz.de \
/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).