From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQCrL-0001Tv-PA for qemu-devel@nongnu.org; Thu, 21 Jul 2016 08:13:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQCrH-0006v1-4P for qemu-devel@nongnu.org; Thu, 21 Jul 2016 08:13:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59602) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQCrG-0006uM-SZ for qemu-devel@nongnu.org; Thu, 21 Jul 2016 08:13:43 -0400 Date: Thu, 21 Jul 2016 13:13:38 +0100 From: "Daniel P. Berrange" Message-ID: <20160721121338.GF13528@redhat.com> Reply-To: "Daniel P. Berrange" References: <1469077560-20620-1-git-send-email-zhang.zhanghailiang@huawei.com> <1469077560-20620-2-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1469077560-20620-2-git-send-email-zhang.zhanghailiang@huawei.com> Subject: Re: [Qemu-devel] [RFC PATCH 1/2] migration: Allow the migrate command to work on file:urls List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: zhanghailiang Cc: qemu-devel@nongnu.org, Benoit Canet , quintela@redhat.com, peter.huangpeng@huawei.com, dgilbert@redhat.com, amit.shah@redhat.com On Thu, Jul 21, 2016 at 01:05:59PM +0800, zhanghailiang wrote: > Usage: > (qemu) migrate file:/path/to/vm_statefile > > Signed-off-by: zhanghailiang > Signed-off-by: Benoit Canet > --- > include/migration/migration.h | 2 ++ > migration/fd.c | 34 ++++++++++++++++++++++++++++------ > migration/migration.c | 2 ++ > migration/trace-events | 1 + > 4 files changed, 33 insertions(+), 6 deletions(-) > > diff --git a/include/migration/migration.h b/include/migration/migration.h > index 3c96623..cc2e4f6 100644 > --- a/include/migration/migration.h > +++ b/include/migration/migration.h > @@ -221,6 +221,8 @@ void fd_start_incoming_migration(const char *path, Error **errp); > > void fd_start_outgoing_migration(MigrationState *s, const char *fdname, 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); > > void rdma_start_incoming_migration(const char *host_port, Error **errp); > diff --git a/migration/fd.c b/migration/fd.c > index 84a10fd..fa5df67 100644 > --- a/migration/fd.c > +++ b/migration/fd.c > @@ -23,15 +23,11 @@ > #include "trace.h" > > > -void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp) > +static void fd_start_outgoing_migration_core(MigrationState *s, int fd, > + Error **errp) > { > QIOChannel *ioc; > - int fd = monitor_get_fd(cur_mon, fdname, errp); > - if (fd == -1) { > - return; > - } > > - trace_migration_fd_outgoing(fd); > ioc = qio_channel_new_fd(fd, errp); > if (!ioc) { > close(fd); > @@ -42,6 +38,32 @@ void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error ** > object_unref(OBJECT(ioc)); > } > > +void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp) > +{ > + int fd = monitor_get_fd(cur_mon, fdname, errp); > + if (fd == -1) { > + return; > + } > + > + trace_migration_fd_outgoing(fd); > + fd_start_outgoing_migration_core(s, fd, errp); > +} > + > +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; > + } > + > + trace_migration_file_outgoing(filename); > + fd_start_outgoing_migration_core(s, fd, errp); > +} This isn't going to fly. Annoyingly with plain files on POSIX platforms you can't get non-blocking I/O, so even though we'll be setting the O_NONBLOCK on fd shortly, I/O is still going to block the entire thread. The same applies for file reads wrt to your next patch supporting incoming mode. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|