render / rpms / qemu

Forked from rpms/qemu 5 months ago
Clone

Blame qemu-improve-error-reporting-on-file-access.patch

Mark McLoughlin 6d739f
From 565c62123258970d9254bc7b8eaa8f4c66ab2a21 Mon Sep 17 00:00:00 2001
Justin M. Forbes def6e7
From: Justin M. Forbes <jforbes@redhat.com>
Justin M. Forbes def6e7
Date: Thu, 1 Oct 2009 16:13:56 -0500
Justin M. Forbes def6e7
Subject: [PATCH] Improve error reporting on file access
Justin M. Forbes def6e7
Justin M. Forbes def6e7
By making the error reporting include strerror(errno), it gives the user
Justin M. Forbes def6e7
a bit more indication as to why qemu failed.  This is particularly
Justin M. Forbes def6e7
important for people running qemu as a non root user.
Justin M. Forbes def6e7
Mark McLoughlin 6d739f
(cherry-picked from commit 850810d01b45e6ce99ac6696773e967890db2937)
Mark McLoughlin 6d739f
Justin M. Forbes def6e7
Signed-off-by: Justin M. Forbes <jforbes@redhat.com>
Mark McLoughlin 6d739f
Fedora-patch: qemu-improve-error-reporting-on-file-access.patch
Justin M. Forbes def6e7
---
Justin M. Forbes def6e7
 hw/pc.c |   12 ++++++------
Justin M. Forbes def6e7
 vl.c    |   20 ++++++++++----------
Justin M. Forbes def6e7
 2 files changed, 16 insertions(+), 16 deletions(-)
Justin M. Forbes def6e7
Justin M. Forbes def6e7
diff --git a/hw/pc.c b/hw/pc.c
Justin M. Forbes def6e7
index 3b226f4..7a184cd 100644
Justin M. Forbes def6e7
--- a/hw/pc.c
Justin M. Forbes def6e7
+++ b/hw/pc.c
Justin M. Forbes def6e7
@@ -841,8 +841,8 @@ static void load_linux(void *fw_cfg,
Justin M. Forbes def6e7
     if (!f || !(kernel_size = get_file_size(f)) ||
Justin M. Forbes def6e7
 	fread(header, 1, MIN(ARRAY_SIZE(header), kernel_size), f) !=
Justin M. Forbes def6e7
 	MIN(ARRAY_SIZE(header), kernel_size)) {
Justin M. Forbes def6e7
-	fprintf(stderr, "qemu: could not load kernel '%s'\n",
Justin M. Forbes def6e7
-		kernel_filename);
Justin M. Forbes def6e7
+	fprintf(stderr, "qemu: could not load kernel '%s': %s\n",
Justin M. Forbes def6e7
+		kernel_filename, strerror(errno));
Justin M. Forbes def6e7
 	exit(1);
Justin M. Forbes def6e7
     }
Mark McLoughlin 6d739f
 
Justin M. Forbes def6e7
@@ -947,8 +947,8 @@ static void load_linux(void *fw_cfg,
Mark McLoughlin 6d739f
 
Justin M. Forbes def6e7
 	fi = fopen(initrd_filename, "rb");
Justin M. Forbes def6e7
 	if (!fi) {
Justin M. Forbes def6e7
-	    fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
Justin M. Forbes def6e7
-		    initrd_filename);
Justin M. Forbes def6e7
+	    fprintf(stderr, "qemu: could not load initial ram disk '%s': %s\n",
Justin M. Forbes def6e7
+		    initrd_filename, strerror(errno));
Justin M. Forbes def6e7
 	    exit(1);
Justin M. Forbes def6e7
 	}
Mark McLoughlin 6d739f
 
Justin M. Forbes def6e7
@@ -956,8 +956,8 @@ static void load_linux(void *fw_cfg,
Justin M. Forbes def6e7
 	initrd_addr = (initrd_max-initrd_size) & ~4095;
Mark McLoughlin 6d739f
 
Justin M. Forbes def6e7
 	if (!fread_targphys_ok(initrd_addr, initrd_size, fi)) {
Justin M. Forbes def6e7
-	    fprintf(stderr, "qemu: read error on initial ram disk '%s'\n",
Justin M. Forbes def6e7
-		    initrd_filename);
Justin M. Forbes def6e7
+	    fprintf(stderr, "qemu: read error on initial ram disk '%s': %s\n",
Justin M. Forbes def6e7
+		    initrd_filename, strerror(errno));
Justin M. Forbes def6e7
 	    exit(1);
Justin M. Forbes def6e7
 	}
Justin M. Forbes def6e7
 	fclose(fi);
Justin M. Forbes def6e7
diff --git a/vl.c b/vl.c
Justin M. Forbes def6e7
index d7c7ab1..9182d89 100644
Justin M. Forbes def6e7
--- a/vl.c
Justin M. Forbes def6e7
+++ b/vl.c
Justin M. Forbes def6e7
@@ -2379,8 +2379,8 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque)
Justin M. Forbes def6e7
     else if (cache == 2) /* write-back */
Justin M. Forbes def6e7
         bdrv_flags |= BDRV_O_CACHE_WB;
Justin M. Forbes def6e7
     if (bdrv_open2(bdrv, file, bdrv_flags, drv) < 0) {
Justin M. Forbes def6e7
-        fprintf(stderr, "qemu: could not open disk image %s\n",
Justin M. Forbes def6e7
-                        file);
Justin M. Forbes def6e7
+        fprintf(stderr, "qemu: could not open disk image %s: %s\n",
Justin M. Forbes def6e7
+                        file, strerror(errno));
Justin M. Forbes def6e7
         return -1;
Justin M. Forbes def6e7
     }
Justin M. Forbes def6e7
     if (bdrv_key_required(bdrv))
Justin M. Forbes def6e7
@@ -5799,7 +5799,7 @@ int main(int argc, char **argv, char **envp)
Justin M. Forbes def6e7
             if (len != 1)
Justin M. Forbes def6e7
                 exit(1);
Justin M. Forbes def6e7
             else if (status == 1) {
Justin M. Forbes def6e7
-                fprintf(stderr, "Could not acquire pidfile\n");
Justin M. Forbes def6e7
+                fprintf(stderr, "Could not acquire pidfile: %s\n", strerror(errno));
Justin M. Forbes def6e7
                 exit(1);
Justin M. Forbes def6e7
             } else
Justin M. Forbes def6e7
                 exit(0);
Justin M. Forbes def6e7
@@ -5826,7 +5826,7 @@ int main(int argc, char **argv, char **envp)
Justin M. Forbes def6e7
             uint8_t status = 1;
Justin M. Forbes def6e7
             write(fds[1], &status, 1);
Justin M. Forbes def6e7
         } else
