From d42ae9d05ede90c423241c6d99a7c4980bfc765f Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: Luiz Capitulino Date: Fri, 5 Oct 2012 17:46:32 +0200 Subject: [PATCH 20/21] qmp: dump-guest-memory: don't spin if non-blocking fd would block RH-Author: Luiz Capitulino Message-id: <1349459193-18226-19-git-send-email-lcapitulino@redhat.com> Patchwork-id: 42766 O-Subject: [RHEL6.4 qemu-kvm PATCH 18/19] qmp: dump-guest-memory: don't spin if non-blocking fd would block Bugzilla: 832458 RH-Acked-by: Marcelo Tosatti RH-Acked-by: Markus Armbruster RH-Acked-by: Paolo Bonzini fd_write_vmcore() will indefinitely spin for a non-blocking file-descriptor that would block. However, if the fd is non-blocking, how does it make sense to spin? Change this behavior to return an error instead. Note that this can only happen with an fd provided by a management application. The fd opened internally by dump-guest-memory is blocking. While there, also fix 'writen_size' variable name. Signed-off-by: Luiz Capitulino Reviewed-by: Eric Blake Reviewed-by: Markus Armbruster (cherry picked from commit 2f61652d660ec1ffdadf926401a174c11f5c13a7) --- dump.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) Signed-off-by: Michal Novotny --- dump.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/dump.c b/dump.c index 0ca14f8..21c732e 100644 --- a/dump.c +++ b/dump.c @@ -105,18 +105,11 @@ static void dump_error(DumpState *s, const char *reason) static int fd_write_vmcore(void *buf, size_t size, void *opaque) { DumpState *s = opaque; - int fd = s->fd; - size_t writen_size; + size_t written_size; - /* The fd may be passed from user, and it can be non-blocked */ - while (size) { - writen_size = qemu_write_full(fd, buf, size); - if (writen_size != size && errno != EAGAIN) { - return -1; - } - - buf += writen_size; - size -= writen_size; + written_size = qemu_write_full(s->fd, buf, size); + if (written_size != size) { + return -1; } return 0; -- 1.7.11.4