@@ -332,16 +332,21 @@ static bool vnc_worker_thread_running(void)
return queue; /* Check global queue */
}
-void vnc_start_worker_thread(void)
+bool vnc_start_worker_thread(Error **errp)
{
VncJobQueue *q;
- if (vnc_worker_thread_running())
- return ;
+ if (vnc_worker_thread_running()) {
+ return true;
+ }
q = vnc_queue_init();
- /* TODO: let the further caller handle the error instead of abort() here */
- qemu_thread_create(&q->thread, "vnc_worker", vnc_worker_thread,
- q, QEMU_THREAD_DETACHED, &error_abort);
+ if (qemu_thread_create(&q->thread, "vnc_worker", vnc_worker_thread,
+ q, QEMU_THREAD_DETACHED, errp) < 0) {
+ vnc_queue_clear(q);
+ return false;
+ }
queue = q; /* Set global queue */
+
+ return true;
}
@@ -37,7 +37,7 @@ void vnc_job_push(VncJob *job);
void vnc_jobs_join(VncState *vs);
void vnc_jobs_consume_buffer(VncState *vs);
-void vnc_start_worker_thread(void);
+bool vnc_start_worker_thread(Error **errp);
/* Locks */
static inline int vnc_trylock_display(VncDisplay *vd)
@@ -3202,7 +3202,9 @@ void vnc_display_init(const char *id, Error **errp)
vd->connections_limit = 32;
qemu_mutex_init(&vd->mutex);
- vnc_start_worker_thread();
+ if (!vnc_start_worker_thread(errp)) {
+ return;
+ }
vd->dcl.ops = &dcl_ops;
register_displaychangelistener(&vd->dcl);