qemu-devel
[Top][All Lists]
Advanced

[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: Fei Li
Subject: Re: [Qemu-devel] [PATCH RFC v5 7/7] qemu_thread_create: propagate the error to callers to handle
Date: Fri, 12 Oct 2018 14:00:05 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1



On 10/11/2018 09:45 PM, Markus Armbruster wrote:
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.
Ok, thanks. I will amend the message to "instead of abort() directly"

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

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

Thanks!

Have a nice day
Fei



reply via email to

[Prev in Thread] Current Thread [Next in Thread]