From patchwork Tue Oct 27 16:51:43 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 37005 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 30549B7BBB for ; Wed, 28 Oct 2009 03:53:02 +1100 (EST) Received: from localhost ([127.0.0.1]:47444 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N2pI3-0006ex-E3 for incoming@patchwork.ozlabs.org; Tue, 27 Oct 2009 12:52:59 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N2pH0-0006Jg-3u for qemu-devel@nongnu.org; Tue, 27 Oct 2009 12:51:54 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N2pGv-0006Fs-BK for qemu-devel@nongnu.org; Tue, 27 Oct 2009 12:51:53 -0400 Received: from [199.232.76.173] (port=41911 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N2pGv-0006Fe-4s for qemu-devel@nongnu.org; Tue, 27 Oct 2009 12:51:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29576) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N2pGu-0004hQ-L5 for qemu-devel@nongnu.org; Tue, 27 Oct 2009 12:51:48 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9RGpkFx029596; Tue, 27 Oct 2009 12:51:46 -0400 Received: from crossbow.pond.sub.org (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9RGpj74019613; Tue, 27 Oct 2009 12:51:45 -0400 Received: by crossbow.pond.sub.org (Postfix, from userid 500) id 1A34F26408; Tue, 27 Oct 2009 17:51:44 +0100 (CET) From: Markus Armbruster To: Mark McLoughlin Subject: Re: [Qemu-devel] [PATCH] Improve error reporting on file access References: <20091001144256.GA30845@linuxtx.org> <1254413572.2920.37.camel@blaa> Date: Tue, 27 Oct 2009 17:51:43 +0100 In-Reply-To: <1254413572.2920.37.camel@blaa> (Mark McLoughlin's message of "Thu, 01 Oct 2009 17:12:52 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: "Justin M. Forbes" , qemu-devel@nongnu.org X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Mark McLoughlin writes: > On Thu, 2009-10-01 at 09:42 -0500, Justin M. Forbes wrote: >> Author: Justin M. Forbes >> Date: Thu Oct 1 09:34:56 2009 -0500 >> >> Improve error reporting on file access >> >> By making the error reporting include strerror(errno), it gives the user >> a bit more indication as to why qemu failed. This is particularly >> important for people running qemu as a non root user. >> >> Signed-off-by: Justin M. Forbes > > Certainly looks sensible to me > > Not having this is hurting us in Fedora 12 because we've started running > qemu as an unprivileged user and people are having a hard time figuring > out the various errors they're seeing caused by the change. This should > help them. > > Only concern is that errno might not be getting propagated correctly by > some of these functions, but we can fix that later if so. Here's one: bdrv_open2() returns the error code. Usually, it also leaves it in errno, but not always. Try: $ >mt.img $ ~/work/qemu/bld/qemu-img create -f qcow2 -b mt.img mt.qcow2 Formatting 'mt.qcow2', fmt=qcow2 size=0 backing_file='mt.img' encryption=off cluster_size=0 $ qemu [...] -drive file=mt.qcow2 qemu: could not open disk image mt.qcow2: Success diff --git a/vl.c b/vl.c index 7bfd415..70fd2ca 100644 --- a/vl.c +++ b/vl.c @@ -2232,8 +2232,8 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, } if (bdrv_open2(dinfo->bdrv, file, bdrv_flags, drv) < 0) { - fprintf(stderr, "qemu: could not open disk image %s\n", - file); + fprintf(stderr, "qemu: could not open disk image %s: %s\n", + file, strerror(errno)); return NULL; }