From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43994) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3LF-0005mA-6y for qemu-devel@nongnu.org; Wed, 02 Sep 2015 04:24:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX3L9-000146-Ds for qemu-devel@nongnu.org; Wed, 02 Sep 2015 04:24:24 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:28055) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3L8-00012i-7y for qemu-devel@nongnu.org; Wed, 02 Sep 2015 04:24:19 -0400 From: zhanghailiang Date: Wed, 2 Sep 2015 16:22:54 +0800 Message-ID: <1441182199-8328-8-git-send-email-zhang.zhanghailiang@huawei.com> In-Reply-To: <1441182199-8328-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1441182199-8328-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH COLO-Frame v9 07/32] migration: Rename the'file' member of MigrationState and MigrationIncomingState List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: lizhijian@cn.fujitsu.com, quintela@redhat.com, yunhong.jiang@intel.com, eddie.dong@intel.com, peter.huangpeng@huawei.com, dgilbert@redhat.com, arei.gonglei@huawei.com, stefanha@redhat.com, amit.shah@redhat.com, yanghy@cn.fujitsu.com, zhanghailiang Rename the 'file' member of MigrationState to 'to_dst_file' and Rename the 'file' member of MigrationIncomingState to 'from_src_file'. For now, there are only one path direction for migration, it is from source side to destination side, but for colo and post-copy, we need both directions communication, so here we rename the file member to indicate this path. Signed-off-by: zhanghailiang Cc: Dr. David Alan Gilbert --- include/migration/migration.h | 4 ++-- migration/exec.c | 4 ++-- migration/fd.c | 4 ++-- migration/migration.c | 48 ++++++++++++++++++++++--------------------- migration/tcp.c | 4 ++-- migration/unix.c | 4 ++-- 6 files changed, 35 insertions(+), 33 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 9cdd6b6..6488e03 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -49,7 +49,7 @@ typedef QLIST_HEAD(, LoadStateEntry) LoadStateEntry_Head; /* State for the incoming migration */ struct MigrationIncomingState { - QEMUFile *file; + QEMUFile *from_src_file; int state; @@ -73,7 +73,7 @@ struct MigrationState size_t xfer_limit; QemuThread thread; QEMUBH *cleanup_bh; - QEMUFile *file; + QEMUFile *to_dst_file; int parameters[MIGRATION_PARAMETER_MAX]; int state; diff --git a/migration/exec.c b/migration/exec.c index 8406d2b..9037109 100644 --- a/migration/exec.c +++ b/migration/exec.c @@ -36,8 +36,8 @@ void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp) { - s->file = qemu_popen_cmd(command, "w"); - if (s->file == NULL) { + s->to_dst_file = qemu_popen_cmd(command, "w"); + if (s->to_dst_file == NULL) { error_setg_errno(errp, errno, "failed to popen the migration target"); return; } diff --git a/migration/fd.c b/migration/fd.c index 3e4bed0..9a9d6c5 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -50,9 +50,9 @@ void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error ** } if (fd_is_socket(fd)) { - s->file = qemu_fopen_socket(fd, "wb"); + s->to_dst_file = qemu_fopen_socket(fd, "wb"); } else { - s->file = qemu_fdopen(fd, "wb"); + s->to_dst_file = qemu_fdopen(fd, "wb"); } migrate_fd_connect(s); diff --git a/migration/migration.c b/migration/migration.c index 241689f..f7ca2c4 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -88,7 +88,7 @@ MigrationIncomingState *migration_incoming_get_current(void) MigrationIncomingState *migration_incoming_state_new(QEMUFile* f) { mis_current = g_malloc0(sizeof(MigrationIncomingState)); - mis_current->file = f; + mis_current->from_src_file = f; mis_current->state = MIGRATION_STATUS_NONE; QLIST_INIT(&mis_current->loadvm_handlers); @@ -579,15 +579,15 @@ static void migrate_fd_cleanup(void *opaque) qemu_bh_delete(s->cleanup_bh); s->cleanup_bh = NULL; - if (s->file) { + if (s->to_dst_file) { trace_migrate_fd_cleanup(); qemu_mutex_unlock_iothread(); qemu_thread_join(&s->thread); qemu_mutex_lock_iothread(); migrate_compress_threads_join(); - qemu_fclose(s->file); - s->file = NULL; + qemu_fclose(s->to_dst_file); + s->to_dst_file = NULL; } assert(s->state != MIGRATION_STATUS_ACTIVE); @@ -606,7 +606,7 @@ static void migrate_fd_cleanup(void *opaque) void migrate_fd_error(MigrationState *s) { trace_migrate_fd_error(); - assert(s->file == NULL); + assert(s->to_dst_file == NULL); migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_FAILED); notifier_list_notify(&migration_state_notifiers, s); @@ -615,7 +615,7 @@ void migrate_fd_error(MigrationState *s) static void migrate_fd_cancel(MigrationState *s) { int old_state ; - QEMUFile *f = migrate_get_current()->file; + QEMUFile *f = migrate_get_current()->to_dst_file; trace_migrate_fd_cancel(); do { @@ -856,8 +856,9 @@ void qmp_migrate_set_speed(int64_t value, Error **errp) s = migrate_get_current(); s->bandwidth_limit = value; - if (s->file) { - qemu_file_set_rate_limit(s->file, s->bandwidth_limit / XFER_LIMIT_RATIO); + if (s->to_dst_file) { + qemu_file_set_rate_limit(s->to_dst_file, + s->bandwidth_limit / XFER_LIMIT_RATIO); } } @@ -970,8 +971,8 @@ static void *migration_thread(void *opaque) rcu_register_thread(); - qemu_savevm_state_header(s->file); - qemu_savevm_state_begin(s->file, &s->params); + qemu_savevm_state_header(s->to_dst_file); + qemu_savevm_state_begin(s->to_dst_file, &s->params); s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start; migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, @@ -981,11 +982,11 @@ static void *migration_thread(void *opaque) int64_t current_time; uint64_t pending_size; - if (!qemu_file_rate_limit(s->file)) { - pending_size = qemu_savevm_state_pending(s->file, max_size); + if (!qemu_file_rate_limit(s->to_dst_file)) { + pending_size = qemu_savevm_state_pending(s->to_dst_file, max_size); trace_migrate_pending(pending_size, max_size); if (pending_size && pending_size >= max_size) { - qemu_savevm_state_iterate(s->file); + qemu_savevm_state_iterate(s->to_dst_file); } else { int ret; @@ -998,8 +999,8 @@ static void *migration_thread(void *opaque) if (!ret) { ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); if (ret >= 0) { - qemu_file_set_rate_limit(s->file, INT64_MAX); - qemu_savevm_state_complete(s->file); + qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX); + qemu_savevm_state_complete(s->to_dst_file); } } qemu_mutex_unlock_iothread(); @@ -1010,7 +1011,7 @@ static void *migration_thread(void *opaque) break; } - if (!qemu_file_get_error(s->file)) { + if (!qemu_file_get_error(s->to_dst_file)) { if (!enable_colo) { migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_COMPLETED); @@ -1020,14 +1021,15 @@ static void *migration_thread(void *opaque) } } - if (qemu_file_get_error(s->file)) { + if (qemu_file_get_error(s->to_dst_file)) { migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_FAILED); break; } current_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); if (current_time >= initial_time + BUFFER_DELAY) { - uint64_t transferred_bytes = qemu_ftell(s->file) - initial_bytes; + uint64_t transferred_bytes = qemu_ftell(s->to_dst_file) - + initial_bytes; uint64_t time_spent = current_time - initial_time; double bandwidth = transferred_bytes / time_spent; max_size = bandwidth * migrate_max_downtime() / 1000000; @@ -1043,11 +1045,11 @@ static void *migration_thread(void *opaque) s->expected_downtime = s->dirty_bytes_rate / bandwidth; } - qemu_file_reset_rate_limit(s->file); + qemu_file_reset_rate_limit(s->to_dst_file); initial_time = current_time; - initial_bytes = qemu_ftell(s->file); + initial_bytes = qemu_ftell(s->to_dst_file); } - if (qemu_file_rate_limit(s->file)) { + if (qemu_file_rate_limit(s->to_dst_file)) { /* usleep expects microseconds */ g_usleep((initial_time + BUFFER_DELAY - current_time)*1000); } @@ -1056,7 +1058,7 @@ static void *migration_thread(void *opaque) qemu_mutex_lock_iothread(); if (s->state == MIGRATION_STATUS_COMPLETED) { int64_t end_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); - uint64_t transferred_bytes = qemu_ftell(s->file); + uint64_t transferred_bytes = qemu_ftell(s->to_dst_file); s->total_time = end_time - s->total_time; s->downtime = end_time - start_time; if (s->total_time) { @@ -1087,7 +1089,7 @@ void migrate_fd_connect(MigrationState *s) s->expected_downtime = max_downtime/1000000; s->cleanup_bh = qemu_bh_new(migrate_fd_cleanup, s); - qemu_file_set_rate_limit(s->file, + qemu_file_set_rate_limit(s->to_dst_file, s->bandwidth_limit / XFER_LIMIT_RATIO); /* Notify before starting migration thread */ diff --git a/migration/tcp.c b/migration/tcp.c index ae89172..e083d68 100644 --- a/migration/tcp.c +++ b/migration/tcp.c @@ -39,11 +39,11 @@ static void tcp_wait_for_connect(int fd, Error *err, void *opaque) if (fd < 0) { DPRINTF("migrate connect error: %s\n", error_get_pretty(err)); - s->file = NULL; + s->to_dst_file = NULL; migrate_fd_error(s); } else { DPRINTF("migrate connect success\n"); - s->file = qemu_fopen_socket(fd, "wb"); + s->to_dst_file = qemu_fopen_socket(fd, "wb"); migrate_fd_connect(s); } } diff --git a/migration/unix.c b/migration/unix.c index b591813..5492dd6 100644 --- a/migration/unix.c +++ b/migration/unix.c @@ -39,11 +39,11 @@ static void unix_wait_for_connect(int fd, Error *err, void *opaque) if (fd < 0) { DPRINTF("migrate connect error: %s\n", error_get_pretty(err)); - s->file = NULL; + s->to_dst_file = NULL; migrate_fd_error(s); } else { DPRINTF("migrate connect success\n"); - s->file = qemu_fopen_socket(fd, "wb"); + s->to_dst_file = qemu_fopen_socket(fd, "wb"); migrate_fd_connect(s); } } -- 1.8.3.1