From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZukBd-0004hf-C3 for qemu-devel@nongnu.org; Fri, 06 Nov 2015 11:48:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZukBa-0001LE-5R for qemu-devel@nongnu.org; Fri, 06 Nov 2015 11:48:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59277) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZukBZ-0001Kx-UA for qemu-devel@nongnu.org; Fri, 06 Nov 2015 11:48:22 -0500 Date: Fri, 6 Nov 2015 16:48:16 +0000 From: "Dr. David Alan Gilbert" Message-ID: <20151106164815.GF4267@work-vm> References: <1446551816-15768-1-git-send-email-zhang.zhanghailiang@huawei.com> <1446551816-15768-6-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1446551816-15768-6-git-send-email-zhang.zhanghailiang@huawei.com> Subject: Re: [Qemu-devel] [PATCH COLO-Frame v10 05/38] migration: Integrate COLO checkpoint process into migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: zhanghailiang Cc: lizhijian@cn.fujitsu.com, quintela@redhat.com, yunhong.jiang@intel.com, eddie.dong@intel.com, peter.huangpeng@huawei.com, qemu-devel@nongnu.org, arei.gonglei@huawei.com, stefanha@redhat.com, amit.shah@redhat.com * zhanghailiang (zhang.zhanghailiang@huawei.com) wrote: > Add a migrate state: MIGRATION_STATUS_COLO, enter this migration state > after the first live migration successfully finished. > > We reuse migration thread, so if colo is enabled by user, migration thread will > go into the process of colo. > > Signed-off-by: zhanghailiang > Signed-off-by: Li Zhijian > Signed-off-by: Gonglei Reviewed-by: Dr. David Alan Gilbert > --- > v10: Simplify process by dropping colo thread and reusing migration thread. > (Dave's suggestion) > --- > include/migration/colo.h | 3 +++ > migration/colo.c | 31 +++++++++++++++++++++++++++++++ > migration/migration.c | 19 +++++++++++++++---- > qapi-schema.json | 2 +- > stubs/migration-colo.c | 9 +++++++++ > trace-events | 3 +++ > 6 files changed, 62 insertions(+), 5 deletions(-) > > diff --git a/include/migration/colo.h b/include/migration/colo.h > index 9b6662d..f462f06 100644 > --- a/include/migration/colo.h > +++ b/include/migration/colo.h > @@ -19,4 +19,7 @@ > bool colo_supported(void); > void colo_info_mig_init(void); > > +void migrate_start_colo_process(MigrationState *s); > +bool migration_in_colo_state(void); > + > #endif > diff --git a/migration/colo.c b/migration/colo.c > index 2c40d2e..cf0ccb8 100644 > --- a/migration/colo.c > +++ b/migration/colo.c > @@ -10,9 +10,40 @@ > * later. See the COPYING file in the top-level directory. > */ > > +#include "sysemu/sysemu.h" > #include "migration/colo.h" > +#include "trace.h" > > bool colo_supported(void) > { > return true; > } > + > +bool migration_in_colo_state(void) > +{ > + MigrationState *s = migrate_get_current(); > + > + return (s->state == MIGRATION_STATUS_COLO); > +} > + > +static void colo_process_checkpoint(MigrationState *s) > +{ > + qemu_mutex_lock_iothread(); > + vm_start(); > + qemu_mutex_unlock_iothread(); > + trace_colo_vm_state_change("stop", "run"); > + > + /*TODO: COLO checkpoint savevm loop*/ > + > + migrate_set_state(&s->state, MIGRATION_STATUS_COLO, > + MIGRATION_STATUS_COMPLETED); > +} > + > +void migrate_start_colo_process(MigrationState *s) > +{ > + qemu_mutex_unlock_iothread(); > + migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, > + MIGRATION_STATUS_COLO); > + colo_process_checkpoint(s); > + qemu_mutex_lock_iothread(); > +} > diff --git a/migration/migration.c b/migration/migration.c > index b179464..cf83531 100644 > --- a/migration/migration.c > +++ b/migration/migration.c > @@ -475,6 +475,10 @@ MigrationInfo *qmp_query_migrate(Error **errp) > > get_xbzrle_cache_stats(info); > break; > + case MIGRATION_STATUS_COLO: > + info->has_status = true; > + /* TODO: display COLO specific information (checkpoint info etc.) */ > + break; > case MIGRATION_STATUS_COMPLETED: > get_xbzrle_cache_stats(info); > > @@ -793,7 +797,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, > > if (s->state == MIGRATION_STATUS_ACTIVE || > s->state == MIGRATION_STATUS_SETUP || > - s->state == MIGRATION_STATUS_CANCELLING) { > + s->state == MIGRATION_STATUS_CANCELLING || > + s->state == MIGRATION_STATUS_COLO) { > error_setg(errp, QERR_MIGRATION_ACTIVE); > return; > } > @@ -1030,8 +1035,11 @@ static void migration_completion(MigrationState *s, bool *old_vm_running, > goto fail; > } > > - migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, > - MIGRATION_STATUS_COMPLETED); > + if (!migrate_colo_enabled()) { > + migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, > + MIGRATION_STATUS_COMPLETED); > + } > + > return; > > fail: > @@ -1056,6 +1064,7 @@ static void *migration_thread(void *opaque) > int64_t max_size = 0; > int64_t start_time = initial_time; > bool old_vm_running = false; > + bool enable_colo = migrate_colo_enabled(); > > rcu_register_thread(); > > @@ -1130,7 +1139,9 @@ static void *migration_thread(void *opaque) > } > runstate_set(RUN_STATE_POSTMIGRATE); > } else { > - if (old_vm_running) { > + if (s->state == MIGRATION_STATUS_ACTIVE && enable_colo) { > + migrate_start_colo_process(s); > + } else if (old_vm_running) { > vm_start(); > } > } > diff --git a/qapi-schema.json b/qapi-schema.json > index cb5e5fd..22251ec 100644 > --- a/qapi-schema.json > +++ b/qapi-schema.json > @@ -439,7 +439,7 @@ > ## > { 'enum': 'MigrationStatus', > 'data': [ 'none', 'setup', 'cancelling', 'cancelled', > - 'active', 'completed', 'failed' ] } > + 'active', 'completed', 'failed', 'colo' ] } > > ## > # @MigrationInfo > diff --git a/stubs/migration-colo.c b/stubs/migration-colo.c > index 3d817df..acddca6 100644 > --- a/stubs/migration-colo.c > +++ b/stubs/migration-colo.c > @@ -16,3 +16,12 @@ bool colo_supported(void) > { > return false; > } > + > +bool migration_in_colo_state(void) > +{ > + return false; > +} > + > +void migrate_start_colo_process(MigrationState *s) > +{ > +} > diff --git a/trace-events b/trace-events > index 72136b9..9cd6391 100644 > --- a/trace-events > +++ b/trace-events > @@ -1497,6 +1497,9 @@ rdma_start_incoming_migration_after_rdma_listen(void) "" > rdma_start_outgoing_migration_after_rdma_connect(void) "" > rdma_start_outgoing_migration_after_rdma_source_init(void) "" > > +# migration/colo.c > +colo_vm_state_change(const char *old, const char *new) "Change '%s' => '%s'" > + > # kvm-all.c > kvm_ioctl(int type, void *arg) "type 0x%x, arg %p" > kvm_vm_ioctl(int type, void *arg) "type 0x%x, arg %p" > -- > 1.8.3.1 > > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK