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 2/6] target-i386: Make cpu_x86_create() get Error argument
Date: Fri, 4 Jan 2013 17:56:18 -0200 [thread overview]
Message-ID: <1357329382-20944-3-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1357329382-20944-1-git-send-email-ehabkost@redhat.com>
Instead of forcing the caller to guess what went wrong while creating
the CPU object, return error information in a Error argument.
Also, as cpu_x86_create() won't print error messages itself anymore,
change cpu_x86_init() to print any error returned by cpu_x86_create()
or cpu_x86_realize().
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Changes v2:
- Fix include "qemu-error.h" to use the new "qemu/error-report.h"
- Remove bogus error_free() call just after error_propagate()
---
target-i386/cpu.c | 5 ++---
target-i386/cpu.h | 2 +-
target-i386/helper.c | 21 ++++++++++++++-------
3 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 243ea3e..6c75327 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1522,7 +1522,7 @@ static void filter_features_for_kvm(X86CPU *cpu)
/* Create and initialize a X86CPU object, based on the full CPU model string
* (that may include "+feature,-feature,feature=xxx,feature" feature strings)
*/
-X86CPU *cpu_x86_create(const char *cpu_model)
+X86CPU *cpu_x86_create(const char *cpu_model, Error **errp)
{
X86CPU *cpu = NULL;
CPUX86State *env;
@@ -1569,8 +1569,7 @@ out:
QDECREF(props);
g_strfreev(model_pieces);
if (error) {
- fprintf(stderr, "%s\n", error_get_pretty(error));
- error_free(error);
+ error_propagate(errp, error);
if (cpu) {
object_delete(OBJECT(cpu));
}
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index c0ac8c7..91091bf 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -981,7 +981,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);
-X86CPU *cpu_x86_create(const char *cpu_model);
+X86CPU *cpu_x86_create(const char *cpu_model, Error **errp);
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 7482c97..8b6b4da 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -23,6 +23,7 @@
#include "sysemu/sysemu.h"
#include "monitor/monitor.h"
#endif
+#include "qemu/error-report.h"
//#define DEBUG_MMU
@@ -1239,21 +1240,27 @@ int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector,
X86CPU *cpu_x86_init(const char *cpu_model)
{
- X86CPU *cpu;
+ X86CPU *cpu = NULL;
Error *error = NULL;
- cpu = cpu_x86_create(cpu_model);
- if (!cpu) {
- return NULL;
+ cpu = cpu_x86_create(cpu_model, &error);
+ if (error) {
+ goto error;
}
x86_cpu_realize(OBJECT(cpu), &error);
if (error) {
- error_free(error);
- object_delete(OBJECT(cpu));
- return NULL;
+ goto error;
}
return cpu;
+
+error:
+ if (cpu) {
+ object_delete(OBJECT(cpu));
+ }
+ error_report("%s", error_get_pretty(error));
+ error_free(error);
+ return NULL;
}
#if !defined(CONFIG_USER_ONLY)
--
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 ` Eduardo Habkost [this message]
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 ` [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-3-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).