Patchwork [03/23] target-i386: if x86_cpu_realize() failed report error and do cleanup

login
register
mail settings
Submitter Igor Mammedov
Date Oct. 2, 2012, 3:36 p.m.
Message ID <1349192235-31895-4-git-send-email-imammedo@redhat.com>
Download mbox | patch
Permalink /patch/188552/
State New
Headers show

Comments

Igor Mammedov - Oct. 2, 2012, 3:36 p.m.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Andreas Färber <afaerber@suse.de>
---
 v2:
   - replaced "if (error_is_set(&error))" with "if (error)"
---
 target-i386/helper.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
Andreas Färber - Oct. 10, 2012, 2:09 p.m.
Am 02.10.2012 17:36, schrieb Igor Mammedov:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Acked-by: Andreas Färber <afaerber@suse.de>

Thanks, queued on qom-cpu branch:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu

This is a prerequisite for the APIC initialization error reporting.

Andreas

Patch

diff --git a/target-i386/helper.c b/target-i386/helper.c
index c635667..1d39ba9 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -1243,6 +1243,7 @@  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;
@@ -1253,8 +1254,12 @@  X86CPU *cpu_x86_init(const char *cpu_model)
         return NULL;
     }
 
-    x86_cpu_realize(OBJECT(cpu), NULL);
-
+    x86_cpu_realize(OBJECT(cpu), &error);
+    if (error) {
+        error_free(error);
+        object_delete(OBJECT(cpu));
+        return NULL;
+    }
     return cpu;
 }