From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVOnc-0005aY-Te for qemu-devel@nongnu.org; Tue, 10 Mar 2015 14:22:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YVOnO-0002ev-W0 for qemu-devel@nongnu.org; Tue, 10 Mar 2015 14:22:36 -0400 Received: from cantor2.suse.de ([195.135.220.15]:55102 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVOnO-0002eW-Q1 for qemu-devel@nongnu.org; Tue, 10 Mar 2015 14:22:22 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 10 Mar 2015 19:22:16 +0100 Message-Id: <1426011740-17688-3-git-send-email-afaerber@suse.de> In-Reply-To: <1426011740-17688-1-git-send-email-afaerber@suse.de> References: <1426011740-17688-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 2/6] target-i386: Clean up misuse of qdev_init() in realize method List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Richard Henderson , Markus Armbruster , =?UTF-8?q?Andreas=20F=C3=A4rber?= From: Markus Armbruster 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 Reviewed-by: Igor Mammedov Signed-off-by: Andreas F=C3=A4rber --- 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, Erro= r **errp) if (cpu->apic_state =3D=3D NULL) { return; } - - 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); } #else static void x86_cpu_apic_realize(X86CPU *cpu, Error **errp) --=20 2.1.4