From patchwork Thu Oct 1 14:42:56 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Forbes X-Patchwork-Id: 34728 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 974ECB7BD0 for ; Fri, 2 Oct 2009 00:46:04 +1000 (EST) Received: from localhost ([127.0.0.1]:38746 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MtMur-0008Cm-M6 for incoming@patchwork.ozlabs.org; Thu, 01 Oct 2009 10:45:57 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MtMs5-0007MH-RL for qemu-devel@nongnu.org; Thu, 01 Oct 2009 10:43:06 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MtMs1-0007KW-R4 for qemu-devel@nongnu.org; Thu, 01 Oct 2009 10:43:05 -0400 Received: from [199.232.76.173] (port=53257 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MtMs1-0007KR-MA for qemu-devel@nongnu.org; Thu, 01 Oct 2009 10:43:01 -0400 Received: from mail-pz0-f188.google.com ([209.85.222.188]:57532) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MtMs1-00063R-3B for qemu-devel@nongnu.org; Thu, 01 Oct 2009 10:43:01 -0400 Received: by pzk26 with SMTP id 26so176869pzk.4 for ; Thu, 01 Oct 2009 07:42:59 -0700 (PDT) Received: by 10.141.34.20 with SMTP id m20mr246172rvj.120.1254408179303; Thu, 01 Oct 2009 07:42:59 -0700 (PDT) Received: from linuxtx.org (cpe-76-182-243-52.tx.res.rr.com [76.182.243.52]) by mx.google.com with ESMTPS id 22sm71893yxe.3.2009.10.01.07.42.58 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 01 Oct 2009 07:42:58 -0700 (PDT) Date: Thu, 1 Oct 2009 09:42:56 -0500 From: "Justin M. Forbes" To: qemu-devel@nongnu.org Message-ID: <20091001144256.GA30845@linuxtx.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.17 (2007-11-01) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH] Improve error reporting on file access 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 commit 1755cdcf9c6328bdcc8558a38af774e31421a145 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 diff --git a/hw/pc.c b/hw/pc.c index bc2875e..8e54fa4 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -844,8 +844,8 @@ static void load_linux(void *fw_cfg, if (!f || !(kernel_size = get_file_size(f)) || fread(header, 1, MIN(ARRAY_SIZE(header), kernel_size), f) != MIN(ARRAY_SIZE(header), kernel_size)) { - fprintf(stderr, "qemu: could not load kernel '%s'\n", - kernel_filename); + fprintf(stderr, "qemu: could not load kernel '%s': %s\n", + kernel_filename, strerror(errno)); exit(1); } @@ -950,8 +950,8 @@ static void load_linux(void *fw_cfg, fi = fopen(initrd_filename, "rb"); if (!fi) { - fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", - initrd_filename); + fprintf(stderr, "qemu: could not load initial ram disk '%s': %s\n", + initrd_filename, strerror(errno)); exit(1); } @@ -959,8 +959,8 @@ static void load_linux(void *fw_cfg, initrd_addr = (initrd_max-initrd_size) & ~4095; if (!fread_targphys_ok(initrd_addr, initrd_size, fi)) { - fprintf(stderr, "qemu: read error on initial ram disk '%s'\n", - initrd_filename); + fprintf(stderr, "qemu: read error on initial ram disk '%s': %s\n", + initrd_filename, strerror(errno)); exit(1); } fclose(fi); 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; } @@ -5487,7 +5487,7 @@ int main(int argc, char **argv, char **envp) if (len != 1) exit(1); else if (status == 1) { - fprintf(stderr, "Could not acquire pidfile\n"); + fprintf(stderr, "Could not acquire pidfile: %s\n", strerror(errno)); exit(1); } else exit(0); @@ -5514,7 +5514,7 @@ int main(int argc, char **argv, char **envp) uint8_t status = 1; write(fds[1], &status, 1); } else - fprintf(stderr, "Could not acquire pid file\n"); + fprintf(stderr, "Could not acquire pid file: %s\n", strerror(errno)); exit(1); } #endif @@ -5699,8 +5699,8 @@ int main(int argc, char **argv, char **envp) snprintf(label, sizeof(label), "serial%d", i); serial_hds[i] = qemu_chr_open(label, devname, NULL); if (!serial_hds[i]) { - fprintf(stderr, "qemu: could not open serial device '%s'\n", - devname); + fprintf(stderr, "qemu: could not open serial device '%s': %s\n", + devname, strerror(errno)); exit(1); } } @@ -5713,8 +5713,8 @@ int main(int argc, char **argv, char **envp) snprintf(label, sizeof(label), "parallel%d", i); parallel_hds[i] = qemu_chr_open(label, devname, NULL); if (!parallel_hds[i]) { - fprintf(stderr, "qemu: could not open parallel device '%s'\n", - devname); + fprintf(stderr, "qemu: could not open parallel device '%s': %s\n", + devname, strerror(errno)); exit(1); } } @@ -5727,8 +5727,8 @@ int main(int argc, char **argv, char **envp) snprintf(label, sizeof(label), "virtcon%d", i); virtcon_hds[i] = qemu_chr_open(label, devname, NULL); if (!virtcon_hds[i]) { - fprintf(stderr, "qemu: could not open virtio console '%s'\n", - devname); + fprintf(stderr, "qemu: could not open virtio console '%s': %s\n", + devname, strerror(errno)); exit(1); } }