From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeoH7-0001QS-Mn for qemu-devel@nongnu.org; Wed, 23 Sep 2015 13:56:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeoH2-0006rU-MY for qemu-devel@nongnu.org; Wed, 23 Sep 2015 13:56:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41367) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeoH2-0006qt-FW for qemu-devel@nongnu.org; Wed, 23 Sep 2015 13:56:08 -0400 Date: Wed, 23 Sep 2015 18:56:00 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20150923175559.GD13453@work-vm> References: <1434450415-11339-1-git-send-email-dgilbert@redhat.com> <1434450415-11339-29-git-send-email-dgilbert@redhat.com> <87a8v0jjvt.fsf@neno.neno> <20150713175654.GM2492@work-vm> <87io9ohqtn.fsf@neno.neno> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87io9ohqtn.fsf@neno.neno> Subject: Re: [Qemu-devel] [PATCH v7 28/42] Postcopy: Postcopy startup in migration thread List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, liang.z.li@intel.com, qemu-devel@nongnu.org, luis@cs.umu.se, amit.shah@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au * Juan Quintela (quintela@redhat.com) wrote: > "Dr. David Alan Gilbert" wrote: > >> > + * We need to leave the fd free for page transfers during the > >> > + * loading of the device state, so wrap all the remaining > >> > + * commands and state into a package that gets sent in one go > >> > + */ > >> > + QEMUFile *fb = qemu_bufopen("w", NULL); > >> > + if (!fb) { > >> > + error_report("Failed to create buffered file"); > >> > + goto fail; > >> > + } > >> > + > >> > + qemu_savevm_state_complete_precopy(fb); > >> > + qemu_savevm_send_ping(fb, 3); > >> > + > >> > + qemu_savevm_send_postcopy_run(fb); > >> > + > >> > + /* <><> end of stuff going into the package */ > >> > + qsb = qemu_buf_get(fb); > >> > + > >> > + /* Now send that blob */ > >> > + if (qemu_savevm_send_packaged(ms->file, qsb)) { > >> > + goto fail_closefb; > >> > + } > >> > + qemu_fclose(fb); > >> > >> Why can't we send this directly without the extra copy? > >> I guess that there are some missing/extra section starts/end whatever? > >> Anything specific? > > > > The problem is that the destination has to be able to read the chunk > > of migration stream off the fd and leave the fd free for page requests > > that may be required during loading the device state. > > Since the migration-stream is unstructured, there is no way to read > > a chunk of stream off without knowing the length of that chunk, and the > > only way to know that chunk is to write it to a buffer and then see > > how big it is. > > Arghhh. ok. Comment? I've changed the comment at the start of that section to: * While loading the device state we may trigger page transfer * requests and the fd must be free to process those, and thus * the destination must read the whole device state off the fd before * it starts processing it. Unfortunately the ad-hoc migration format * doesn't allow the destination to know the size to read without fully * parsing it through each devices load-state code (especially the open * coded devices that use get/put). * So we wrap the device state up in a package with a length at the start; * to do this we use a qemu_buf to hold the whole of the device state. Dave > > > > >> > + ms->downtime = qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - time_at_stop; > >> > >> Now, that we are here, is there a counter of the time that takes the > >> postcopy stage? Just curious. > > > > No, not separate. > > > >> > +/* > >> > * Master migration thread on the source VM. > >> > * It drives the migration and pumps the data down the outgoing channel. > >> > */ > >> > static void *migration_thread(void *opaque) > >> > { > >> > MigrationState *s = opaque; > >> > + /* Used by the bandwidth calcs, updated later */ > >> > int64_t initial_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); > >> > int64_t setup_start = qemu_clock_get_ms(QEMU_CLOCK_HOST); > >> > int64_t initial_bytes = 0; > >> > int64_t max_size = 0; > >> > int64_t start_time = initial_time; > >> > bool old_vm_running = false; > >> > + bool entered_postcopy = false; > >> > + /* The active state we expect to be in; ACTIVE or POSTCOPY_ACTIVE */ > >> > + enum MigrationStatus current_active_type = MIGRATION_STATUS_ACTIVE; > >> > >> current_active_state? > > > > Changed. > > > > Dave > > > > -- > > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK