All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: David Gibson <dgibson@redhat.com>,
	qemu-ppc@nongnu.org, afaerber@suse.de,
	Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCH 2/3] spapr: Clean up misuse of qdev_init() in xics-kvm creation
Date: Wed, 18 Feb 2015 15:42:44 +0100	[thread overview]
Message-ID: <87ioezz3ff.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <1423128889-18260-3-git-send-email-armbru@redhat.com> (Markus Armbruster's message of "Thu, 5 Feb 2015 10:34:48 +0100")

David, your commit 11ad93f suggests you're highly qualified to review.
No good deed shall go unpunished ;)

Markus Armbruster <armbru@redhat.com> writes:

> We call try_create_xics() to create a "xics-kvm".  If it fails, we
> call it again to fall back to plain "xics".
>
> try_create_xics() uses qdev_init().  qdev_init()'s error handling has
> an unwanted side effect: it calls qerror_report_err(), which prints to
> stderr.  Looks like an error, but isn't.
>
> In QMP context, it would stash the error in the monitor instead,
> making the QMP command fail.  Fortunately, it's only called from board
> initialization, never in QMP context.
>
> Clean up by cutting out the qdev_init() middle-man: set property
> "realized" directly.
>
> While there, improve the error message when we can't satisfy an
> explicit user request for "xics-kvm", and exit(1) instead of abort().
> Simplify the abort when we can't create "xics".
>
> Cc: Alexander Graf <agraf@suse.de>
> Cc: qemu-ppc@nongnu.org
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  hw/ppc/spapr.c | 25 ++++++++++++-------------
>  1 file changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index b560459..de6d0bb 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -109,17 +109,20 @@ struct sPAPRMachineState {
>  sPAPREnvironment *spapr;
>  
>  static XICSState *try_create_xics(const char *type, int nr_servers,
> -                                  int nr_irqs)
> +                                  int nr_irqs, Error **errp)
>  {
> +    Error *err;
>      DeviceState *dev;
>  
>      dev = qdev_create(NULL, type);
>      qdev_prop_set_uint32(dev, "nr_servers", nr_servers);
>      qdev_prop_set_uint32(dev, "nr_irqs", nr_irqs);
> -    if (qdev_init(dev) < 0) {
> +    object_property_set_bool(OBJECT(dev), true, "realized", &err);
> +    if (err) {
> +        error_propagate(errp, err);
> +        object_unparent(OBJECT(dev));
>          return NULL;
>      }
> -
>      return XICS_COMMON(dev);
>  }
>  
> @@ -133,23 +136,19 @@ static XICSState *xics_system_init(int nr_servers, int nr_irqs)
>                                                  "kernel_irqchip", true);
>          bool irqchip_required = qemu_opt_get_bool(machine_opts,
>                                                    "kernel_irqchip", false);
> +        Error *err = NULL;
> +
>          if (irqchip_allowed) {
> -            icp = try_create_xics(TYPE_KVM_XICS, nr_servers, nr_irqs);
> +            icp = try_create_xics(TYPE_KVM_XICS, nr_servers, nr_irqs, &err);
>          }
> -
>          if (irqchip_required && !icp) {
> -            perror("Failed to create in-kernel XICS\n");
> -            abort();
> +            error_report("kernel_irqchip requested but unavailable: %s",
> +                         error_get_pretty(err));
>          }
>      }
>  
>      if (!icp) {
> -        icp = try_create_xics(TYPE_XICS, nr_servers, nr_irqs);
> -    }
> -
> -    if (!icp) {
> -        perror("Failed to create XICS\n");
> -        abort();
> +        icp = try_create_xics(TYPE_XICS, nr_servers, nr_irqs, &error_abort);
>      }
>  
>      return icp;

  reply	other threads:[~2015-02-18 14:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-05  9:34 [Qemu-devel] [PATCH 0/3] Clean up misuse of qdev_init() in interrupt controller creation Markus Armbruster
2015-02-05  9:34 ` [Qemu-devel] [PATCH 1/3] PPC: Clean up misuse of qdev_init() in kvm-openpic creation Markus Armbruster
2015-02-18 14:43   ` Markus Armbruster
2015-02-25  0:04     ` Scott Wood
2015-02-25  9:32       ` Markus Armbruster
2015-02-05  9:34 ` [Qemu-devel] [PATCH 2/3] spapr: Clean up misuse of qdev_init() in xics-kvm creation Markus Armbruster
2015-02-18 14:42   ` Markus Armbruster [this message]
2015-02-23  0:31     ` David Gibson
2015-02-20 13:16   ` Alexander Graf
2015-02-05  9:34 ` [Qemu-devel] [PATCH 3/3] s390x: Replace unchecked qdev_init() by qdev_init_nofail() Markus Armbruster
2015-02-18 14:45   ` Markus Armbruster
2015-02-18 15:31     ` Cornelia Huck
2015-03-10 11:56       ` Cornelia Huck

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=87ioezz3ff.fsf@blackfin.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=dgibson@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.