Fei Li <f...@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.
>
> Signed-off-by: Fei Li <f...@suse.com>
> ---
[...]
> diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
> index 289af4fab5..3a2a0cb3c1 100644
> --- a/util/qemu-thread-posix.c
> +++ b/util/qemu-thread-posix.c
> @@ -15,6 +15,7 @@
>  #include "qemu/atomic.h"
>  #include "qemu/notify.h"
>  #include "qemu-thread-common.h"
> +#include "qapi/error.h"
>  
>  static bool name_threads;
>  
> @@ -504,9 +505,9 @@ static void *qemu_thread_start(void *args)
>      return start_routine(arg);
>  }
>  
> -void qemu_thread_create(QemuThread *thread, const char *name,
> -                       void *(*start_routine)(void*),
> -                       void *arg, int mode)
> +bool qemu_thread_create(QemuThread *thread, const char *name,
> +                        void *(*start_routine)(void *),
> +                        void *arg, int mode, Error **errp)
>  {
>      sigset_t set, oldset;
>      int err;
> @@ -515,7 +516,8 @@ void qemu_thread_create(QemuThread *thread, const char 
> *name,
>  
>      err = pthread_attr_init(&attr);
>      if (err) {
> -        error_exit(err, __func__);
> +        error_setg(errp, "pthread_attr_init failed: %s", strerror(err));
> +        return false;

The commit message claims this function was "failing with an error".
Not true; error_exit() abort()s.  It exit()ed until commit 53380ac37f2,
v1.0.  The name error_exit() became misleading then.  The bad name is
not this patch's problem, but its commit message needs to be corrected.

>      }
>  
>      if (mode == QEMU_THREAD_DETACHED) {
[...]

I think David Gilbert added the bite-sized task you took on.  David,
please review.

Reply via email to