2013-05-25 18:38:28 +00:00
|
|
|
From 4f88dd44aa288f1ded954850a9a222f4ecdf00b8 Mon Sep 17 00:00:00 2001
|
2013-05-23 01:48:57 +00:00
|
|
|
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
|
Date: Fri, 22 Feb 2013 17:36:36 +0100
|
2013-05-25 18:38:28 +00:00
|
|
|
Subject: [PATCH] migration: merge qemu_popen_cmd with qemu_popen
|
2013-05-23 01:48:57 +00:00
|
|
|
|
|
|
|
There is no reason for outgoing exec migration to do popen manually
|
|
|
|
anymore (the reason used to be that we needed the FILE* to make it
|
|
|
|
non-blocking). Use qemu_popen_cmd.
|
|
|
|
|
|
|
|
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>
|
2013-05-25 18:38:28 +00:00
|
|
|
(cherry picked from commit 817b9ed5eb300dbb434d752da416441028539a96)
|
2013-05-23 01:48:57 +00:00
|
|
|
---
|
|
|
|
include/migration/qemu-file.h | 1 -
|
|
|
|
migration-exec.c | 10 ++++------
|
|
|
|
savevm.c | 22 ++++++++--------------
|
|
|
|
3 files changed, 12 insertions(+), 21 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h
|
|
|
|
index 46fc11d..987e719 100644
|
|
|
|
--- a/include/migration/qemu-file.h
|
|
|
|
+++ b/include/migration/qemu-file.h
|
|
|
|
@@ -77,7 +77,6 @@ QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops);
|
|
|
|
QEMUFile *qemu_fopen(const char *filename, const char *mode);
|
|
|
|
QEMUFile *qemu_fdopen(int fd, const char *mode);
|
|
|
|
QEMUFile *qemu_fopen_socket(int fd);
|
|
|
|
-QEMUFile *qemu_popen(FILE *popen_file, const char *mode);
|
|
|
|
QEMUFile *qemu_popen_cmd(const char *command, const char *mode);
|
|
|
|
int qemu_get_fd(QEMUFile *f);
|
|
|
|
int qemu_fclose(QEMUFile *f);
|
|
|
|
diff --git a/migration-exec.c b/migration-exec.c
|
|
|
|
index a051a6e..5dc7313 100644
|
|
|
|
--- a/migration-exec.c
|
|
|
|
+++ b/migration-exec.c
|
|
|
|
@@ -59,19 +59,17 @@ static int exec_close(MigrationState *s)
|
|
|
|
|
|
|
|
void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp)
|
|
|
|
{
|
|
|
|
- FILE *f;
|
|
|
|
-
|
|
|
|
- f = popen(command, "w");
|
|
|
|
+ QEMUFile *f;
|
|
|
|
+ f = qemu_popen_cmd(command, "w");
|
|
|
|
if (f == NULL) {
|
|
|
|
error_setg_errno(errp, errno, "failed to popen the migration target");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
- s->fd = fileno(f);
|
|
|
|
+ s->opaque = f;
|
|
|
|
+ s->fd = qemu_get_fd(f);
|
|
|
|
assert(s->fd != -1);
|
|
|
|
|
|
|
|
- s->opaque = qemu_popen(f, "w");
|
|
|
|
-
|
|
|
|
s->close = exec_close;
|
|
|
|
s->get_error = file_errno;
|
|
|
|
s->write = file_write;
|
|
|
|
diff --git a/savevm.c b/savevm.c
|
|
|
|
index fef2ab9..38699de 100644
|
|
|
|
--- a/savevm.c
|
|
|
|
+++ b/savevm.c
|
|
|
|
@@ -275,11 +275,17 @@ static const QEMUFileOps stdio_pipe_write_ops = {
|
|
|
|
.close = stdio_pclose
|
|
|
|
};
|
|
|
|
|
|
|
|
-QEMUFile *qemu_popen(FILE *stdio_file, const char *mode)
|
|
|
|
+QEMUFile *qemu_popen_cmd(const char *command, const char *mode)
|
|
|
|
{
|
|
|
|
+ FILE *stdio_file;
|
|
|
|
QEMUFileStdio *s;
|
|
|
|
|
|
|
|
- if (stdio_file == NULL || mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) {
|
|
|
|
+ stdio_file = popen(command, mode);
|
|
|
|
+ if (stdio_file == NULL) {
|
|
|
|
+ return NULL;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) {
|
|
|
|
fprintf(stderr, "qemu_popen: Argument validity check failed\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
@@ -296,18 +302,6 @@ QEMUFile *qemu_popen(FILE *stdio_file, const char *mode)
|
|
|
|
return s->file;
|
|
|
|
}
|
|
|
|
|
|
|
|
-QEMUFile *qemu_popen_cmd(const char *command, const char *mode)
|
|
|
|
-{
|
|
|
|
- FILE *popen_file;
|
|
|
|
-
|
|
|
|
- popen_file = popen(command, mode);
|
|
|
|
- if(popen_file == NULL) {
|
|
|
|
- return NULL;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return qemu_popen(popen_file, mode);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
static const QEMUFileOps stdio_file_read_ops = {
|
|
|
|
.get_fd = stdio_get_fd,
|
|
|
|
.get_buffer = stdio_get_buffer,
|