From patchwork Thu Jan 5 16:53:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 711492 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tvYn335K5z9sfH for ; Fri, 6 Jan 2017 03:59:19 +1100 (AEDT) Received: from localhost ([::1]:47509 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPBNk-0003tf-Tr for incoming@patchwork.ozlabs.org; Thu, 05 Jan 2017 11:59:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPBIg-0007Z1-Vg for qemu-devel@nongnu.org; Thu, 05 Jan 2017 11:54:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cPBIf-0002rE-NS for qemu-devel@nongnu.org; Thu, 05 Jan 2017 11:54:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58936) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cPBIf-0002r2-Fn for qemu-devel@nongnu.org; Thu, 05 Jan 2017 11:54:01 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C2CC7F76D for ; Thu, 5 Jan 2017 16:54:01 +0000 (UTC) Received: from localhost (ovpn-116-93.ams2.redhat.com [10.36.116.93]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v05Gs08U002109; Thu, 5 Jan 2017 11:54:01 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 5 Jan 2017 17:53:25 +0100 Message-Id: <20170105165329.17227-17-marcandre.lureau@redhat.com> In-Reply-To: <20170105165329.17227-1-marcandre.lureau@redhat.com> References: <20170105165329.17227-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 05 Jan 2017 16:54:01 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 16/20] char: use error_report() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Prefer error_report() over fprintf(stderr..) Signed-off-by: Marc-André Lureau Reviewed-by: Eric Blake --- qemu-char.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 6ac52ce48d..284dd2f979 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -451,8 +451,8 @@ int qemu_chr_fe_get_msgfd(CharBackend *be) int fd; int res = (qemu_chr_fe_get_msgfds(be, &fd, 1) == 1) ? fd : -1; if (s && qemu_chr_replay(s)) { - fprintf(stderr, - "Replay: get msgfd is not supported for serial devices yet\n"); + error_report("Replay: get msgfd is not supported " + "for serial devices yet"); exit(1); } return res; @@ -1675,8 +1675,8 @@ static Chardev *qemu_chr_open_pty(const CharDriver *driver, ret->pty = g_strdup(pty_name); ret->has_pty = true; - fprintf(stderr, "char device redirected to %s (label %s)\n", - pty_name, id); + error_report("char device redirected to %s (label %s)", + pty_name, id); s = (PtyChardev *)chr; s->ioc = QIO_CHANNEL(qio_channel_file_new_fd(master_fd)); @@ -3379,8 +3379,8 @@ static int tcp_chr_wait_connected(Chardev *chr, Error **errp) * in TLS and telnet cases, only wait for an accepted socket */ while (!s->ioc) { if (s->is_listen) { - fprintf(stderr, "QEMU waiting for connection on: %s\n", - chr->filename); + error_report("QEMU waiting for connection on: %s", + chr->filename); qio_channel_set_blocking(QIO_CHANNEL(s->listen_ioc), true, NULL); tcp_chr_accept(QIO_CHANNEL(s->listen_ioc), G_IO_IN, chr); qio_channel_set_blocking(QIO_CHANNEL(s->listen_ioc), false, NULL); @@ -4139,17 +4139,20 @@ Chardev *qemu_chr_new_from_opts(QemuOpts *opts, } if (is_help_option(qemu_opt_get(opts, "backend"))) { - fprintf(stderr, "Available chardev backend types:\n"); + GString *str = g_string_new(""); for (i = 0; i < ARRAY_SIZE(backends); i++) { cd = backends[i]; if (cd) { - fprintf(stderr, "%s\n", ChardevBackendKind_lookup[cd->kind]); + g_string_append_printf(str, "\n%s", ChardevBackendKind_lookup[cd->kind]); if (cd->alias) { - fprintf(stderr, "%s\n", cd->alias); + g_string_append_printf(str, "\n%s", cd->alias); } } } - exit(!is_help_option(qemu_opt_get(opts, "backend"))); + + error_report("Available chardev backend types: %s", str->str); + g_string_free(str, true); + exit(0); } if (id == NULL) { @@ -4262,8 +4265,8 @@ Chardev *qemu_chr_new(const char *label, const char *filename) qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_REPLAY); } if (qemu_chr_replay(chr) && chr->driver->chr_ioctl) { - fprintf(stderr, - "Replay: ioctl is not supported for serial devices yet\n"); + error_report("Replay: ioctl is not supported " + "for serial devices yet"); } replay_register_char_driver(chr); }