Justin M. Forbes def6e7
-            fprintf(stderr, "Could not acquire pid file\n");
Justin M. Forbes def6e7
+            fprintf(stderr, "Could not acquire pid file: %s\n", strerror(errno));
Justin M. Forbes def6e7
         exit(1);
Justin M. Forbes def6e7
     }
Justin M. Forbes def6e7
 #endif
Justin M. Forbes def6e7
@@ -6031,8 +6031,8 @@ int main(int argc, char **argv, char **envp)
Justin M. Forbes def6e7
             snprintf(label, sizeof(label), "serial%d", i);
Justin M. Forbes def6e7
             serial_hds[i] = qemu_chr_open(label, devname, NULL);
Justin M. Forbes def6e7
             if (!serial_hds[i]) {
Justin M. Forbes def6e7
-                fprintf(stderr, "qemu: could not open serial device '%s'\n",
Justin M. Forbes def6e7
-                        devname);
Justin M. Forbes def6e7
+                fprintf(stderr, "qemu: could not open serial device '%s': %s\n",
Justin M. Forbes def6e7
+                        devname, strerror(errno));
Justin M. Forbes def6e7
                 exit(1);
Justin M. Forbes def6e7
             }
Justin M. Forbes def6e7
         }
Justin M. Forbes def6e7
@@ -6045,8 +6045,8 @@ int main(int argc, char **argv, char **envp)
Justin M. Forbes def6e7
             snprintf(label, sizeof(label), "parallel%d", i);
Justin M. Forbes def6e7
             parallel_hds[i] = qemu_chr_open(label, devname, NULL);
Justin M. Forbes def6e7
             if (!parallel_hds[i]) {
Justin M. Forbes def6e7
-                fprintf(stderr, "qemu: could not open parallel device '%s'\n",
Justin M. Forbes def6e7
-                        devname);
Justin M. Forbes def6e7
+                fprintf(stderr, "qemu: could not open parallel device '%s': %s\n",
Justin M. Forbes def6e7
+                        devname, strerror(errno));
Justin M. Forbes def6e7
                 exit(1);
Justin M. Forbes def6e7
             }
Justin M. Forbes def6e7
         }
Justin M. Forbes def6e7
@@ -6059,8 +6059,8 @@ int main(int argc, char **argv, char **envp)
Justin M. Forbes def6e7
             snprintf(label, sizeof(label), "virtcon%d", i);
Justin M. Forbes def6e7
             virtcon_hds[i] = qemu_chr_open(label, devname, NULL);
Justin M. Forbes def6e7
             if (!virtcon_hds[i]) {
Justin M. Forbes def6e7
-                fprintf(stderr, "qemu: could not open virtio console '%s'\n",
Justin M. Forbes def6e7
-                        devname);
Justin M. Forbes def6e7
+                fprintf(stderr, "qemu: could not open virtio console '%s': %s\n",
Justin M. Forbes def6e7
+                        devname, strerror(errno));
Justin M. Forbes def6e7
                 exit(1);
Justin M. Forbes def6e7
             }
Justin M. Forbes def6e7
         }
Justin M. Forbes def6e7
-- 
Justin M. Forbes def6e7
1.6.2.5
Justin M. Forbes def6e7