]> git.proxmox.com Git - qemu.git/commitdiff
qemu-file: check exit status when closing a pipe QEMUFile
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 22 Feb 2013 16:36:38 +0000 (17:36 +0100)
committerJuan Quintela <quintela@redhat.com>
Mon, 11 Mar 2013 12:32:02 +0000 (13:32 +0100)
This is what exec_close does.  Move this to the underlying QEMUFile.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
include/qemu/osdep.h
migration-exec.c
savevm.c

index 87d3b9cfa8f720d247f57eaed1de0096aad01204..df244006c72fa91b22724f9ac2dc5360bfc17520 100644 (file)
@@ -9,6 +9,13 @@
 #include <sys/signal.h>
 #endif
 
+#ifndef _WIN32
+#include <sys/wait.h>
+#else
+#define WIFEXITED(x)   1
+#define WEXITSTATUS(x) (x)
+#endif
+
 #include <sys/time.h>
 
 #if defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10
index 5dc73139a4d2edfb86c25603d48fb56847fae077..a2b5f8d7293ab59da74e9c1a392280da2373a6f6 100644 (file)
@@ -50,10 +50,6 @@ static int exec_close(MigrationState *s)
     ret = qemu_fclose(s->opaque);
     s->opaque = NULL;
     s->fd = -1;
-    if (ret >= 0 && !(WIFEXITED(ret) && WEXITSTATUS(ret) == 0)) {
-        /* close succeeded, but non-zero exit code: */
-        ret = -EIO; /* fake errno value */
-    }
     return ret;
 }
 
index 1d49fde68b484abd74d4c12d7cc570ad949ba5fa..6d6f1f1ca6ca0daa29b8519cca2a13692acf509d 100644 (file)
--- a/savevm.c
+++ b/savevm.c
@@ -247,6 +247,9 @@ static int stdio_pclose(void *opaque)
     ret = pclose(s->stdio_file);
     if (ret == -1) {
         ret = -errno;
+    } else if (!WIFEXITED(ret) || WEXITSTATUS(ret) != 0) {
+        /* close succeeded, but non-zero exit code: */
+        ret = -EIO; /* fake errno value */
     }
     g_free(s);
     return ret;