From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4WzX-00069n-ME for qemu-devel@nongnu.org; Thu, 23 Aug 2012 08:58:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T4WzW-0000Sy-9J for qemu-devel@nongnu.org; Thu, 23 Aug 2012 08:58:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10394) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4WzW-0000St-1o for qemu-devel@nongnu.org; Thu, 23 Aug 2012 08:58:30 -0400 Date: Thu, 23 Aug 2012 13:58:21 +0100 From: "Daniel P. Berrange" Message-ID: <20120823125821.GE10833@redhat.com> 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=utf-8 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 Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?utf-8?Q?Beno=C3=AEt?= Canet Cc: aliguori@us.ibm.com, =?utf-8?Q?Beno=C3=AEt?= Canet , qemu-devel@nongnu.org On Thu, Aug 23, 2012 at 02:48:19PM +0200, Beno=C3=AEt Canet wrote: > Le Thursday 23 Aug 2012 =C3=A0 13:34:01 (+0100), Daniel P. Berrange a =C3= =A9crit : > > On Thu, Aug 23, 2012 at 02:28:07PM +0200, Beno=C3=AEt 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 ? The default migration bandwidth limit means qemu throttles the rate at which it sends data, so you won't notice the flaw with I/O blocking. Daniel --=20 |: http://berrange.com -o- http://www.flickr.com/photos/dberrange= / :| |: http://libvirt.org -o- http://virt-manager.or= g :| |: http://autobuild.org -o- http://search.cpan.org/~danberr= / :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vn= c :|