diff options
-rw-r--r-- | chardev/char.c | 2 | ||||
-rw-r--r-- | include/chardev/char.h | 4 | ||||
-rw-r--r-- | vl.c | 10 |
3 files changed, 10 insertions, 6 deletions
diff --git a/chardev/char.c b/chardev/char.c index c34b44abc9..5d283b90d3 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -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) { diff --git a/include/chardev/char.h b/include/chardev/char.h index 1604ea9143..66dde4637e 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -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); @@ -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; } |