aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dump.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/dump.c b/dump.c
index 6bdb0dbe23..669f715274 100644
--- a/dump.c
+++ b/dump.c
@@ -107,7 +107,7 @@ static int fd_write_vmcore(const void *buf, size_t size, void *opaque)
written_size = qemu_write_full(s->fd, buf, size);
if (written_size != size) {
- return -1;
+ return -errno;
}
return 0;
@@ -140,7 +140,7 @@ static void write_elf64_header(DumpState *s, Error **errp)
ret = fd_write_vmcore(&elf_header, sizeof(elf_header), s);
if (ret < 0) {
- error_setg(errp, "dump: failed to write elf header");
+ error_setg_errno(errp, -ret, "dump: failed to write elf header");
}
}
@@ -171,7 +171,7 @@ static void write_elf32_header(DumpState *s, Error **errp)
ret = fd_write_vmcore(&elf_header, sizeof(elf_header), s);
if (ret < 0) {
- error_setg(errp, "dump: failed to write elf header");
+ error_setg_errno(errp, -ret, "dump: failed to write elf header");
}
}
@@ -194,7 +194,8 @@ static void write_elf64_load(DumpState *s, MemoryMapping *memory_mapping,
ret = fd_write_vmcore(&phdr, sizeof(Elf64_Phdr), s);
if (ret < 0) {
- error_setg(errp, "dump: failed to write program header table");
+ error_setg_errno(errp, -ret,
+ "dump: failed to write program header table");
}
}
@@ -217,7 +218,8 @@ static void write_elf32_load(DumpState *s, MemoryMapping *memory_mapping,
ret = fd_write_vmcore(&phdr, sizeof(Elf32_Phdr), s);
if (ret < 0) {
- error_setg(errp, "dump: failed to write program header table");
+ error_setg_errno(errp, -ret,
+ "dump: failed to write program header table");
}
}
@@ -237,7 +239,8 @@ static void write_elf64_note(DumpState *s, Error **errp)
ret = fd_write_vmcore(&phdr, sizeof(Elf64_Phdr), s);
if (ret < 0) {
- error_setg(errp, "dump: failed to write program header table");
+ error_setg_errno(errp, -ret,
+ "dump: failed to write program header table");
}
}
@@ -302,7 +305,8 @@ static void write_elf32_note(DumpState *s, Error **errp)
ret = fd_write_vmcore(&phdr, sizeof(Elf32_Phdr), s);
if (ret < 0) {
- error_setg(errp, "dump: failed to write program header table");
+ error_setg_errno(errp, -ret,
+ "dump: failed to write program header table");
}
}
@@ -355,7 +359,8 @@ static void write_elf_section(DumpState *s, int type, Error **errp)
ret = fd_write_vmcore(&shdr, shdr_size, s);
if (ret < 0) {
- error_setg(errp, "dump: failed to write section header table");
+ error_setg_errno(errp, -ret,
+ "dump: failed to write section header table");
}
}
@@ -365,7 +370,7 @@ static void write_data(DumpState *s, void *buf, int length, Error **errp)
ret = fd_write_vmcore(buf, length, s);
if (ret < 0) {
- error_setg(errp, "dump: failed to save memory");
+ error_setg_errno(errp, -ret, "dump: failed to save memory");
} else {
s->written_size += length;
}