From patchwork Mon Dec 12 22:42:43 2016 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: 705178 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 3tcyvt40QXz9t0J for ; Tue, 13 Dec 2016 09:59:38 +1100 (AEDT) Received: from localhost ([::1]:33989 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGZZI-00081H-Gn for incoming@patchwork.ozlabs.org; Mon, 12 Dec 2016 17:59:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGZKZ-0003hF-9D for qemu-devel@nongnu.org; Mon, 12 Dec 2016 17:44:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cGZKY-0003VX-GH for qemu-devel@nongnu.org; Mon, 12 Dec 2016 17:44:23 -0500 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 1cGZKY-0003VD-AS for qemu-devel@nongnu.org; Mon, 12 Dec 2016 17:44:22 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (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 748B73DD47 for ; Mon, 12 Dec 2016 22:44:21 +0000 (UTC) Received: from localhost (ovpn-116-54.ams2.redhat.com [10.36.116.54]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uBCMiJuC018165; Mon, 12 Dec 2016 17:44:20 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Tue, 13 Dec 2016 01:42:43 +0300 Message-Id: <20161212224325.20790-13-marcandre.lureau@redhat.com> In-Reply-To: <20161212224325.20790-1-marcandre.lureau@redhat.com> References: <20161212224325.20790-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 12 Dec 2016 22:44:21 +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 12/54] spice-char: improve error reporting 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" Set errp to report errors up. Use error_report() to give hints about parameters on the right monitor, instead of a direct fprintf() call. Signed-off-by: Marc-André Lureau --- spice-qemu-char.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/spice-qemu-char.c b/spice-qemu-char.c index 5feb88c1ec..4e934cf224 100644 --- a/spice-qemu-char.c +++ b/spice-qemu-char.c @@ -2,6 +2,7 @@ #include "trace.h" #include "ui/qemu-spice.h" #include "sysemu/char.h" +#include "qemu/error-report.h" #include #include @@ -239,23 +240,6 @@ static void spice_port_set_fe_open(struct Chardev *chr, int fe_open) #endif } -static void print_allowed_subtypes(void) -{ - const char** psubtype; - int i; - - fprintf(stderr, "allowed names: "); - for(i=0, psubtype = spice_server_char_device_recognized_subtypes(); - *psubtype != NULL; ++psubtype, ++i) { - if (i == 0) { - fprintf(stderr, "%s", *psubtype); - } else { - fprintf(stderr, ", %s", *psubtype); - } - } - fprintf(stderr, "\n"); -} - static void spice_chr_accept_input(struct Chardev *chr) { SpiceChardev *s = (SpiceChardev *)chr; @@ -302,8 +286,13 @@ static Chardev *qemu_chr_open_spice_vmc(const CharDriver *driver, } } if (*psubtype == NULL) { - fprintf(stderr, "spice-qemu-char: unsupported type: %s\n", type); - print_allowed_subtypes(); + char *subtypes = g_strjoinv(", ", + (gchar **)spice_server_char_device_recognized_subtypes()); + + error_setg(errp, "unsupported type name: %s", type); + error_report("allowed spice char type names: %s", subtypes); + + g_free(subtypes); return NULL; } @@ -326,7 +315,7 @@ static Chardev *qemu_chr_open_spice_port(const CharDriver *driver, SpiceChardev *s; if (name == NULL) { - fprintf(stderr, "spice-qemu-char: missing name parameter\n"); + error_setg(errp, "missing name parameter"); return NULL; }