]> git.proxmox.com Git - qemu.git/commitdiff
qmp: dump-guest-memory: don't spin if non-blocking fd would block
authorLuiz Capitulino <lcapitulino@redhat.com>
Fri, 21 Sep 2012 16:17:55 +0000 (13:17 -0300)
committerLuiz Capitulino <lcapitulino@redhat.com>
Thu, 27 Sep 2012 12:46:17 +0000 (09:46 -0300)
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 <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
dump.c

diff --git a/dump.c b/dump.c
index 1a3c7164be6e717786f6e1ef995eb87a5a61f405..6b7c127906b102c11af5bb151bf1c31c4ed02ba0 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -100,18 +100,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;