From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:33425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4XYd-0002UC-Au for qemu-devel@nongnu.org; Thu, 23 Aug 2012 09:34:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T4XYb-00040V-Gz for qemu-devel@nongnu.org; Thu, 23 Aug 2012 09:34:47 -0400 Received: from paradis.irqsave.net ([109.190.18.76]:37392) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4XYb-00040B-3b for qemu-devel@nongnu.org; Thu, 23 Aug 2012 09:34:45 -0400 Date: Thu, 23 Aug 2012 15:34:32 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20120823133431.GB17575@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> <20120823124819.GA17575@irqsave.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20120823124819.GA17575@irqsave.net> 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: =?iso-8859-1?Q?Beno=EEt?= Canet Cc: aliguori@us.ibm.com, =?iso-8859-1?Q?Beno=EEt?= Canet , qemu-devel@nongnu.org Le Thursday 23 Aug 2012 =E0 14:48:19 (+0200), Beno=EEt Canet a =E9crit : > Le Thursday 23 Aug 2012 =E0 13:34:01 (+0100), Daniel P. Berrange a =E9c= rit : > > 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 *fdn= ame) > > > +int fd_start_outgoing_migration(MigrationState *s, const char *fdn= ame, 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(MigrationCap= abilityStatusList *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, reas= on); > > > } > > > =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_IWUS= R); > > > + 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. >=20 > 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 migrati= on) > How can it be ? >=20 > Beno=EEt >=20 > >=20 > > To deal with this issue you'd either have to use the POSIX > > async I/O APIs (or QEMU's internal equivalent) I don't see how AIO could fit in this scheme. >, 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. I could subvert a exec_start_outgoing_migration clone to be fork_start_outgoing_migration doing a for then writing to disk the incoming data. Does any QEMU developper have an idea on this ? Beno=EEt > >=20 > > Daniel > > --=20 > > |: http://berrange.com -o- http://www.flickr.com/photos/dberr= ange/ :| > > |: http://libvirt.org -o- http://virt-manage= r.org :| > > |: http://autobuild.org -o- http://search.cpan.org/~dan= berr/ :| > > |: http://entangle-photo.org -o- http://live.gnome.org/gt= k-vnc :| >=20