From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXKoG-0007ea-Ap for qemu-devel@nongnu.org; Wed, 10 Aug 2016 00:08:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXKoD-000764-1A for qemu-devel@nongnu.org; Wed, 10 Aug 2016 00:08:04 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:5192) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXKoC-00074h-7k for qemu-devel@nongnu.org; Wed, 10 Aug 2016 00:08:00 -0400 References: <1470227172-13704-1-git-send-email-zhang.zhanghailiang@huawei.com> <1470227172-13704-18-git-send-email-zhang.zhanghailiang@huawei.com> <20160809091712.GA2025@work-vm> From: Hailiang Zhang Message-ID: <57AAA887.70307@huawei.com> Date: Wed, 10 Aug 2016 12:07:35 +0800 MIME-Version: 1.0 In-Reply-To: <20160809091712.GA2025@work-vm> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH COLO-Frame v18 17/34] COLO failover: Introduce state to record failover process List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert" Cc: peter.huangpeng@huawei.com, qemu-devel@nongnu.org, amit.shah@redhat.com, quintela@redhat.com, eddie.dong@intel.com, wency@cn.fujitsu.com, lizhijian@cn.fujitsu.com, zhangchen.fnst@cn.fujitsu.com, xiecl.fnst@cn.fujitsu.com On 2016/8/9 17:17, Dr. David Alan Gilbert wrote: > * zhanghailiang (zhang.zhanghailiang@huawei.com) wrote: > >> + error_report("Unkown error for failover, old_state=%d", old_state); > > Tiny typo; 'Unknown'. > Don't bother reposting just for that, we can fix it later; or fix it if > you have to repost anyway. > OK, thanks. > Dave > >> + return; >> + } >> /*TODO: Do failover work */ >> } >> >> void failover_request_active(Error **errp) >> { >> + if (failover_set_state(FAILOVER_STATUS_NONE, FAILOVER_STATUS_REQUEST) >> + != FAILOVER_STATUS_NONE) { >> + error_setg(errp, "COLO failover is already actived"); >> + return; >> + } >> failover_bh = qemu_bh_new(colo_failover_bh, NULL); >> qemu_bh_schedule(failover_bh); >> } >> >> +void failover_init_state(void) >> +{ >> + failover_state = FAILOVER_STATUS_NONE; >> +} >> + >> +int failover_set_state(int old_state, int new_state) >> +{ >> + int old; >> + >> + old = atomic_cmpxchg(&failover_state, old_state, new_state); >> + if (old == old_state) { >> + trace_colo_failover_set_state(new_state); >> + } >> + return old; >> +} >> + >> +int failover_get_state(void) >> +{ >> + return atomic_read(&failover_state); >> +} >> + >> void qmp_x_colo_lost_heartbeat(Error **errp) >> { >> if (get_colo_mode() == COLO_MODE_UNKNOWN) { >> diff --git a/migration/colo.c b/migration/colo.c >> index b445279..9afc527 100644 >> --- a/migration/colo.c >> +++ b/migration/colo.c >> @@ -232,6 +232,8 @@ static void colo_process_checkpoint(MigrationState *s) >> Error *local_err = NULL; >> int ret; >> >> + failover_init_state(); >> + >> s->rp_state.from_dst_file = qemu_file_get_return_path(s->to_dst_file); >> if (!s->rp_state.from_dst_file) { >> error_report("Open QEMUFile from_dst_file failed"); >> @@ -331,6 +333,8 @@ void *colo_process_incoming_thread(void *opaque) >> migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, >> MIGRATION_STATUS_COLO); >> >> + failover_init_state(); >> + >> mis->to_src_file = qemu_file_get_return_path(mis->from_src_file); >> if (!mis->to_src_file) { >> error_report("colo incoming thread: Open QEMUFile to_src_file failed"); >> diff --git a/migration/trace-events b/migration/trace-events >> index 82dc7a0..d9f44ba 100644 >> --- a/migration/trace-events >> +++ b/migration/trace-events >> @@ -214,3 +214,4 @@ migration_tls_incoming_handshake_complete(void) "" >> colo_vm_state_change(const char *old, const char *new) "Change '%s' => '%s'" >> colo_send_message(const char *msg) "Send '%s' message" >> colo_receive_message(const char *msg) "Receive '%s' message" >> +colo_failover_set_state(int new_state) "new state %d" >> -- >> 1.8.3.1 >> >> > -- > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK > > . >