Skip to contentSkip to conversation

pc.c: better error message on initrd sizing failure

PATCH In review Michael S. Tsirkin 2 participants 3 messages Feb 2, 2014 – Feb 5, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pc.c: better error message on initrd sizing failure

---
 hw/i386/pc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/i386/pc.c +2 -2
index 348b15f..e715a33 100644
@@ -835,8 +835,8 @@ static void load_linux(FWCfgState *fw_cfg,
 
         initrd_size = get_image_size(initrd_filename);
         if (initrd_size < 0) {
-            fprintf(stderr, "qemu: error reading initrd %s\n",
-                    initrd_filename);
+            fprintf(stderr, "qemu: error reading initrd %s: %s\n",
+                    initrd_filename, strerror(errno));
             exit(1);
         }
 
Signature · 1 line
MST
#1 lore raw
Quoted 10 lines · Michael S. Tsirkin
---
 hw/i386/pc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/i386/pc.c +0 -0
index 348b15f..e715a33 100644

hw/i386/pc.c static void load_linux(FWCfgState *fw_cfg, · line 840

Quoted 8 lines
hw/i386/pc.c +2 -2
@@ -835,8 +835,8 @@ static void load_linux(FWCfgState *fw_cfg,
 
         initrd_size = get_image_size(initrd_filename);
         if (initrd_size < 0) {
-            fprintf(stderr, "qemu: error reading initrd %s\n",
-                    initrd_filename);
+            fprintf(stderr, "qemu: error reading initrd %s: %s\n",
+                    initrd_filename, strerror(errno));
             exit(1);

get_image_size() happens to set errno on failure, but it doesn't guarantee to -- all the doc comment says currently is "return the size or -1 if error". If we're going to rely on errno being set in the failure case it would be nice to at least add an "(and errno is set)" to that. (Better still would be to transfer the info into a properly formatted doc comment for the prototype in include/hw/loader.h...)

thanks
-- PMM

#2 lore raw
Quoted 28 lines · Peter Maydell
Quoted 10 lines · Michael S. Tsirkin
---
 hw/i386/pc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/i386/pc.c +0 -0
index 348b15f..e715a33 100644

hw/i386/pc.c static void load_linux(FWCfgState *fw_cfg, · line 840

Quoted 8 lines
hw/i386/pc.c +2 -2
@@ -835,8 +835,8 @@ static void load_linux(FWCfgState *fw_cfg,
 
         initrd_size = get_image_size(initrd_filename);
         if (initrd_size < 0) {
-            fprintf(stderr, "qemu: error reading initrd %s\n",
-                    initrd_filename);
+            fprintf(stderr, "qemu: error reading initrd %s: %s\n",
+                    initrd_filename, strerror(errno));
             exit(1);

get_image_size() happens to set errno on failure, but it doesn't guarantee to -- all the doc comment says currently is "return the size or -1 if error". If we're going to rely on errno being set in the failure case it would be nice to at least add an "(and errno is set)" to that. (Better still would be to transfer the info into a properly formatted doc comment for the prototype in include/hw/loader.h...)

Quoted 2 lines

thanks
-- PMM

Good idea. This patch doesn't have to change though - I'll post an additional one with the comment.