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>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Justin M. Forbes 2009-10-01 09:42:56 -05:00 committed by Anthony Liguori
parent 6c098407ef
commit 850810d01b
2 changed files with 16 additions and 16 deletions

12
hw/pc.c
View file

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