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] [PATCH 1/2] target-i386: move CPU object creation to cpu.c
Date: Mon, 10 Dec 2012 22:30:42 -0200 [thread overview]
Message-ID: <1355185843-19682-2-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1355185843-19682-1-git-send-email-ehabkost@redhat.com>
As we will need to create the CPU object after splitting the CPU model
string (because we're going to use different subclasses for each CPU
model), move the CPU object creation to cpu_x86_register(), and at the
same time rename cpu_x86_register() to cpu_x86_create().
This will also simplify the CPU creation code to a trivial
cpu_x86_create()+cpu_x86_realize() sequence. This will be useful for
code that have to set additional properties before cpu_x86_realize() is
called (e.g. the PC CPU initialization code, that needs to set APIC IDs
depending on the CPU cores/threads topology).
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
target-i386/cpu.c | 17 +++++++++++++----
target-i386/cpu.h | 2 +-
target-i386/helper.c | 9 ++-------
3 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 7be3ad8..044e2d9 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1488,14 +1488,22 @@ static void filter_features_for_kvm(X86CPU *cpu)
}
#endif
-int cpu_x86_register(X86CPU *cpu, const char *cpu_model)
+/* Create and initialize a X86CPU object, based on the full CPU model string
+ * (that may include "+feature,-feature,feature=xxx" feature strings)
+ */
+X86CPU *cpu_x86_create(const char *cpu_model)
{
- CPUX86State *env = &cpu->env;
+ X86CPU *cpu;
+ CPUX86State *env;
x86_def_t def1, *def = &def1;
Error *error = NULL;
char *name, *features;
gchar **model_pieces;
+ cpu = X86_CPU(object_new(TYPE_X86_CPU));
+ env = &cpu->env;
+ env->cpu_model_str = cpu_model;
+
memset(def, 0, sizeof(*def));
model_pieces = g_strsplit(cpu_model, ",", 2);
@@ -1572,10 +1580,11 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model)
}
g_strfreev(model_pieces);
- return 0;
+ return cpu;
error:
+ object_delete(OBJECT(cpu));
g_strfreev(model_pieces);
- return -1;
+ return NULL;
}
#if !defined(CONFIG_USER_ONLY)
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 386c4f6..3ebaae9 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -980,7 +980,7 @@ int cpu_x86_signal_handler(int host_signum, void *pinfo,
void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
uint32_t *eax, uint32_t *ebx,
uint32_t *ecx, uint32_t *edx);
-int cpu_x86_register(X86CPU *cpu, const char *cpu_model);
+X86CPU *cpu_x86_create(const char *cpu_model);
void cpu_clear_apic_feature(CPUX86State *env);
void host_cpuid(uint32_t function, uint32_t count,
uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx);
diff --git a/target-i386/helper.c b/target-i386/helper.c
index bf206cf..23af4a8 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -1243,15 +1243,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 *error = NULL;
- cpu = X86_CPU(object_new(TYPE_X86_CPU));
- env = &cpu->env;
- env->cpu_model_str = cpu_model;
-
- if (cpu_x86_register(cpu, cpu_model) < 0) {
- object_delete(OBJECT(cpu));
+ cpu = cpu_x86_create(cpu_model);
+ if (!cpu) {
return NULL;
}
--
1.7.11.7
next prev parent reply other threads:[~2012-12-11 0:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-11 0:30 [Qemu-devel] [PATCH 0/2] target-i386: move CPU object creation to cpu.c Eduardo Habkost
2012-12-11 0:30 ` Eduardo Habkost [this message]
2012-12-11 13:21 ` [Qemu-devel] [PATCH 1/2] " Eduardo Habkost
2012-12-11 13:33 ` Igor Mammedov
2012-12-11 13:46 ` Eduardo Habkost
2012-12-11 0:30 ` [Qemu-devel] [PATCH 2/2] target-i386: make cpu_x86_create() get Error argument Eduardo Habkost
-- strict thread matches above, loose matches on Subject: below --
2012-12-12 18:16 [Qemu-devel] [PATCH 0/2] target-i386: move CPU object creation to cpu.c (v2) Eduardo Habkost
2012-12-12 18:16 ` [Qemu-devel] [PATCH 1/2] target-i386: move CPU object creation to cpu.c Eduardo Habkost
2012-12-14 10:26 ` Igor Mammedov
2012-12-14 12:42 ` 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=1355185843-19682-2-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).