diff mbox

[19/27] cpu_x86_init: check for x86_cpu_realize() errors

Message ID 1351101001-14589-20-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost Oct. 24, 2012, 5:49 p.m. UTC
If x86_cpu_realize() set any errors, print an error message and return
NULL.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 target-i386/helper.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/target-i386/helper.c b/target-i386/helper.c
index c5d42c5..1e5f61f 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -19,6 +19,7 @@ 
 
 #include "cpu.h"
 #include "kvm.h"
+#include "qemu-error.h"
 #ifndef CONFIG_USER_ONLY
 #include "sysemu.h"
 #include "monitor.h"
@@ -1243,6 +1244,7 @@  X86CPU *cpu_x86_init(const char *cpu_model)
 {
     X86CPU *cpu;
     CPUX86State *env;
+    Error *err = NULL;
 
     cpu = X86_CPU(object_new(TYPE_X86_CPU));
     env = &cpu->env;
@@ -1253,7 +1255,11 @@  X86CPU *cpu_x86_init(const char *cpu_model)
         return NULL;
     }
 
-    x86_cpu_realize(OBJECT(cpu), NULL);
+    x86_cpu_realize(OBJECT(cpu), &err);
+    if (err) {
+        error_report("cpu_x86_init: %s\n", error_get_pretty(err));
+        return NULL;
+    }
 
     return cpu;
 }