dump: Show custom message for ENOSPC
PATCH v2 1/1 dump: Show custom message for ENOSPC
This patch intends to make a more specific message for when the system has not enough space to save guest memory.
--- dump.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
dump.c +6 -2
@@ -106,7 +106,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 ;
@@ -364,7 +364,11 @@ 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" ); +if (ret == -ENOSPC ) { +error_setg (errp,"dump: not enough space to save memory" ); + }else { +error_setg (errp,"dump: failed to save memory" ); + } }else { s->written_size += length; }
Signature · 1 line
2.14.1
Quoted 9 lines · Yasmin Beatriz
This patch intends to make a more specific message for when the system has not enough space to save guest memory.
Reported-by [email protected]Cc Jose Ricardo Ziviani <[email protected]>Signed-off-by Yasmin Beatriz <[email protected]>--- dump.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Quoted 26 lines
dump.c +6
-2@@ -106,7 +106,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 ;@@ -364,7 +364,11 @@ 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" ); +if (ret == -ENOSPC ) { +error_setg (errp,"dump: not enough space to save memory" ); + }else { +error_setg (errp,"dump: failed to save memory" ); + } }else { s->written_size += length; }
Quoted 9 lines · Yasmin Beatriz
This patch intends to make a more specific message for when the system has not enough space to save guest memory.
Reported-by [email protected]Cc Jose Ricardo Ziviani <[email protected]>Signed-off-by Yasmin Beatriz <[email protected]>---
dump.c static void write_data(DumpState *s, void *buf, int length, Error **errp) · line 371
Quoted 9 lines
dump.c +5
-1@@ -364,7 +364,11 @@ 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" ); +if (ret == -ENOSPC ) { +error_setg (errp,"dump: not enough space to save memory" ); + }else { +error_setg (errp,"dump: failed to save memory" ); + }
Why is this caller the only one in the file that gets distinguished error messages? And why not use error_setg_errno() instead of open-coding just one special errno value? If you're changing the return value of fd_write_vmcore() anyways, I'd suggest that ALL callers in the file be updated to use error_setg_errno().
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 9 lines · Eric Blake
Quoted 7 lines · Yasmin Beatriz
This patch intends to make a more specific message for when the system has not enough space to save guest memory.
Reported-by [email protected]Cc Jose Ricardo Ziviani <[email protected]>Signed-off-by Yasmin Beatriz <[email protected]>---
Quoted 15 lines
dump.c static void write_data(DumpState *s, void *buf, int length, Error **errp) · line 370
Quoted 9 lines
dump.c +5
-1@@ -364,7 +364,11 @@ 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" ); +if (ret == -ENOSPC ) { +error_setg (errp,"dump: not enough space to save memory" ); + }else { +error_setg (errp,"dump: failed to save memory" ); + }Why is this caller the only one in the file that gets distinguished error messages? And why not use
error_setg_errno()instead of open-coding just one special errno value? If you're changing the return value offd_write_vmcore()anyways, I'd suggest that ALL callers in the file be updated to useerror_setg_errno().
Hello Eric, thanks for reviewing it! :)
Yes, only this part has this distiguished error handling because the whole big amount of data is managed in here, as far as we can tell it.
It's triggered when you have one of those huge memory guests that crashes and want to dump its memory into a host that can't offer all these requirements. AFAIK, other callers doesn't handle so much data, so we decided to handle only in this part to be the less intrusive possible.
Your suggestions will be applied then!
Quoted 6 lines
Signature · 4 lines
-- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org