From patchwork Tue Oct 27 16:51:43 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Improve error reporting on file access Date: Tue, 27 Oct 2009 06:51:43 -0000 From: Markus Armbruster X-Patchwork-Id: 37005 Message-Id: To: Mark McLoughlin Cc: "Justin M. Forbes" , qemu-devel@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; }