Received: from eggs.gnu.org ([2001:4830:134:3::10]:34585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZxVY-00007m-Gx for qemu-devel@nongnu.org; Tue, 25 Jul 2017 06:56:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZxVT-0004uQ-LX for qemu-devel@nongnu.org; Tue, 25 Jul 2017 06:56:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60460) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dZxVT-0004u7-Fh for qemu-devel@nongnu.org; Tue, 25 Jul 2017 06:56:03 -0400 References: <1500977081-120929-1-git-send-email-anton.nefedov@virtuozzo.com> From: Paolo Bonzini Message-ID: Date: Tue, 25 Jul 2017 12:55:54 +0200 MIME-Version: 1.0 In-Reply-To: <1500977081-120929-1-git-send-email-anton.nefedov@virtuozzo.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] char: don't exit on hmp 'chardev-add help' List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anton Nefedov , qemu-devel@nongnu.org Cc: den@virtuozzo.com, marcandre.lureau@redhat.com, dgilbert@redhat.com On 25/07/2017 12:04, Anton Nefedov wrote: > 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. Queued, thanks. Paolo > Signed-off-by: Anton Nefedov > --- > include/chardev/char.h | 4 +++- > chardev/char.c | 2 +- > vl.c | 10 ++++++---- > 3 files changed, 10 insertions(+), 6 deletions(-) > > diff --git a/include/chardev/char.h b/include/chardev/char.h > index 1604ea9..66dde46 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); > diff --git a/chardev/char.c b/chardev/char.c > index c34b44a..5d283b9 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/vl.c b/vl.c > index fb6b2ef..47bfe51 100644 > --- 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; > } >