From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LPFB9-0005dr-91 for qemu-devel@nongnu.org; Tue, 20 Jan 2009 06:53:59 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LPFB3-0005d1-P0 for qemu-devel@nongnu.org; Tue, 20 Jan 2009 06:53:55 -0500 Received: from [199.232.76.173] (port=44801 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LPFB1-0005cb-9l for qemu-devel@nongnu.org; Tue, 20 Jan 2009 06:53:52 -0500 Received: from mx1.redhat.com ([66.187.233.31]:32871) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LPFB0-0005y5-Rt for qemu-devel@nongnu.org; Tue, 20 Jan 2009 06:53:51 -0500 Date: Tue, 20 Jan 2009 11:53:47 +0000 From: "Daniel P. Berrange" Subject: Re: [Qemu-devel] [PATCH] migration: adding migration to/from a file Message-ID: <20090120115347.GK6004@redhat.com> References: <1232324325-25060-1-git-send-email-uril@redhat.com> <49749820.2070209@codemonkey.ws> <4975B648.5050104@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4975B648.5050104@redhat.com> Reply-To: "Daniel P. Berrange" , qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Tue, Jan 20, 2009 at 01:32:24PM +0200, Uri Lublin wrote: > Anthony Liguori wrote: > >Uri Lublin wrote: > >>Migration to file, reuses migration-to-fd. > >>Migration from file, uses qemu-fopen directly. > >> > >>The saved state-file should be used only once and removed (or used > >>with -snapshot, or a the disk-image should be copied), as the > >>disk image is not saved, only the VM state. > >> > >>Also there is not point of doing a _live_ migration to file (except > >>for debugging migration code), so I recommend to stop the VM before > >>migrating its state to a file. > >> > >>An advantage migration-to-file over savevm/loadvm is that for the latter > >>a qcow2 is a requirement, while the former works for any image-format. > >> > >>Signed-off-by: Uri Lublin > >>--- > > >>+ > >>+MigrationState *file_start_outgoing_migration(const char *filename, > >>+ int64_t bandwidth_limit, > >>+ int async) > >>+{ > >>+ FdMigrationState *s; > >>+ int fd; > >>+ > >>+ s = qemu_mallocz(sizeof(*s)); > >>+ if (s == NULL) { > >>+ perror("file_migration: qemu_mallocz failed"); > >>+ term_printf("file_migration: qemu_mallocz failed"); > >>+ goto err1; > >>+ } > >>+ > >>+ fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0600); > >>+ if (fd < 0) { > >>+ perror("file_migration: failed to open filename"); > >>+ term_printf("file_migration: failed to open filename %s\n", > >>filename); > >>+ goto err2; > >>+ } > >> > > > >The migration code assumes that the file descriptor used is > >non-blocking. In general, open() on a file system cannot produce a > >non-blocking file descriptor. > > I can call fcntl with F_SETFL and O_NONBLOCK. IIRC that doesn't have any effect on plain files - they'll still potentially block on write. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|