[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PULL 2/6] target-i386: Clean up misuse of qdev_init() in r

From: Andreas Färber
Subject: [Qemu-devel] [PULL 2/6] target-i386: Clean up misuse of qdev_init() in realize method
Date: Tue, 10 Mar 2015 19:22:16 +0100

From: Markus Armbruster <address@hidden>

x86_cpu_apic_realize() calls qdev_init() to realize the APIC.
qdev_init()'s error handling has unwanted side effects: it unparents
the device, and it calls qerror_report_err().

qerror_report_err() is always inappropriate in realize methods,
because it doesn't return the Error object.  It either reports the
error to stderr or the human monitor, or it stores it in the QMP
monitor, where it makes the QMP command fail even though the realize
method succeeded.

Fortunately, qdev_init() can't actually fail here, because realize
can't fail for any of the three possible APIC device models.

Clean up by cutting out the qdev_init() middle-man: set property
"realized" directly.

Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Igor Mammedov <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
 target-i386/cpu.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index d543e2b..97777fb 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2751,12 +2751,8 @@ static void x86_cpu_apic_realize(X86CPU *cpu, Error 
     if (cpu->apic_state == NULL) {
-    if (qdev_init(cpu->apic_state)) {
-        error_setg(errp, "APIC device '%s' could not be initialized",
-                   object_get_typename(OBJECT(cpu->apic_state)));
-        return;
-    }
+    object_property_set_bool(OBJECT(cpu->apic_state), true, "realized",
+                             errp);
 static void x86_cpu_apic_realize(X86CPU *cpu, Error **errp)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]