From patchwork Tue Feb 7 14:09:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 139944 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B92C71007D3 for ; Wed, 8 Feb 2012 01:37:22 +1100 (EST) Received: from localhost ([::1]:33885 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rulkz-0002gU-1Z for incoming@patchwork.ozlabs.org; Tue, 07 Feb 2012 09:10:53 -0500 Received: from eggs.gnu.org ([140.186.70.92]:53950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ruljs-0001V8-DG for qemu-devel@nongnu.org; Tue, 07 Feb 2012 09:09:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ruljh-0005h5-05 for qemu-devel@nongnu.org; Tue, 07 Feb 2012 09:09:44 -0500 Received: from oxygen.pond.sub.org ([78.46.104.156]:39198) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ruljg-0005gv-Rf for qemu-devel@nongnu.org; Tue, 07 Feb 2012 09:09:32 -0500 Received: from blackfin.pond.sub.org (p5B32D218.dip.t-dialin.net [91.50.210.24]) by oxygen.pond.sub.org (Postfix) with ESMTPA id F252BA4401; Tue, 7 Feb 2012 15:09:31 +0100 (CET) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id CD3E060092; Tue, 7 Feb 2012 15:09:27 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 7 Feb 2012 15:09:26 +0100 Message-Id: <1328623766-12287-20-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.7.6.5 In-Reply-To: <1328623766-12287-1-git-send-email-armbru@redhat.com> References: <1328623766-12287-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 78.46.104.156 Cc: kwolf@redhat.com, aliguori@us.ibm.com Subject: [Qemu-devel] [PATCH 19/19] qemu-char: Fix legacy chardev syntax error reporting X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Watch this: $ qemu-system-x86_64 -nodefaults -vnc :0 -debugcon crap $ echo $? 1 $ qemu-system-x86_64 -nodefaults -vnc :0 -serial crap qemu: could not open serial device 'crap': Success Two issues: 1. qemu_chr_new() fails silently on syntax errors. It does report other errors. 2. serial_parse() incorrectly asumes qemu_chr_new() sets errno on failure. Same for parallel_parse() and virtcon_parse(). Fix both of them. Signed-off-by: Markus Armbruster --- qemu-char.c | 4 +++- vl.c | 6 ------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index fe0cfce..c74babb 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2867,8 +2867,10 @@ CharDriverState *qemu_chr_new(const char *label, const char *filename, void (*in } opts = qemu_chr_parse_compat(label, filename); - if (!opts) + if (!opts) { + error_report("parse error"); return NULL; + } chr = qemu_chr_new_from_opts(opts, init); if (chr && qemu_opt_get_bool(opts, "mux", 0)) { diff --git a/vl.c b/vl.c index 1394a08..941fab0 100644 --- a/vl.c +++ b/vl.c @@ -1907,8 +1907,6 @@ static int serial_parse(const char *devname) snprintf(label, sizeof(label), "serial%d", index); serial_hds[index] = qemu_chr_new(label, devname, NULL); if (!serial_hds[index]) { - fprintf(stderr, "qemu: could not open serial device '%s': %s\n", - devname, strerror(errno)); return -1; } index++; @@ -1929,8 +1927,6 @@ static int parallel_parse(const char *devname) snprintf(label, sizeof(label), "parallel%d", index); parallel_hds[index] = qemu_chr_new(label, devname, NULL); if (!parallel_hds[index]) { - fprintf(stderr, "qemu: could not open parallel device '%s': %s\n", - devname, strerror(errno)); return -1; } index++; @@ -1960,8 +1956,6 @@ static int virtcon_parse(const char *devname) snprintf(label, sizeof(label), "virtcon%d", index); virtcon_hds[index] = qemu_chr_new(label, devname, NULL); if (!virtcon_hds[index]) { - fprintf(stderr, "qemu: could not open virtio console '%s': %s\n", - devname, strerror(errno)); return -1; } qemu_opt_set(dev_opts, "chardev", label);