All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fei Li <fli@suse.com>
To: qemu-devel@nongnu.org
Cc: fli@suse.com
Subject: [Qemu-devel] [PATCH 2/5] ui/vnc.c: polish vnc_init_func
Date: Tue,  4 Sep 2018 19:08:19 +0800	[thread overview]
Message-ID: <20180904110822.12863-3-fli@suse.com> (raw)
In-Reply-To: <20180904110822.12863-1-fli@suse.com>

Add a new Error parameter to vnc_display_init() and handle the Error
in its caller: vnc_init_func() just like vnc_display_open() does. And
let the call trace propagate the Error.

Signed-off-by: Fei Li <fli@suse.com>
---
 include/ui/console.h |  2 +-
 ui/vnc-jobs.c        |  2 +-
 ui/vnc-jobs.h        |  2 +-
 ui/vnc.c             | 15 ++++++++++++---
 4 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index fb969caf70..c17803c530 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -453,7 +453,7 @@ void qemu_display_early_init(DisplayOptions *opts);
 void qemu_display_init(DisplayState *ds, DisplayOptions *opts);
 
 /* vnc.c */
-void vnc_display_init(const char *id);
+void vnc_display_init(const char *id, Error **errp);
 void vnc_display_open(const char *id, Error **errp);
 void vnc_display_add_client(const char *id, int csock, bool skipauth);
 int vnc_display_password(const char *id, const char *password);
diff --git a/ui/vnc-jobs.c b/ui/vnc-jobs.c
index 929391f85d..7c05a1e6df 100644
--- a/ui/vnc-jobs.c
+++ b/ui/vnc-jobs.c
@@ -331,7 +331,7 @@ static bool vnc_worker_thread_running(void)
     return queue; /* Check global queue */
 }
 
-void vnc_start_worker_thread(void)
+void vnc_start_worker_thread(Error **errp)
 {
     VncJobQueue *q;
 
diff --git a/ui/vnc-jobs.h b/ui/vnc-jobs.h
index 59f66bcc35..31eb482582 100644
--- a/ui/vnc-jobs.h
+++ b/ui/vnc-jobs.h
@@ -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);
+void vnc_start_worker_thread(Error **errp);
 
 /* Locks */
 static inline int vnc_trylock_display(VncDisplay *vd)
diff --git a/ui/vnc.c b/ui/vnc.c
index ccb1335d86..ff22bbc055 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3206,9 +3206,10 @@ static const DisplayChangeListenerOps dcl_ops = {
     .dpy_cursor_define    = vnc_dpy_cursor_define,
 };
 
-void vnc_display_init(const char *id)
+void vnc_display_init(const char *id, Error **errp)
 {
     VncDisplay *vd;
+    Error *local_err = NULL;
 
     if (vnc_display_find(id) != NULL) {
         return;
@@ -3236,7 +3237,11 @@ void vnc_display_init(const char *id)
     vd->connections_limit = 32;
 
     qemu_mutex_init(&vd->mutex);
-    vnc_start_worker_thread();
+    vnc_start_worker_thread(&local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
 
     vd->dcl.ops = &dcl_ops;
     register_displaychangelistener(&vd->dcl);
@@ -4079,7 +4084,11 @@ int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp)
     char *id = (char *)qemu_opts_id(opts);
 
     assert(id);
-    vnc_display_init(id);
+    vnc_display_init(id, &local_err);
+    if (local_err) {
+        error_reportf_err(local_err, "Failed to init VNC server: ");
+        exit(1);
+    }
     vnc_display_open(id, &local_err);
     if (local_err != NULL) {
         error_reportf_err(local_err, "Failed to start VNC server: ");
-- 
2.13.7

  parent reply	other threads:[~2018-09-04 11:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-04 11:08 [Qemu-devel] [PATCH 0/5] qemu_thread_create: propagate errors to callers to check Fei Li
2018-09-04 11:08 ` [Qemu-devel] [PATCH 1/5] Fix segmentation fault when qemu_signal_init fails Fei Li
2018-09-04 11:26   ` Daniel P. Berrangé
2018-09-05  4:17     ` Fei Li
2018-09-05  8:36       ` Daniel P. Berrangé
2018-09-05 11:20         ` Fei Li
2018-09-05 14:38           ` Fam Zheng
2018-09-06  6:31             ` Fei Li
2018-09-04 11:08 ` Fei Li [this message]
2018-09-04 11:08 ` [Qemu-devel] [PATCH 3/5] qemu_init_vcpu: add a new Error paramater to propagate Fei Li
2018-09-04 11:22   ` Daniel P. Berrangé
2018-09-05  4:36     ` Fei Li
2018-09-05 17:15     ` Eric Blake
2018-09-06  6:52       ` Fei Li
2018-09-04 11:08 ` [Qemu-devel] [PATCH 4/5] qemu_thread_create: propagate the error to callers to check Fei Li
2018-09-04 11:18   ` Daniel P. Berrangé
2018-09-05  4:20     ` Fei Li
2018-09-04 11:08 ` [Qemu-devel] [PATCH 5/5] Propagate qemu_thread_create's error to all callers to handle Fei Li
2018-09-04 11:20   ` Daniel P. Berrangé

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=20180904110822.12863-3-fli@suse.com \
    --to=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.