aboutsummaryrefslogtreecommitdiffstats
path: root/migration-exec.c
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@android.com>2011-05-10 16:50:01 +0200
committerDavid 'Digit' Turner <digit@android.com>2011-06-01 17:08:18 +0200
commit986acc9eba2cf7c9b468c2f84764fa478907ac66 (patch)
tree3c5821af551f90d5dba1d1a5daf7254220066ba6 /migration-exec.c
parent39373b13009fd2c2d13b6804c3e2d146d1e11afa (diff)
downloadexternal_qemu-986acc9eba2cf7c9b468c2f84764fa478907ac66.zip
external_qemu-986acc9eba2cf7c9b468c2f84764fa478907ac66.tar.gz
external_qemu-986acc9eba2cf7c9b468c2f84764fa478907ac66.tar.bz2
savevm.c: minor integrate
Change-Id: I16103c65ac7b15b2dc58dcc7dd6b3052004aa31a
Diffstat (limited to 'migration-exec.c')
-rw-r--r--migration-exec.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/migration-exec.c b/migration-exec.c
index 0dd5aff..ab1dea2 100644
--- a/migration-exec.c
+++ b/migration-exec.c
@@ -20,14 +20,16 @@
#include "sysemu.h"
#include "buffered_file.h"
#include "block.h"
+#include <sys/types.h>
+#include <sys/wait.h>
//#define DEBUG_MIGRATION_EXEC
#ifdef DEBUG_MIGRATION_EXEC
-#define dprintf(fmt, ...) \
+#define DPRINTF(fmt, ...) \
do { printf("migration-exec: " fmt, ## __VA_ARGS__); } while (0)
#else
-#define dprintf(fmt, ...) \
+#define DPRINTF(fmt, ...) \
do { } while (0)
#endif
@@ -43,13 +45,21 @@ static int file_write(FdMigrationState *s, const void * buf, size_t size)
static int exec_close(FdMigrationState *s)
{
- dprintf("exec_close\n");
+ int ret = 0;
+ DPRINTF("exec_close\n");
if (s->opaque) {
- qemu_fclose(s->opaque);
+ ret = qemu_fclose(s->opaque);
s->opaque = NULL;
s->fd = -1;
+ if (ret != -1 &&
+ WIFEXITED(ret)
+ && WEXITSTATUS(ret) == 0) {
+ ret = 0;
+ } else {
+ ret = -1;
}
- return 0;
+ }
+ return ret;
}
MigrationState *exec_start_outgoing_migration(const char *command,
@@ -63,18 +73,18 @@ MigrationState *exec_start_outgoing_migration(const char *command,
f = popen(command, "w");
if (f == NULL) {
- dprintf("Unable to popen exec target\n");
+ DPRINTF("Unable to popen exec target\n");
goto err_after_alloc;
}
s->fd = fileno(f);
if (s->fd == -1) {
- dprintf("Unable to retrieve file descriptor for popen'd handle\n");
+ DPRINTF("Unable to retrieve file descriptor for popen'd handle\n");
goto err_after_open;
}
if (fcntl(s->fd, F_SETFD, O_NONBLOCK) == -1) {
- dprintf("Unable to set nonblocking mode on file descriptor\n");
+ DPRINTF("Unable to set nonblocking mode on file descriptor\n");
goto err_after_open;
}
@@ -116,9 +126,9 @@ static void exec_accept_incoming_migration(void *opaque)
goto err;
}
qemu_announce_self();
- dprintf("successfully loaded vm state\n");
+ DPRINTF("successfully loaded vm state\n");
/* we've successfully migrated, close the fd */
- qemu_set_fd_handler2(qemu_popen_fd(f), NULL, NULL, NULL, NULL);
+ qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
vm_start();
err:
@@ -129,14 +139,14 @@ int exec_start_incoming_migration(const char *command)
{
QEMUFile *f;
- dprintf("Attempting to start an incoming migration\n");
+ DPRINTF("Attempting to start an incoming migration\n");
f = qemu_popen_cmd(command, "r");
if(f == NULL) {
- dprintf("Unable to apply qemu wrapper to popen file\n");
+ DPRINTF("Unable to apply qemu wrapper to popen file\n");
return -errno;
}
- qemu_set_fd_handler2(qemu_popen_fd(f), NULL,
+ qemu_set_fd_handler2(qemu_stdio_fd(f), NULL,
exec_accept_incoming_migration, NULL,
(void *)(unsigned long)f);