qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Richard Henderson" <rth@twiddle.net>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>
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	[thread overview]
Message-ID: <1426011740-17688-3-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1426011740-17688-1-git-send-email-afaerber@suse.de>

From: Markus Armbruster <armbru@redhat.com>

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 <armbru@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 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 **errp)
     if (cpu->apic_state == 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)
-- 
2.1.4

  parent reply	other threads:[~2015-03-10 18:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-10 18:22 [Qemu-devel] [PULL 0/6] QOM CPUState patch queue 2015-03-10 Andreas Färber
2015-03-10 18:22 ` [Qemu-devel] [PULL 1/6] cpu: Add missing documentation for some CPUClass methods Andreas Färber
2015-03-10 18:22 ` Andreas Färber [this message]
2015-03-10 18:22 ` [Qemu-devel] [PULL 3/6] target-unicore32: Make uc32_cpu_init() return UniCore32CPU Andreas Färber
2015-03-10 18:22 ` [Qemu-devel] [PULL 4/6] m68k: Use cpu_m68k_init() Andreas Färber
2015-03-10 18:22 ` [Qemu-devel] [PULL 5/6] unicore32: Use uc32_cpu_init() Andreas Färber
2015-03-10 18:22 ` [Qemu-devel] [PULL 6/6] cpu: Make cpu_init() return QOM CPUState object Andreas Färber
2015-03-11 14:26 ` [Qemu-devel] [PULL 0/6] QOM CPUState patch queue 2015-03-10 Peter Maydell

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=1426011740-17688-3-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=armbru@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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).