From: "Benoît Canet" <benoit.canet@gmail.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, "Benoît Canet" <benoit@irqsave.net>
Subject: [Qemu-devel] [PATCH 1/2] migration: Allow the migrate command to work on file: urls
Date: Thu, 23 Aug 2012 14:28:07 +0200 [thread overview]
Message-ID: <1345724888-30204-2-git-send-email-benoit@irqsave.net> (raw)
In-Reply-To: <1345724888-30204-1-git-send-email-benoit@irqsave.net>
Usage:
(qemu) migrate file:/path/to/vm_statefile
Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
migration-fd.c | 4 ++--
migration.c | 20 +++++++++++++++++++-
migration.h | 2 +-
3 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/migration-fd.c b/migration-fd.c
index 50138ed..d39e44a 100644
--- a/migration-fd.c
+++ b/migration-fd.c
@@ -73,9 +73,9 @@ static int fd_close(MigrationState *s)
return 0;
}
-int fd_start_outgoing_migration(MigrationState *s, const char *fdname)
+int fd_start_outgoing_migration(MigrationState *s, const char *fdname, int fd)
{
- s->fd = monitor_get_fd(cur_mon, fdname);
+ s->fd = fd ? fd : monitor_get_fd(cur_mon, fdname);
if (s->fd == -1) {
DPRINTF("fd_migration: invalid file descriptor identifier\n");
goto err_after_get_fd;
diff --git a/migration.c b/migration.c
index 1edeec5..679847d 100644
--- a/migration.c
+++ b/migration.c
@@ -239,9 +239,14 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
static int migrate_fd_cleanup(MigrationState *s)
{
int ret = 0;
+ struct stat st;
qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
+ if (!fstat(s->fd, &st) && S_ISREG(st.st_mode)) {
+ fsync(s->fd);
+ }
+
if (s->file) {
DPRINTF("closing file\n");
ret = qemu_fclose(s->file);
@@ -475,6 +480,17 @@ void migrate_del_blocker(Error *reason)
migration_blockers = g_slist_remove(migration_blockers, reason);
}
+static int file_start_outgoing_migration(MigrationState *s,
+ const char *filename)
+{
+ int fd;
+ fd = open(filename, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR);
+ if (fd < 0) {
+ return -errno;
+ }
+ return fd_start_outgoing_migration(s, NULL, fd);
+}
+
void qmp_migrate(const char *uri, bool has_blk, bool blk,
bool has_inc, bool inc, bool has_detach, bool detach,
Error **errp)
@@ -511,7 +527,9 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
} else if (strstart(uri, "unix:", &p)) {
ret = unix_start_outgoing_migration(s, p);
} else if (strstart(uri, "fd:", &p)) {
- ret = fd_start_outgoing_migration(s, p);
+ ret = fd_start_outgoing_migration(s, p, 0);
+ } else if (strstart(uri, "file:", &p)) {
+ ret = file_start_outgoing_migration(s, p);
#endif
} else {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "uri", "a valid migration protocol");
diff --git a/migration.h b/migration.h
index a9852fc..d431284 100644
--- a/migration.h
+++ b/migration.h
@@ -69,7 +69,7 @@ int unix_start_outgoing_migration(MigrationState *s, const char *path);
int fd_start_incoming_migration(const char *path);
-int fd_start_outgoing_migration(MigrationState *s, const char *fdname);
+int fd_start_outgoing_migration(MigrationState *s, const char *fdname, int fd);
void migrate_fd_error(MigrationState *s);
--
1.7.9.5
next prev parent reply other threads:[~2012-08-23 12:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-23 12:28 [Qemu-devel] [PATCH 0/2] Add file url support to migration Benoît Canet
2012-08-23 12:28 ` Benoît Canet [this message]
2012-08-23 12:34 ` [Qemu-devel] [PATCH 1/2] migration: Allow the migrate command to work on file: urls Daniel P. Berrange
2012-08-23 12:48 ` Benoît Canet
2012-08-23 12:58 ` Daniel P. Berrange
2012-08-23 13:34 ` Benoît Canet
2012-08-27 7:36 ` Benoît Canet
2012-08-28 13:11 ` Luiz Capitulino
2012-08-23 12:28 ` [Qemu-devel] [PATCH 2/2] migration: Allow -incoming " Benoît Canet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1345724888-30204-2-git-send-email-benoit@irqsave.net \
--to=benoit.canet@gmail.com \
--cc=aliguori@us.ibm.com \
--cc=benoit@irqsave.net \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).