qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Justin M. Forbes" <jmforbes@linuxtx.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Improve error reporting on file access
Date: Thu, 1 Oct 2009 09:42:56 -0500	[thread overview]
Message-ID: <20091001144256.GA30845@linuxtx.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: qemu-accurate-error-reporting.patch --]
[-- Type: text/plain, Size: 4471 bytes --]

commit 1755cdcf9c6328bdcc8558a38af774e31421a145
Author: Justin M. Forbes <jforbes@redhat.com>
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 <jforbes@redhat.com>

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);
             }
         }

             reply	other threads:[~2009-10-01 14:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-01 14:42 Justin M. Forbes [this message]
2009-10-01 16:12 ` [Qemu-devel] [PATCH] Improve error reporting on file access Mark McLoughlin
2009-10-27 16:51   ` Markus Armbruster
2009-10-27 17:38     ` malc
2009-11-29 12:20       ` Andreas Färber
2010-01-18 17:43         ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091001144256.GA30845@linuxtx.org \
    --to=jmforbes@linuxtx.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).