From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEdI4-0007C1-LE for qemu-devel@nongnu.org; Mon, 13 Jul 2015 08:57:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZEdI1-0004yj-BH for qemu-devel@nongnu.org; Mon, 13 Jul 2015 08:57:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39143) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEdI1-0004yT-3j for qemu-devel@nongnu.org; Mon, 13 Jul 2015 08:56:57 -0400 From: Juan Quintela In-Reply-To: <1434450415-11339-29-git-send-email-dgilbert@redhat.com> (David Alan Gilbert's message of "Tue, 16 Jun 2015 11:26:41 +0100") References: <1434450415-11339-1-git-send-email-dgilbert@redhat.com> <1434450415-11339-29-git-send-email-dgilbert@redhat.com> Date: Mon, 13 Jul 2015 14:56:54 +0200 Message-ID: <87a8v0jjvt.fsf@neno.neno> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v7 28/42] Postcopy: Postcopy startup in migration thread Reply-To: quintela@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert (git)" 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 "Dr. David Alan Gilbert (git)" wrote: > From: "Dr. David Alan Gilbert" > > Rework the migration thread to setup and start postcopy. > > Signed-off-by: Dr. David Alan Gilbert > --- > include/migration/migration.h | 3 + > migration/migration.c | 166 ++++++++++++++++++++++++++++++++++++++++-- > trace-events | 4 + > 3 files changed, 167 insertions(+), 6 deletions(-) > > diff --git a/include/migration/migration.h b/include/migration/migration.h > index e6585c5..68a1731 100644 > --- a/include/migration/migration.h > +++ b/include/migration/migration.h > @@ -120,6 +120,9 @@ struct MigrationState > /* Flag set once the migration has been asked to enter postcopy */ > bool start_postcopy; > > + /* Flag set once the migration thread is running (and needs joining) */ > + bool started_migration_thread; > + migration_thread_started? > + > + /* > + * send rest of state - note things that are doing postcopy > + * will notice we're in POSTCOPY_ACTIVE and not actually > + * wrap their state up here > + */ > + qemu_file_set_rate_limit(ms->file, INT64_MAX); Do we undo this? or, are we sure that it is ok to maximize network output? > + /* Ping just for debugging, helps line traces up */ > + qemu_savevm_send_ping(ms->file, 2); Change the values 1, 2, 3 to constants? > + * 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? > + 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. > +/* > * 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?