[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH RFC v5 7/7] qemu_thread_create: propagate the er
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH RFC v5 7/7] qemu_thread_create: propagate the error to callers to handle |
Date: |
Thu, 11 Oct 2018 15:45:53 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Fei Li <address@hidden> 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 <address@hidden>
> ---
[...]
> 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.
- Re: [Qemu-devel] [PATCH RFC v5 2/7] ui/vnc.c: polish vnc_init_func, (continued)
- [Qemu-devel] [PATCH RFC v5 3/7] qemu_init_vcpu: add a new Error parameter to propagate, Fei Li, 2018/10/10
- [Qemu-devel] [PATCH RFC v5 4/7] qemu_thread_join: fix segmentation fault, Fei Li, 2018/10/10
- [Qemu-devel] [PATCH RFC v5 5/7] migration: fix the multifd code, Fei Li, 2018/10/10
- [Qemu-devel] [PATCH RFC v5 6/7] migration: fix some error handling, Fei Li, 2018/10/10
- [Qemu-devel] [PATCH RFC v5 7/7] qemu_thread_create: propagate the error to callers to handle, Fei Li, 2018/10/10
- Re: [Qemu-devel] [PATCH RFC v5 7/7] qemu_thread_create: propagate the error to callers to handle,
Markus Armbruster <=