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 2/2] migration: Allow -incoming to work on file: urls
Date: Thu, 23 Aug 2012 14:28:08 +0200 [thread overview]
Message-ID: <1345724888-30204-3-git-send-email-benoit@irqsave.net> (raw)
In-Reply-To: <1345724888-30204-1-git-send-email-benoit@irqsave.net>
Usage:
-incoming file:/path/to/vm_statefile
Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
migration-fd.c | 5 ++---
migration.c | 14 +++++++++++++-
migration.h | 2 +-
3 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/migration-fd.c b/migration-fd.c
index d39e44a..bf500a0 100644
--- a/migration-fd.c
+++ b/migration-fd.c
@@ -108,14 +108,13 @@ static void fd_accept_incoming_migration(void *opaque)
qemu_fclose(f);
}
-int fd_start_incoming_migration(const char *infd)
+int fd_start_incoming_migration(const char *infd, int fd)
{
- int fd;
QEMUFile *f;
DPRINTF("Attempting to start an incoming migration via fd\n");
- fd = strtol(infd, NULL, 0);
+ fd = fd ? fd : strtol(infd, NULL, 0);
f = qemu_fdopen(fd, "rb");
if(f == NULL) {
DPRINTF("Unable to apply qemu wrapper to file descriptor\n");
diff --git a/migration.c b/migration.c
index 679847d..e4b228e 100644
--- a/migration.c
+++ b/migration.c
@@ -64,6 +64,16 @@ static MigrationState *migrate_get_current(void)
return ¤t_migration;
}
+static int file_start_incoming_migration(const char *filename)
+{
+ int fd;
+ fd = open(filename, O_RDONLY);
+ if (fd < 0) {
+ return -errno;
+ }
+ return fd_start_incoming_migration(NULL, fd);
+}
+
int qemu_start_incoming_migration(const char *uri, Error **errp)
{
const char *p;
@@ -77,7 +87,9 @@ int qemu_start_incoming_migration(const char *uri, Error **errp)
else if (strstart(uri, "unix:", &p))
ret = unix_start_incoming_migration(p);
else if (strstart(uri, "fd:", &p))
- ret = fd_start_incoming_migration(p);
+ ret = fd_start_incoming_migration(p, 0);
+ else if (strstart(uri, "file:", &p))
+ ret = file_start_incoming_migration(p);
#endif
else {
fprintf(stderr, "unknown migration protocol: %s\n", uri);
diff --git a/migration.h b/migration.h
index d431284..dbdaf72 100644
--- a/migration.h
+++ b/migration.h
@@ -67,7 +67,7 @@ int unix_start_incoming_migration(const char *path);
int unix_start_outgoing_migration(MigrationState *s, const char *path);
-int fd_start_incoming_migration(const char *path);
+int fd_start_incoming_migration(const char *path, int fd);
int fd_start_outgoing_migration(MigrationState *s, const char *fdname, int fd);
--
1.7.9.5
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 ` [Qemu-devel] [PATCH 1/2] migration: Allow the migrate command to work on file: urls Benoît Canet
2012-08-23 12:34 ` 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 ` Benoît Canet [this message]
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-3-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).