From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:44109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4Wpt-000282-O7 for qemu-devel@nongnu.org; Thu, 23 Aug 2012 08:48:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T4Wps-0005iX-1j for qemu-devel@nongnu.org; Thu, 23 Aug 2012 08:48:33 -0400 Received: from paradis.irqsave.net ([109.190.18.76]:37346) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4Wpr-0005i6-Lf for qemu-devel@nongnu.org; Thu, 23 Aug 2012 08:48:31 -0400 Date: Thu, 23 Aug 2012 14:48:19 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20120823124819.GA17575@irqsave.net> References: <1345724888-30204-1-git-send-email-benoit@irqsave.net> <1345724888-30204-2-git-send-email-benoit@irqsave.net> <20120823123401.GD10833@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20120823123401.GD10833@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [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: "Daniel P. Berrange" Cc: aliguori@us.ibm.com, =?iso-8859-1?Q?Beno=EEt?= Canet , qemu-devel@nongnu.org Le Thursday 23 Aug 2012 =E0 13:34:01 (+0100), Daniel P. Berrange a =E9cri= t : > On Thu, Aug 23, 2012 at 02:28:07PM +0200, Beno=EEt Canet wrote: > > Usage: > > (qemu) migrate file:/path/to/vm_statefile > >=20 > > Signed-off-by: Benoit Canet > > --- > > migration-fd.c | 4 ++-- > > migration.c | 20 +++++++++++++++++++- > > migration.h | 2 +- > > 3 files changed, 22 insertions(+), 4 deletions(-) > >=20 > > 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; > > } > > =20 > > -int fd_start_outgoing_migration(MigrationState *s, const char *fdnam= e) > > +int fd_start_outgoing_migration(MigrationState *s, const char *fdnam= e, int fd) > > { > > - s->fd =3D monitor_get_fd(cur_mon, fdname); > > + s->fd =3D fd ? fd : monitor_get_fd(cur_mon, fdname); > > if (s->fd =3D=3D -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(MigrationCapab= ilityStatusList *params, > > static int migrate_fd_cleanup(MigrationState *s) > > { > > int ret =3D 0; > > + struct stat st; > > =20 > > qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); > > =20 > > + if (!fstat(s->fd, &st) && S_ISREG(st.st_mode)) { > > + fsync(s->fd); > > + } > > + > > if (s->file) { > > DPRINTF("closing file\n"); > > ret =3D qemu_fclose(s->file); > > @@ -475,6 +480,17 @@ void migrate_del_blocker(Error *reason) > > migration_blockers =3D g_slist_remove(migration_blockers, reason= ); > > } > > =20 > > +static int file_start_outgoing_migration(MigrationState *s, > > + const char *filename) > > +{ > > + int fd; > > + fd =3D 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); >=20 > 'fd_start_outgoing_migration' requires that the FD you give it > supports non-blocking I/O. File descriptors opened from plain > files or block devices do not honour that requirement. So this > proposed code will cause the entire QEMU process to block while > migration is taking place. This is why no on has ever implemented > the 'file:' protocol in QEMU before. When I run the code it appear it does not block all the time. (guest is still interactive most of the time needed to complete migration= ) How can it be ? Beno=EEt >=20 > To deal with this issue you'd either have to use the POSIX > async I/O APIs (or QEMU's internal equivalent), or spawn a > separate 'dd' helper process and give QEMU a pipe FD instead. > The latter is what libvirt does to implement migrate to file. >=20 > Daniel > --=20 > |: http://berrange.com -o- http://www.flickr.com/photos/dberran= ge/ :| > |: http://libvirt.org -o- http://virt-manager.= org :| > |: http://autobuild.org -o- http://search.cpan.org/~danbe= rr/ :| > |: http://entangle-photo.org -o- http://live.gnome.org/gtk-= vnc :|