]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
char: don't exit on hmp 'chardev-add help'
authorAnton Nefedov <anton.nefedov@virtuozzo.com>
Tue, 25 Jul 2017 10:04:41 +0000 (13:04 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 1 Aug 2017 15:27:33 +0000 (17:27 +0200)
qemu_chr_new_from_opts() is used from both vl.c and hmp,
and it is quite confusing to see qemu suddenly exit after receiving a help
option in hmp.

Do exit(0) from vl.c instead.

Signed-off-by: Anton Nefedov <anton.nefedov@virtuozzo.com>
Message-Id: <1500977081-120929-1-git-send-email-anton.nefedov@virtuozzo.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
chardev/char.c
include/chardev/char.h
vl.c

index c34b44abc998b265214e0127e7636d2c75a52986..5d283b90d3f7bc96b525eb2cca6bf17913454dbc 100644 (file)
@@ -620,7 +620,7 @@ Chardev *qemu_chr_new_from_opts(QemuOpts *opts, Error **errp)
 
         error_report("Available chardev backend types: %s", str->str);
         g_string_free(str, true);
-        exit(0);
+        return NULL;
     }
 
     if (id == NULL) {
index 1604ea91436bb8da31d442d57e7090e89d10677e..66dde4637e749440e4ab96e1e035aa4beeef7453 100644 (file)
@@ -65,7 +65,9 @@ struct Chardev {
  *
  * @opts see qemu-config.c for a list of valid options
  *
- * Returns: a new character backend
+ * Returns: on success: a new character backend
+ *          otherwise:  NULL; @errp specifies the error
+ *                            or left untouched in case of help option
  */
 Chardev *qemu_chr_new_from_opts(QemuOpts *opts,
                                 Error **errp);
diff --git a/vl.c b/vl.c
index dd803fc24459c4d6de2474fcd910522ce9aec938..99fcfa04421a59100e1df6a3f47e30834d960f71 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -2344,10 +2344,12 @@ static int chardev_init_func(void *opaque, QemuOpts *opts, Error **errp)
 {
     Error *local_err = NULL;
 
-    qemu_chr_new_from_opts(opts, &local_err);
-    if (local_err) {
-        error_report_err(local_err);
-        return -1;
+    if (!qemu_chr_new_from_opts(opts, &local_err)) {
+        if (local_err) {
+            error_report_err(local_err);
+            return -1;
+        }
+        exit(0);
     }
     return 0;
 }