From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6LZT-0003UG-Pl for qemu-devel@nongnu.org; Tue, 28 Aug 2012 09:11:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T6LZN-0005bI-8c for qemu-devel@nongnu.org; Tue, 28 Aug 2012 09:11:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56430) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6LZM-0005Zm-W7 for qemu-devel@nongnu.org; Tue, 28 Aug 2012 09:11:01 -0400 Date: Tue, 28 Aug 2012 10:11:42 -0300 From: Luiz Capitulino Message-ID: <20120828101142.3232d21c@doriath.home> In-Reply-To: <20120827073604.GA2179@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> <20120827073604.GA2179@irqsave.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 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?B?QmVub+50?= Canet Cc: qemu-devel@nongnu.org, Juan Jose Quintela Carreira On Mon, 27 Aug 2012 09:36:05 +0200 Beno=EEt Canet wrote: > Adding Luiz to the thread since he is concerned by migration. >=20 > Luiz do you have any hints on doing this properly ? I don't. Juan is a better option though. But, we use exec migration for this, no? >=20 > Beno=EEt >=20 > > 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 *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. > >=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 :| > >=20 >=20