All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <dgibson@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Fei Li <fli@suse.com>,
	qemu-devel@nongnu.org,
	"Dr . David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [Qemu-devel] [PATCH for-4.0 v8 6/7] qemu_thread_create: propagate the error to callers to handle
Date: Fri, 14 Dec 2018 11:24:47 +1100	[thread overview]
Message-ID: <20181214112447.510e4691@umbus.fritz.box> (raw)
In-Reply-To: <87y38tc2fb.fsf@dusky.pond.sub.org>

[-- Attachment #1: Type: text/plain, Size: 2880 bytes --]

On Thu, 13 Dec 2018 08:26:48 +0100
Markus Armbruster <armbru@redhat.com> wrote:

> There's a question for David Gibson inline.  Please search for /ppc/.
> 
> Fei Li <fli@suse.com> writes:
> 
> > Make qemu_thread_create() return a Boolean to indicate if it succeeds
> > rather than failing with an error. And add an Error parameter to hold
> > the error message and let the callers handle it.  
> 
> The "rather than failing with an error" is misleading.  Before the
> patch, we report to stderr and abort().  What about:
> 
>     qemu-thread: Make qemu_thread_create() handle errors properly
> 
>     qemu_thread_create() abort()s on error.  Not nice.  Give it a
>     return value and an Error ** argument, so it can return success /
>     failure.
> 
> Still missing from the commit message then: how you update the callers.
> Let's see below.

[snip]
> > --- a/hw/ppc/spapr_hcall.c
> > +++ b/hw/ppc/spapr_hcall.c
> > @@ -478,6 +478,7 @@ static target_ulong h_resize_hpt_prepare(PowerPCCPU *cpu,
> >      sPAPRPendingHPT *pending = spapr->pending_hpt;
> >      uint64_t current_ram_size;
> >      int rc;
> > +    Error *local_err = NULL;
> >  
> >      if (spapr->resize_hpt == SPAPR_RESIZE_HPT_DISABLED) {
> >          return H_AUTHORITY;
> > @@ -538,8 +539,13 @@ static target_ulong h_resize_hpt_prepare(PowerPCCPU *cpu,
> >      pending->shift = shift;
> >      pending->ret = H_HARDWARE;
> >  
> > -    qemu_thread_create(&pending->thread, "sPAPR HPT prepare",
> > -                       hpt_prepare_thread, pending, QEMU_THREAD_DETACHED);
> > +    if (!qemu_thread_create(&pending->thread, "sPAPR HPT prepare",
> > +                            hpt_prepare_thread, pending,
> > +                            QEMU_THREAD_DETACHED, &local_err)) {
> > +        error_reportf_err(local_err, "failed to create hpt_prepare_thread: ");
> > +        g_free(pending);
> > +        return H_RESOURCE;
> > +    }
> >  
> >      spapr->pending_hpt = pending;
> >    
> 
> This is a caller that returns an error code on failure.  You change it
> to report the error, then return failure.  The return failure part looks
> fine.  Whether reporting the error is appropriate I can't say for sure.
> No other failure mode reports anything.  David, what do you think?

I think it's reasonable here.  In this context error returns and
reported errors are for different audiences.  The error returns are for
the guest, the reported errors are for the guest administrator or
management layers.  This particularly failure is essentially a host
side fault that is mostly relevant to the VM management.  We have to
say *something* to the guest to explain that the action couldn't go
forward and H_RESOURCE makes as much sense as anything.

-- 
David Gibson <dgibson@redhat.com>
Principal Software Engineer, Virtualization, Red Hat

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2018-12-14  0:25 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-11  9:50 [Qemu-devel] [PATCH for-4.0 v8 0/7] qemu_thread_create: propagate errors to callers to check Fei Li
2018-12-11  9:50 ` [Qemu-devel] [PATCH for-4.0 v8 1/7] Fix segmentation fault when qemu_signal_init fails Fei Li
2018-12-11  9:50 ` [Qemu-devel] [PATCH for-4.0 v8 2/7] qemu_init_vcpu: add a new Error parameter to propagate Fei Li
2018-12-11  9:50 ` [Qemu-devel] [PATCH for-4.0 v8 3/7] migration: fix the multifd code when receiving less channels Fei Li
2018-12-13  6:17   ` Markus Armbruster
2018-12-17 11:45     ` Fei Li
2018-12-19 14:11       ` Markus Armbruster
2018-12-20  3:27         ` Fei Li
2018-12-11  9:50 ` [Qemu-devel] [PATCH for-4.0 v8 4/7] migration: remove unused &local_err parameter in multifd_save_cleanup Fei Li
2018-12-11  9:50 ` [Qemu-devel] [PATCH for-4.0 v8 5/7] migration: add more error handling for postcopy_ram_enable_notify Fei Li
2018-12-11  9:50 ` [Qemu-devel] [PATCH for-4.0 v8 6/7] qemu_thread_create: propagate the error to callers to handle Fei Li
2018-12-13  7:26   ` Markus Armbruster
2018-12-14  0:24     ` David Gibson [this message]
2018-12-19  9:29       ` Markus Armbruster
2019-01-02  2:29         ` David Gibson
2018-12-17  7:29     ` Fei Li
2018-12-18 12:40       ` Fei Li
2018-12-19 10:11         ` Markus Armbruster
2018-12-19 10:10       ` Markus Armbruster
2018-12-19 12:14         ` Fei Li
2018-12-19 17:29           ` Eric Blake
2018-12-20  3:20             ` Fei Li
2018-12-21  9:36           ` Fei Li
2018-12-24  3:34             ` Peter Xu
2018-12-24  6:53               ` Fei Li
2018-12-25 12:18                 ` Fei Li
2018-12-11  9:50 ` [Qemu-devel] [PATCH for-4.0 v8 7/7] qemu_thread_join: fix segmentation fault Fei Li

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=20181214112447.510e4691@umbus.fritz.box \
    --to=dgibson@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=fli@suse.com \
    --cc=qemu-devel@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.