From patchwork Tue Feb 7 14:09:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 139970 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 859701007D3 for ; Wed, 8 Feb 2012 03:25:43 +1100 (EST) Received: from localhost ([::1]:33793 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rulkc-0002dX-3L for incoming@patchwork.ozlabs.org; Tue, 07 Feb 2012 09:10:30 -0500 Received: from eggs.gnu.org ([140.186.70.92]:53897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ruljn-0001Us-OA for qemu-devel@nongnu.org; Tue, 07 Feb 2012 09:09:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ruljf-0005fe-LQ for qemu-devel@nongnu.org; Tue, 07 Feb 2012 09:09:39 -0500 Received: from oxygen.pond.sub.org ([78.46.104.156]:39193) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ruljf-0005eo-Fq for qemu-devel@nongnu.org; Tue, 07 Feb 2012 09:09:31 -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 6A14AA43F8; Tue, 7 Feb 2012 15:09:30 +0100 (CET) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id 7B85560088; Tue, 7 Feb 2012 15:09:27 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 7 Feb 2012 15:09:20 +0100 Message-Id: <1328623766-12287-14-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 13/19] qemu-char: Chardev open error reporting, parport part 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 Unlike many other backends, these leave open error reporting to their caller. Because the caller doesn't know what went wrong, this results in a pretty useless error message. Change them to report their errors themselves. Improves user-hostile messages like this one for "-chardev tty,id=foo,path=/dev/parport0" chardev: opening backend "parport" failed to qemu-system-x86_64: -chardev parport,id=foo,path=/dev/parport0: Can't open '/dev/parport0': Permission denied chardev: opening backend "parport" failed The useless "opening backend failed" message will be cleaned up shortly. Signed-off-by: Markus Armbruster --- qemu-char.c | 21 ++++++++++++++++++--- 1 files changed, 18 insertions(+), 3 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 1ff7f4b..ecbb595 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -1371,14 +1371,18 @@ static CharDriverState *qemu_chr_open_pp(QemuOpts *opts) ParallelCharDriver *drv; int fd; + if (!filename) { + error_report("parport character device requires parameter path"); + return NULL; + } + TFR(fd = qemu_open(filename, O_RDWR)); if (fd < 0) { - return NULL; + goto err; } if (ioctl(fd, PPCLAIM) < 0) { - close(fd); - return NULL; + goto err; } drv = g_malloc0(sizeof(ParallelCharDriver)); @@ -1394,6 +1398,11 @@ static CharDriverState *qemu_chr_open_pp(QemuOpts *opts) qemu_chr_generic_open(chr); return chr; + +err: + error_report("Can't open '%s': %s", filename, strerror(errno)); + close(fd); + return NULL; } #endif /* __linux__ */ @@ -1441,8 +1450,14 @@ static CharDriverState *qemu_chr_open_pp(QemuOpts *opts) CharDriverState *chr; int fd; + if (!filename) { + error_report("parport character device requires parameter path"); + return NULL; + } + fd = qemu_open(filename, O_RDWR); if (fd < 0) { + error_report("Can't open '%s': %s", filename, strerror(errno)); return NULL; }