From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNZBm-0002PM-57 for qemu-devel@nongnu.org; Thu, 14 Jul 2016 01:27:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNZBh-0006RA-Pq for qemu-devel@nongnu.org; Thu, 14 Jul 2016 01:27:57 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:2297) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNZBh-0006Qa-37 for qemu-devel@nongnu.org; Thu, 14 Jul 2016 01:27:53 -0400 References: <1452169208-840-1-git-send-email-zhang.zhanghailiang@huawei.com> <1452169208-840-3-git-send-email-zhang.zhanghailiang@huawei.com> <20160713161230.GE4573@work-vm> From: Hailiang Zhang Message-ID: <578722B5.6000207@huawei.com> Date: Thu, 14 Jul 2016 13:27:17 +0800 MIME-Version: 1.0 In-Reply-To: <20160713161230.GE4573@work-vm> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC 02/13] migration: Allow the migrate command to work on file: urls List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert" Cc: peter.huangpeng@huawei.com, qemu-devel@nongnu.org, aarcange@redhat.com, quintela@redhat.com, amit.shah@redhat.com, hanweidong@huawei.com, Benoit Canet On 2016/7/14 0:12, Dr. David Alan Gilbert wrote: > * zhanghailiang (zhang.zhanghailiang@huawei.com) wrote: >> Usage: >> (qemu) migrate file:/path/to/vm_statefile >> >> Signed-off-by: zhanghailiang >> Signed-off-by: Benoit Canet >> --- >> - With this patch, we can easily test memory snapshot >> - Rebase on qemu 2.5 >> --- >> include/migration/migration.h | 6 +++++- >> migration/fd.c | 19 +++++++++++++++++-- >> migration/migration.c | 4 +++- >> 3 files changed, 25 insertions(+), 4 deletions(-) > > Even if the rest of this series takes some time to finish; it might be > best to post this patch separately - it just a nice bit of simplification. > Of course now you have to rewrite using qio_channel_file_new_path > but I guess it's simple. > > (I've tended to use migrate "exec:cat > file" but a file: would be nice) > OK, if you need this, i will send it as a single patch. Thanks. > Dave > >> diff --git a/include/migration/migration.h b/include/migration/migration.h >> index 4c80939..bf4f8e9 100644 >> --- a/include/migration/migration.h >> +++ b/include/migration/migration.h >> @@ -193,7 +193,11 @@ void unix_start_outgoing_migration(MigrationState *s, const char *path, Error ** >> >> void fd_start_incoming_migration(const char *path, Error **errp); >> >> -void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp); >> +void fd_start_outgoing_migration(MigrationState *s, const char *fdname, >> + int outfd, Error **errp); >> + >> +void file_start_outgoing_migration(MigrationState *s, const char *filename, >> + Error **errp); >> >> void rdma_start_outgoing_migration(void *opaque, const char *host_port, Error **errp); >> >> diff --git a/migration/fd.c b/migration/fd.c >> index 3e4bed0..b62161f 100644 >> --- a/migration/fd.c >> +++ b/migration/fd.c >> @@ -42,9 +42,10 @@ static bool fd_is_socket(int fd) >> return S_ISSOCK(stat.st_mode); >> } >> >> -void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp) >> +void fd_start_outgoing_migration(MigrationState *s, const char *fdname, >> + int outfd, Error **errp) >> { >> - int fd = monitor_get_fd(cur_mon, fdname, errp); >> + int fd = fdname ? monitor_get_fd(cur_mon, fdname, errp) : outfd; >> if (fd == -1) { >> return; >> } >> @@ -58,6 +59,20 @@ void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error ** >> migrate_fd_connect(s); >> } >> >> +void file_start_outgoing_migration(MigrationState *s, const char *filename, >> + Error **errp) >> +{ >> + int fd; >> + >> + fd = qemu_open(filename, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR); >> + if (fd < 0) { >> + error_setg_errno(errp, errno, "Failed to open file: %s", filename); >> + return; >> + } >> + fd_start_outgoing_migration(s, NULL, fd, errp); >> +} >> + >> + >> static void fd_accept_incoming_migration(void *opaque) >> { >> QEMUFile *f = opaque; >> diff --git a/migration/migration.c b/migration/migration.c >> index c842499..3ec3b85 100644 >> --- a/migration/migration.c >> +++ b/migration/migration.c >> @@ -1021,7 +1021,9 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, >> } else if (strstart(uri, "unix:", &p)) { >> unix_start_outgoing_migration(s, p, &local_err); >> } else if (strstart(uri, "fd:", &p)) { >> - fd_start_outgoing_migration(s, p, &local_err); >> + fd_start_outgoing_migration(s, p, -1, &local_err); >> + } else if (strstart(uri, "file:", &p)) { >> + file_start_outgoing_migration(s, p, &local_err); >> #endif >> } else { >> error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "uri", >> -- >> 1.8.3.1 >> >> > -- > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK > > . >