Message ID | 1448357149-17572-9-git-send-email-zhang.zhanghailiang@huawei.com |
---|---|
State | New |
Headers | show |
* zhanghailiang (zhang.zhanghailiang@huawei.com) wrote: > Rename the 'file' member of MigrationState to 'to_dst_file'. > > Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> > Cc: Dr. David Alan Gilbert <dgilbert@redhat.com> > --- > v11: > - Only rename 'file' member of MigrationState Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> You should be able to post this one separately. Dave > --- > include/migration/migration.h | 2 +- > migration/exec.c | 4 +-- > migration/fd.c | 4 +-- > migration/migration.c | 72 ++++++++++++++++++++++--------------------- > migration/postcopy-ram.c | 6 ++-- > migration/savevm.c | 2 +- > migration/tcp.c | 4 +-- > migration/unix.c | 4 +-- > 8 files changed, 51 insertions(+), 47 deletions(-) > > diff --git a/include/migration/migration.h b/include/migration/migration.h > index a57a734..ba5bcec 100644 > --- a/include/migration/migration.h > +++ b/include/migration/migration.h > @@ -140,7 +140,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 41eac0d..a4c690d 100644 > --- a/migration/migration.c > +++ b/migration/migration.c > @@ -834,7 +834,7 @@ static void migrate_fd_cleanup(void *opaque) > > flush_page_queue(s); > > - if (s->file) { > + if (s->to_dst_file) { > trace_migrate_fd_cleanup(); > qemu_mutex_unlock_iothread(); > if (s->migration_thread_running) { > @@ -844,8 +844,8 @@ static void migrate_fd_cleanup(void *opaque) > 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) && > @@ -862,7 +862,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); > @@ -871,7 +871,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(); > > if (s->rp_state.from_dst_file) { > @@ -942,7 +942,7 @@ MigrationState *migrate_init(const MigrationParams *params) > s->bytes_xfer = 0; > s->xfer_limit = 0; > s->cleanup_bh = 0; > - s->file = NULL; > + s->to_dst_file = NULL; > s->state = MIGRATION_STATUS_NONE; > s->params = *params; > s->rp_state.from_dst_file = NULL; > @@ -1122,8 +1122,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); > } > } > > @@ -1393,7 +1394,7 @@ out: > static int open_return_path_on_source(MigrationState *ms) > { > > - ms->rp_state.from_dst_file = qemu_file_get_return_path(ms->file); > + ms->rp_state.from_dst_file = qemu_file_get_return_path(ms->to_dst_file); > if (!ms->rp_state.from_dst_file) { > return -1; > } > @@ -1415,7 +1416,7 @@ static int await_return_path_close_on_source(MigrationState *ms) > * rp_thread will exit, however if there's an error we need to cause > * it to exit. > */ > - if (qemu_file_get_error(ms->file) && ms->rp_state.from_dst_file) { > + if (qemu_file_get_error(ms->to_dst_file) && ms->rp_state.from_dst_file) { > /* > * shutdown(2), if we have it, will cause it to unblock if it's stuck > * waiting for the destination. > @@ -1458,7 +1459,7 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) > * Cause any non-postcopiable, but iterative devices to > * send out their final data. > */ > - qemu_savevm_state_complete_precopy(ms->file, true); > + qemu_savevm_state_complete_precopy(ms->to_dst_file, true); > > /* > * in Finish migrate and with the io-lock held everything should > @@ -1476,9 +1477,9 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) > * will notice we're in POSTCOPY_ACTIVE and not actually > * wrap their state up here > */ > - qemu_file_set_rate_limit(ms->file, INT64_MAX); > + qemu_file_set_rate_limit(ms->to_dst_file, INT64_MAX); > /* Ping just for debugging, helps line traces up */ > - qemu_savevm_send_ping(ms->file, 2); > + qemu_savevm_send_ping(ms->to_dst_file, 2); > > /* > * While loading the device state we may trigger page transfer > @@ -1512,7 +1513,7 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) > qsb = qemu_buf_get(fb); > > /* Now send that blob */ > - if (qemu_savevm_send_packaged(ms->file, qsb)) { > + if (qemu_savevm_send_packaged(ms->to_dst_file, qsb)) { > goto fail_closefb; > } > qemu_fclose(fb); > @@ -1524,9 +1525,9 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) > * Although this ping is just for debug, it could potentially be > * used for getting a better measurement of downtime at the source. > */ > - qemu_savevm_send_ping(ms->file, 4); > + qemu_savevm_send_ping(ms->to_dst_file, 4); > > - ret = qemu_file_get_error(ms->file); > + ret = qemu_file_get_error(ms->to_dst_file); > if (ret) { > error_report("postcopy_start: Migration stream errored"); > migrate_set_state(&ms->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, > @@ -1569,8 +1570,8 @@ static void migration_completion(MigrationState *s, int current_active_state, > 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_precopy(s->file, false); > + qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX); > + qemu_savevm_state_complete_precopy(s->to_dst_file, false); > } > } > qemu_mutex_unlock_iothread(); > @@ -1581,7 +1582,7 @@ static void migration_completion(MigrationState *s, int current_active_state, > } else if (s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE) { > trace_migration_completion_postcopy_end(); > > - qemu_savevm_state_complete_postcopy(s->file); > + qemu_savevm_state_complete_postcopy(s->to_dst_file); > trace_migration_completion_postcopy_end_after_complete(); > } > > @@ -1602,7 +1603,7 @@ static void migration_completion(MigrationState *s, int current_active_state, > } > } > > - if (qemu_file_get_error(s->file)) { > + if (qemu_file_get_error(s->to_dst_file)) { > trace_migration_completion_file_err(); > goto fail; > } > @@ -1647,24 +1648,24 @@ static void *migration_thread(void *opaque) > > rcu_register_thread(); > > - qemu_savevm_state_header(s->file); > + qemu_savevm_state_header(s->to_dst_file); > > if (migrate_postcopy_ram()) { > /* Now tell the dest that it should open its end so it can reply */ > - qemu_savevm_send_open_return_path(s->file); > + qemu_savevm_send_open_return_path(s->to_dst_file); > > /* And do a ping that will make stuff easier to debug */ > - qemu_savevm_send_ping(s->file, 1); > + qemu_savevm_send_ping(s->to_dst_file, 1); > > /* > * Tell the destination that we *might* want to do postcopy later; > * if the other end can't do postcopy it should fail now, nice and > * early. > */ > - qemu_savevm_send_postcopy_advise(s->file); > + qemu_savevm_send_postcopy_advise(s->to_dst_file); > } > > - qemu_savevm_state_begin(s->file, &s->params); > + qemu_savevm_state_begin(s->to_dst_file, &s->params); > > s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start; > current_active_state = MIGRATION_STATUS_ACTIVE; > @@ -1678,10 +1679,10 @@ static void *migration_thread(void *opaque) > int64_t current_time; > uint64_t pending_size; > > - if (!qemu_file_rate_limit(s->file)) { > + if (!qemu_file_rate_limit(s->to_dst_file)) { > uint64_t pend_post, pend_nonpost; > > - qemu_savevm_state_pending(s->file, max_size, &pend_nonpost, > + qemu_savevm_state_pending(s->to_dst_file, max_size, &pend_nonpost, > &pend_post); > pending_size = pend_nonpost + pend_post; > trace_migrate_pending(pending_size, max_size, > @@ -1702,7 +1703,7 @@ static void *migration_thread(void *opaque) > continue; > } > /* Just another iteration step */ > - qemu_savevm_state_iterate(s->file, entered_postcopy); > + qemu_savevm_state_iterate(s->to_dst_file, entered_postcopy); > } else { > trace_migration_thread_low_pending(pending_size); > migration_completion(s, current_active_state, > @@ -1711,7 +1712,7 @@ 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, current_active_state, > MIGRATION_STATUS_FAILED); > trace_migration_thread_file_err(); > @@ -1719,7 +1720,8 @@ static void *migration_thread(void *opaque) > } > 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; > @@ -1735,11 +1737,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); > } > @@ -1757,7 +1759,7 @@ static void *migration_thread(void *opaque) > qemu_savevm_state_cleanup(); > } > if (s->state == MIGRATION_STATUS_COMPLETED) { > - 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; > if (!entered_postcopy) { > s->downtime = end_time - start_time; > @@ -1794,7 +1796,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/postcopy-ram.c b/migration/postcopy-ram.c > index 22d6b18..f74016d 100644 > --- a/migration/postcopy-ram.c > +++ b/migration/postcopy-ram.c > @@ -733,7 +733,8 @@ void postcopy_discard_send_range(MigrationState *ms, PostcopyDiscardState *pds, > > if (pds->cur_entry == MAX_DISCARDS_PER_COMMAND) { > /* Full set, ship it! */ > - qemu_savevm_send_postcopy_ram_discard(ms->file, pds->ramblock_name, > + qemu_savevm_send_postcopy_ram_discard(ms->to_dst_file, > + pds->ramblock_name, > pds->cur_entry, > pds->start_list, > pds->length_list); > @@ -753,7 +754,8 @@ void postcopy_discard_send_finish(MigrationState *ms, PostcopyDiscardState *pds) > { > /* Anything unsent? */ > if (pds->cur_entry) { > - qemu_savevm_send_postcopy_ram_discard(ms->file, pds->ramblock_name, > + qemu_savevm_send_postcopy_ram_discard(ms->to_dst_file, > + pds->ramblock_name, > pds->cur_entry, > pds->start_list, > pds->length_list); > diff --git a/migration/savevm.c b/migration/savevm.c > index 0ad1b93..f102870 100644 > --- a/migration/savevm.c > +++ b/migration/savevm.c > @@ -1163,7 +1163,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp) > .shared = 0 > }; > MigrationState *ms = migrate_init(¶ms); > - ms->file = f; > + ms->to_dst_file = f; > > if (qemu_savevm_state_blocked(errp)) { > return -EINVAL; > 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 > > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
On 2015/11/25 2:26, Dr. David Alan Gilbert wrote: > * zhanghailiang (zhang.zhanghailiang@huawei.com) wrote: >> Rename the 'file' member of MigrationState to 'to_dst_file'. >> >> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> >> Cc: Dr. David Alan Gilbert <dgilbert@redhat.com> >> --- >> v11: >> - Only rename 'file' member of MigrationState > > Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> > > You should be able to post this one separately. > OK, i will post this patch together with other independent migration patches as a prerequisite series. Thanks. > Dave > >> --- >> include/migration/migration.h | 2 +- >> migration/exec.c | 4 +-- >> migration/fd.c | 4 +-- >> migration/migration.c | 72 ++++++++++++++++++++++--------------------- >> migration/postcopy-ram.c | 6 ++-- >> migration/savevm.c | 2 +- >> migration/tcp.c | 4 +-- >> migration/unix.c | 4 +-- >> 8 files changed, 51 insertions(+), 47 deletions(-) >> >> diff --git a/include/migration/migration.h b/include/migration/migration.h >> index a57a734..ba5bcec 100644 >> --- a/include/migration/migration.h >> +++ b/include/migration/migration.h >> @@ -140,7 +140,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 41eac0d..a4c690d 100644 >> --- a/migration/migration.c >> +++ b/migration/migration.c >> @@ -834,7 +834,7 @@ static void migrate_fd_cleanup(void *opaque) >> >> flush_page_queue(s); >> >> - if (s->file) { >> + if (s->to_dst_file) { >> trace_migrate_fd_cleanup(); >> qemu_mutex_unlock_iothread(); >> if (s->migration_thread_running) { >> @@ -844,8 +844,8 @@ static void migrate_fd_cleanup(void *opaque) >> 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) && >> @@ -862,7 +862,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); >> @@ -871,7 +871,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(); >> >> if (s->rp_state.from_dst_file) { >> @@ -942,7 +942,7 @@ MigrationState *migrate_init(const MigrationParams *params) >> s->bytes_xfer = 0; >> s->xfer_limit = 0; >> s->cleanup_bh = 0; >> - s->file = NULL; >> + s->to_dst_file = NULL; >> s->state = MIGRATION_STATUS_NONE; >> s->params = *params; >> s->rp_state.from_dst_file = NULL; >> @@ -1122,8 +1122,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); >> } >> } >> >> @@ -1393,7 +1394,7 @@ out: >> static int open_return_path_on_source(MigrationState *ms) >> { >> >> - ms->rp_state.from_dst_file = qemu_file_get_return_path(ms->file); >> + ms->rp_state.from_dst_file = qemu_file_get_return_path(ms->to_dst_file); >> if (!ms->rp_state.from_dst_file) { >> return -1; >> } >> @@ -1415,7 +1416,7 @@ static int await_return_path_close_on_source(MigrationState *ms) >> * rp_thread will exit, however if there's an error we need to cause >> * it to exit. >> */ >> - if (qemu_file_get_error(ms->file) && ms->rp_state.from_dst_file) { >> + if (qemu_file_get_error(ms->to_dst_file) && ms->rp_state.from_dst_file) { >> /* >> * shutdown(2), if we have it, will cause it to unblock if it's stuck >> * waiting for the destination. >> @@ -1458,7 +1459,7 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) >> * Cause any non-postcopiable, but iterative devices to >> * send out their final data. >> */ >> - qemu_savevm_state_complete_precopy(ms->file, true); >> + qemu_savevm_state_complete_precopy(ms->to_dst_file, true); >> >> /* >> * in Finish migrate and with the io-lock held everything should >> @@ -1476,9 +1477,9 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) >> * will notice we're in POSTCOPY_ACTIVE and not actually >> * wrap their state up here >> */ >> - qemu_file_set_rate_limit(ms->file, INT64_MAX); >> + qemu_file_set_rate_limit(ms->to_dst_file, INT64_MAX); >> /* Ping just for debugging, helps line traces up */ >> - qemu_savevm_send_ping(ms->file, 2); >> + qemu_savevm_send_ping(ms->to_dst_file, 2); >> >> /* >> * While loading the device state we may trigger page transfer >> @@ -1512,7 +1513,7 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) >> qsb = qemu_buf_get(fb); >> >> /* Now send that blob */ >> - if (qemu_savevm_send_packaged(ms->file, qsb)) { >> + if (qemu_savevm_send_packaged(ms->to_dst_file, qsb)) { >> goto fail_closefb; >> } >> qemu_fclose(fb); >> @@ -1524,9 +1525,9 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) >> * Although this ping is just for debug, it could potentially be >> * used for getting a better measurement of downtime at the source. >> */ >> - qemu_savevm_send_ping(ms->file, 4); >> + qemu_savevm_send_ping(ms->to_dst_file, 4); >> >> - ret = qemu_file_get_error(ms->file); >> + ret = qemu_file_get_error(ms->to_dst_file); >> if (ret) { >> error_report("postcopy_start: Migration stream errored"); >> migrate_set_state(&ms->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, >> @@ -1569,8 +1570,8 @@ static void migration_completion(MigrationState *s, int current_active_state, >> 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_precopy(s->file, false); >> + qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX); >> + qemu_savevm_state_complete_precopy(s->to_dst_file, false); >> } >> } >> qemu_mutex_unlock_iothread(); >> @@ -1581,7 +1582,7 @@ static void migration_completion(MigrationState *s, int current_active_state, >> } else if (s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE) { >> trace_migration_completion_postcopy_end(); >> >> - qemu_savevm_state_complete_postcopy(s->file); >> + qemu_savevm_state_complete_postcopy(s->to_dst_file); >> trace_migration_completion_postcopy_end_after_complete(); >> } >> >> @@ -1602,7 +1603,7 @@ static void migration_completion(MigrationState *s, int current_active_state, >> } >> } >> >> - if (qemu_file_get_error(s->file)) { >> + if (qemu_file_get_error(s->to_dst_file)) { >> trace_migration_completion_file_err(); >> goto fail; >> } >> @@ -1647,24 +1648,24 @@ static void *migration_thread(void *opaque) >> >> rcu_register_thread(); >> >> - qemu_savevm_state_header(s->file); >> + qemu_savevm_state_header(s->to_dst_file); >> >> if (migrate_postcopy_ram()) { >> /* Now tell the dest that it should open its end so it can reply */ >> - qemu_savevm_send_open_return_path(s->file); >> + qemu_savevm_send_open_return_path(s->to_dst_file); >> >> /* And do a ping that will make stuff easier to debug */ >> - qemu_savevm_send_ping(s->file, 1); >> + qemu_savevm_send_ping(s->to_dst_file, 1); >> >> /* >> * Tell the destination that we *might* want to do postcopy later; >> * if the other end can't do postcopy it should fail now, nice and >> * early. >> */ >> - qemu_savevm_send_postcopy_advise(s->file); >> + qemu_savevm_send_postcopy_advise(s->to_dst_file); >> } >> >> - qemu_savevm_state_begin(s->file, &s->params); >> + qemu_savevm_state_begin(s->to_dst_file, &s->params); >> >> s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start; >> current_active_state = MIGRATION_STATUS_ACTIVE; >> @@ -1678,10 +1679,10 @@ static void *migration_thread(void *opaque) >> int64_t current_time; >> uint64_t pending_size; >> >> - if (!qemu_file_rate_limit(s->file)) { >> + if (!qemu_file_rate_limit(s->to_dst_file)) { >> uint64_t pend_post, pend_nonpost; >> >> - qemu_savevm_state_pending(s->file, max_size, &pend_nonpost, >> + qemu_savevm_state_pending(s->to_dst_file, max_size, &pend_nonpost, >> &pend_post); >> pending_size = pend_nonpost + pend_post; >> trace_migrate_pending(pending_size, max_size, >> @@ -1702,7 +1703,7 @@ static void *migration_thread(void *opaque) >> continue; >> } >> /* Just another iteration step */ >> - qemu_savevm_state_iterate(s->file, entered_postcopy); >> + qemu_savevm_state_iterate(s->to_dst_file, entered_postcopy); >> } else { >> trace_migration_thread_low_pending(pending_size); >> migration_completion(s, current_active_state, >> @@ -1711,7 +1712,7 @@ 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, current_active_state, >> MIGRATION_STATUS_FAILED); >> trace_migration_thread_file_err(); >> @@ -1719,7 +1720,8 @@ static void *migration_thread(void *opaque) >> } >> 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; >> @@ -1735,11 +1737,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); >> } >> @@ -1757,7 +1759,7 @@ static void *migration_thread(void *opaque) >> qemu_savevm_state_cleanup(); >> } >> if (s->state == MIGRATION_STATUS_COMPLETED) { >> - 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; >> if (!entered_postcopy) { >> s->downtime = end_time - start_time; >> @@ -1794,7 +1796,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/postcopy-ram.c b/migration/postcopy-ram.c >> index 22d6b18..f74016d 100644 >> --- a/migration/postcopy-ram.c >> +++ b/migration/postcopy-ram.c >> @@ -733,7 +733,8 @@ void postcopy_discard_send_range(MigrationState *ms, PostcopyDiscardState *pds, >> >> if (pds->cur_entry == MAX_DISCARDS_PER_COMMAND) { >> /* Full set, ship it! */ >> - qemu_savevm_send_postcopy_ram_discard(ms->file, pds->ramblock_name, >> + qemu_savevm_send_postcopy_ram_discard(ms->to_dst_file, >> + pds->ramblock_name, >> pds->cur_entry, >> pds->start_list, >> pds->length_list); >> @@ -753,7 +754,8 @@ void postcopy_discard_send_finish(MigrationState *ms, PostcopyDiscardState *pds) >> { >> /* Anything unsent? */ >> if (pds->cur_entry) { >> - qemu_savevm_send_postcopy_ram_discard(ms->file, pds->ramblock_name, >> + qemu_savevm_send_postcopy_ram_discard(ms->to_dst_file, >> + pds->ramblock_name, >> pds->cur_entry, >> pds->start_list, >> pds->length_list); >> diff --git a/migration/savevm.c b/migration/savevm.c >> index 0ad1b93..f102870 100644 >> --- a/migration/savevm.c >> +++ b/migration/savevm.c >> @@ -1163,7 +1163,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp) >> .shared = 0 >> }; >> MigrationState *ms = migrate_init(¶ms); >> - ms->file = f; >> + ms->to_dst_file = f; >> >> if (qemu_savevm_state_blocked(errp)) { >> return -EINVAL; >> 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 >> >> > -- > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK > > . >
On 11/24/2015 05:25 PM, zhanghailiang wrote: > Rename the 'file' member of MigrationState to 'to_dst_file'. > > Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> > Cc: Dr. David Alan Gilbert <dgilbert@redhat.com> > --- > v11: > - Only rename 'file' member of MigrationState You forgot to update migration/rdma.c. Thanks Wen Congyang > --- > include/migration/migration.h | 2 +- > migration/exec.c | 4 +-- > migration/fd.c | 4 +-- > migration/migration.c | 72 ++++++++++++++++++++++--------------------- > migration/postcopy-ram.c | 6 ++-- > migration/savevm.c | 2 +- > migration/tcp.c | 4 +-- > migration/unix.c | 4 +-- > 8 files changed, 51 insertions(+), 47 deletions(-) > > diff --git a/include/migration/migration.h b/include/migration/migration.h > index a57a734..ba5bcec 100644 > --- a/include/migration/migration.h > +++ b/include/migration/migration.h > @@ -140,7 +140,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 41eac0d..a4c690d 100644 > --- a/migration/migration.c > +++ b/migration/migration.c > @@ -834,7 +834,7 @@ static void migrate_fd_cleanup(void *opaque) > > flush_page_queue(s); > > - if (s->file) { > + if (s->to_dst_file) { > trace_migrate_fd_cleanup(); > qemu_mutex_unlock_iothread(); > if (s->migration_thread_running) { > @@ -844,8 +844,8 @@ static void migrate_fd_cleanup(void *opaque) > 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) && > @@ -862,7 +862,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); > @@ -871,7 +871,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(); > > if (s->rp_state.from_dst_file) { > @@ -942,7 +942,7 @@ MigrationState *migrate_init(const MigrationParams *params) > s->bytes_xfer = 0; > s->xfer_limit = 0; > s->cleanup_bh = 0; > - s->file = NULL; > + s->to_dst_file = NULL; > s->state = MIGRATION_STATUS_NONE; > s->params = *params; > s->rp_state.from_dst_file = NULL; > @@ -1122,8 +1122,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); > } > } > > @@ -1393,7 +1394,7 @@ out: > static int open_return_path_on_source(MigrationState *ms) > { > > - ms->rp_state.from_dst_file = qemu_file_get_return_path(ms->file); > + ms->rp_state.from_dst_file = qemu_file_get_return_path(ms->to_dst_file); > if (!ms->rp_state.from_dst_file) { > return -1; > } > @@ -1415,7 +1416,7 @@ static int await_return_path_close_on_source(MigrationState *ms) > * rp_thread will exit, however if there's an error we need to cause > * it to exit. > */ > - if (qemu_file_get_error(ms->file) && ms->rp_state.from_dst_file) { > + if (qemu_file_get_error(ms->to_dst_file) && ms->rp_state.from_dst_file) { > /* > * shutdown(2), if we have it, will cause it to unblock if it's stuck > * waiting for the destination. > @@ -1458,7 +1459,7 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) > * Cause any non-postcopiable, but iterative devices to > * send out their final data. > */ > - qemu_savevm_state_complete_precopy(ms->file, true); > + qemu_savevm_state_complete_precopy(ms->to_dst_file, true); > > /* > * in Finish migrate and with the io-lock held everything should > @@ -1476,9 +1477,9 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) > * will notice we're in POSTCOPY_ACTIVE and not actually > * wrap their state up here > */ > - qemu_file_set_rate_limit(ms->file, INT64_MAX); > + qemu_file_set_rate_limit(ms->to_dst_file, INT64_MAX); > /* Ping just for debugging, helps line traces up */ > - qemu_savevm_send_ping(ms->file, 2); > + qemu_savevm_send_ping(ms->to_dst_file, 2); > > /* > * While loading the device state we may trigger page transfer > @@ -1512,7 +1513,7 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) > qsb = qemu_buf_get(fb); > > /* Now send that blob */ > - if (qemu_savevm_send_packaged(ms->file, qsb)) { > + if (qemu_savevm_send_packaged(ms->to_dst_file, qsb)) { > goto fail_closefb; > } > qemu_fclose(fb); > @@ -1524,9 +1525,9 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) > * Although this ping is just for debug, it could potentially be > * used for getting a better measurement of downtime at the source. > */ > - qemu_savevm_send_ping(ms->file, 4); > + qemu_savevm_send_ping(ms->to_dst_file, 4); > > - ret = qemu_file_get_error(ms->file); > + ret = qemu_file_get_error(ms->to_dst_file); > if (ret) { > error_report("postcopy_start: Migration stream errored"); > migrate_set_state(&ms->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, > @@ -1569,8 +1570,8 @@ static void migration_completion(MigrationState *s, int current_active_state, > 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_precopy(s->file, false); > + qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX); > + qemu_savevm_state_complete_precopy(s->to_dst_file, false); > } > } > qemu_mutex_unlock_iothread(); > @@ -1581,7 +1582,7 @@ static void migration_completion(MigrationState *s, int current_active_state, > } else if (s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE) { > trace_migration_completion_postcopy_end(); > > - qemu_savevm_state_complete_postcopy(s->file); > + qemu_savevm_state_complete_postcopy(s->to_dst_file); > trace_migration_completion_postcopy_end_after_complete(); > } > > @@ -1602,7 +1603,7 @@ static void migration_completion(MigrationState *s, int current_active_state, > } > } > > - if (qemu_file_get_error(s->file)) { > + if (qemu_file_get_error(s->to_dst_file)) { > trace_migration_completion_file_err(); > goto fail; > } > @@ -1647,24 +1648,24 @@ static void *migration_thread(void *opaque) > > rcu_register_thread(); > > - qemu_savevm_state_header(s->file); > + qemu_savevm_state_header(s->to_dst_file); > > if (migrate_postcopy_ram()) { > /* Now tell the dest that it should open its end so it can reply */ > - qemu_savevm_send_open_return_path(s->file); > + qemu_savevm_send_open_return_path(s->to_dst_file); > > /* And do a ping that will make stuff easier to debug */ > - qemu_savevm_send_ping(s->file, 1); > + qemu_savevm_send_ping(s->to_dst_file, 1); > > /* > * Tell the destination that we *might* want to do postcopy later; > * if the other end can't do postcopy it should fail now, nice and > * early. > */ > - qemu_savevm_send_postcopy_advise(s->file); > + qemu_savevm_send_postcopy_advise(s->to_dst_file); > } > > - qemu_savevm_state_begin(s->file, &s->params); > + qemu_savevm_state_begin(s->to_dst_file, &s->params); > > s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start; > current_active_state = MIGRATION_STATUS_ACTIVE; > @@ -1678,10 +1679,10 @@ static void *migration_thread(void *opaque) > int64_t current_time; > uint64_t pending_size; > > - if (!qemu_file_rate_limit(s->file)) { > + if (!qemu_file_rate_limit(s->to_dst_file)) { > uint64_t pend_post, pend_nonpost; > > - qemu_savevm_state_pending(s->file, max_size, &pend_nonpost, > + qemu_savevm_state_pending(s->to_dst_file, max_size, &pend_nonpost, > &pend_post); > pending_size = pend_nonpost + pend_post; > trace_migrate_pending(pending_size, max_size, > @@ -1702,7 +1703,7 @@ static void *migration_thread(void *opaque) > continue; > } > /* Just another iteration step */ > - qemu_savevm_state_iterate(s->file, entered_postcopy); > + qemu_savevm_state_iterate(s->to_dst_file, entered_postcopy); > } else { > trace_migration_thread_low_pending(pending_size); > migration_completion(s, current_active_state, > @@ -1711,7 +1712,7 @@ 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, current_active_state, > MIGRATION_STATUS_FAILED); > trace_migration_thread_file_err(); > @@ -1719,7 +1720,8 @@ static void *migration_thread(void *opaque) > } > 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; > @@ -1735,11 +1737,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); > } > @@ -1757,7 +1759,7 @@ static void *migration_thread(void *opaque) > qemu_savevm_state_cleanup(); > } > if (s->state == MIGRATION_STATUS_COMPLETED) { > - 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; > if (!entered_postcopy) { > s->downtime = end_time - start_time; > @@ -1794,7 +1796,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/postcopy-ram.c b/migration/postcopy-ram.c > index 22d6b18..f74016d 100644 > --- a/migration/postcopy-ram.c > +++ b/migration/postcopy-ram.c > @@ -733,7 +733,8 @@ void postcopy_discard_send_range(MigrationState *ms, PostcopyDiscardState *pds, > > if (pds->cur_entry == MAX_DISCARDS_PER_COMMAND) { > /* Full set, ship it! */ > - qemu_savevm_send_postcopy_ram_discard(ms->file, pds->ramblock_name, > + qemu_savevm_send_postcopy_ram_discard(ms->to_dst_file, > + pds->ramblock_name, > pds->cur_entry, > pds->start_list, > pds->length_list); > @@ -753,7 +754,8 @@ void postcopy_discard_send_finish(MigrationState *ms, PostcopyDiscardState *pds) > { > /* Anything unsent? */ > if (pds->cur_entry) { > - qemu_savevm_send_postcopy_ram_discard(ms->file, pds->ramblock_name, > + qemu_savevm_send_postcopy_ram_discard(ms->to_dst_file, > + pds->ramblock_name, > pds->cur_entry, > pds->start_list, > pds->length_list); > diff --git a/migration/savevm.c b/migration/savevm.c > index 0ad1b93..f102870 100644 > --- a/migration/savevm.c > +++ b/migration/savevm.c > @@ -1163,7 +1163,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp) > .shared = 0 > }; > MigrationState *ms = migrate_init(¶ms); > - ms->file = f; > + ms->to_dst_file = f; > > if (qemu_savevm_state_blocked(errp)) { > return -EINVAL; > 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); > } > } >
On 2015/12/10 14:41, Wen Congyang wrote: > On 11/24/2015 05:25 PM, zhanghailiang wrote: >> Rename the 'file' member of MigrationState to 'to_dst_file'. >> >> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> >> Cc: Dr. David Alan Gilbert <dgilbert@redhat.com> >> --- >> v11: >> - Only rename 'file' member of MigrationState > > You forgot to update migration/rdma.c. > Good catch, i will fix it, thanks. > Thanks > Wen Congyang > >> --- >> include/migration/migration.h | 2 +- >> migration/exec.c | 4 +-- >> migration/fd.c | 4 +-- >> migration/migration.c | 72 ++++++++++++++++++++++--------------------- >> migration/postcopy-ram.c | 6 ++-- >> migration/savevm.c | 2 +- >> migration/tcp.c | 4 +-- >> migration/unix.c | 4 +-- >> 8 files changed, 51 insertions(+), 47 deletions(-) >> >> diff --git a/include/migration/migration.h b/include/migration/migration.h >> index a57a734..ba5bcec 100644 >> --- a/include/migration/migration.h >> +++ b/include/migration/migration.h >> @@ -140,7 +140,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 41eac0d..a4c690d 100644 >> --- a/migration/migration.c >> +++ b/migration/migration.c >> @@ -834,7 +834,7 @@ static void migrate_fd_cleanup(void *opaque) >> >> flush_page_queue(s); >> >> - if (s->file) { >> + if (s->to_dst_file) { >> trace_migrate_fd_cleanup(); >> qemu_mutex_unlock_iothread(); >> if (s->migration_thread_running) { >> @@ -844,8 +844,8 @@ static void migrate_fd_cleanup(void *opaque) >> 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) && >> @@ -862,7 +862,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); >> @@ -871,7 +871,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(); >> >> if (s->rp_state.from_dst_file) { >> @@ -942,7 +942,7 @@ MigrationState *migrate_init(const MigrationParams *params) >> s->bytes_xfer = 0; >> s->xfer_limit = 0; >> s->cleanup_bh = 0; >> - s->file = NULL; >> + s->to_dst_file = NULL; >> s->state = MIGRATION_STATUS_NONE; >> s->params = *params; >> s->rp_state.from_dst_file = NULL; >> @@ -1122,8 +1122,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); >> } >> } >> >> @@ -1393,7 +1394,7 @@ out: >> static int open_return_path_on_source(MigrationState *ms) >> { >> >> - ms->rp_state.from_dst_file = qemu_file_get_return_path(ms->file); >> + ms->rp_state.from_dst_file = qemu_file_get_return_path(ms->to_dst_file); >> if (!ms->rp_state.from_dst_file) { >> return -1; >> } >> @@ -1415,7 +1416,7 @@ static int await_return_path_close_on_source(MigrationState *ms) >> * rp_thread will exit, however if there's an error we need to cause >> * it to exit. >> */ >> - if (qemu_file_get_error(ms->file) && ms->rp_state.from_dst_file) { >> + if (qemu_file_get_error(ms->to_dst_file) && ms->rp_state.from_dst_file) { >> /* >> * shutdown(2), if we have it, will cause it to unblock if it's stuck >> * waiting for the destination. >> @@ -1458,7 +1459,7 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) >> * Cause any non-postcopiable, but iterative devices to >> * send out their final data. >> */ >> - qemu_savevm_state_complete_precopy(ms->file, true); >> + qemu_savevm_state_complete_precopy(ms->to_dst_file, true); >> >> /* >> * in Finish migrate and with the io-lock held everything should >> @@ -1476,9 +1477,9 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) >> * will notice we're in POSTCOPY_ACTIVE and not actually >> * wrap their state up here >> */ >> - qemu_file_set_rate_limit(ms->file, INT64_MAX); >> + qemu_file_set_rate_limit(ms->to_dst_file, INT64_MAX); >> /* Ping just for debugging, helps line traces up */ >> - qemu_savevm_send_ping(ms->file, 2); >> + qemu_savevm_send_ping(ms->to_dst_file, 2); >> >> /* >> * While loading the device state we may trigger page transfer >> @@ -1512,7 +1513,7 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) >> qsb = qemu_buf_get(fb); >> >> /* Now send that blob */ >> - if (qemu_savevm_send_packaged(ms->file, qsb)) { >> + if (qemu_savevm_send_packaged(ms->to_dst_file, qsb)) { >> goto fail_closefb; >> } >> qemu_fclose(fb); >> @@ -1524,9 +1525,9 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) >> * Although this ping is just for debug, it could potentially be >> * used for getting a better measurement of downtime at the source. >> */ >> - qemu_savevm_send_ping(ms->file, 4); >> + qemu_savevm_send_ping(ms->to_dst_file, 4); >> >> - ret = qemu_file_get_error(ms->file); >> + ret = qemu_file_get_error(ms->to_dst_file); >> if (ret) { >> error_report("postcopy_start: Migration stream errored"); >> migrate_set_state(&ms->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, >> @@ -1569,8 +1570,8 @@ static void migration_completion(MigrationState *s, int current_active_state, >> 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_precopy(s->file, false); >> + qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX); >> + qemu_savevm_state_complete_precopy(s->to_dst_file, false); >> } >> } >> qemu_mutex_unlock_iothread(); >> @@ -1581,7 +1582,7 @@ static void migration_completion(MigrationState *s, int current_active_state, >> } else if (s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE) { >> trace_migration_completion_postcopy_end(); >> >> - qemu_savevm_state_complete_postcopy(s->file); >> + qemu_savevm_state_complete_postcopy(s->to_dst_file); >> trace_migration_completion_postcopy_end_after_complete(); >> } >> >> @@ -1602,7 +1603,7 @@ static void migration_completion(MigrationState *s, int current_active_state, >> } >> } >> >> - if (qemu_file_get_error(s->file)) { >> + if (qemu_file_get_error(s->to_dst_file)) { >> trace_migration_completion_file_err(); >> goto fail; >> } >> @@ -1647,24 +1648,24 @@ static void *migration_thread(void *opaque) >> >> rcu_register_thread(); >> >> - qemu_savevm_state_header(s->file); >> + qemu_savevm_state_header(s->to_dst_file); >> >> if (migrate_postcopy_ram()) { >> /* Now tell the dest that it should open its end so it can reply */ >> - qemu_savevm_send_open_return_path(s->file); >> + qemu_savevm_send_open_return_path(s->to_dst_file); >> >> /* And do a ping that will make stuff easier to debug */ >> - qemu_savevm_send_ping(s->file, 1); >> + qemu_savevm_send_ping(s->to_dst_file, 1); >> >> /* >> * Tell the destination that we *might* want to do postcopy later; >> * if the other end can't do postcopy it should fail now, nice and >> * early. >> */ >> - qemu_savevm_send_postcopy_advise(s->file); >> + qemu_savevm_send_postcopy_advise(s->to_dst_file); >> } >> >> - qemu_savevm_state_begin(s->file, &s->params); >> + qemu_savevm_state_begin(s->to_dst_file, &s->params); >> >> s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start; >> current_active_state = MIGRATION_STATUS_ACTIVE; >> @@ -1678,10 +1679,10 @@ static void *migration_thread(void *opaque) >> int64_t current_time; >> uint64_t pending_size; >> >> - if (!qemu_file_rate_limit(s->file)) { >> + if (!qemu_file_rate_limit(s->to_dst_file)) { >> uint64_t pend_post, pend_nonpost; >> >> - qemu_savevm_state_pending(s->file, max_size, &pend_nonpost, >> + qemu_savevm_state_pending(s->to_dst_file, max_size, &pend_nonpost, >> &pend_post); >> pending_size = pend_nonpost + pend_post; >> trace_migrate_pending(pending_size, max_size, >> @@ -1702,7 +1703,7 @@ static void *migration_thread(void *opaque) >> continue; >> } >> /* Just another iteration step */ >> - qemu_savevm_state_iterate(s->file, entered_postcopy); >> + qemu_savevm_state_iterate(s->to_dst_file, entered_postcopy); >> } else { >> trace_migration_thread_low_pending(pending_size); >> migration_completion(s, current_active_state, >> @@ -1711,7 +1712,7 @@ 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, current_active_state, >> MIGRATION_STATUS_FAILED); >> trace_migration_thread_file_err(); >> @@ -1719,7 +1720,8 @@ static void *migration_thread(void *opaque) >> } >> 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; >> @@ -1735,11 +1737,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); >> } >> @@ -1757,7 +1759,7 @@ static void *migration_thread(void *opaque) >> qemu_savevm_state_cleanup(); >> } >> if (s->state == MIGRATION_STATUS_COMPLETED) { >> - 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; >> if (!entered_postcopy) { >> s->downtime = end_time - start_time; >> @@ -1794,7 +1796,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/postcopy-ram.c b/migration/postcopy-ram.c >> index 22d6b18..f74016d 100644 >> --- a/migration/postcopy-ram.c >> +++ b/migration/postcopy-ram.c >> @@ -733,7 +733,8 @@ void postcopy_discard_send_range(MigrationState *ms, PostcopyDiscardState *pds, >> >> if (pds->cur_entry == MAX_DISCARDS_PER_COMMAND) { >> /* Full set, ship it! */ >> - qemu_savevm_send_postcopy_ram_discard(ms->file, pds->ramblock_name, >> + qemu_savevm_send_postcopy_ram_discard(ms->to_dst_file, >> + pds->ramblock_name, >> pds->cur_entry, >> pds->start_list, >> pds->length_list); >> @@ -753,7 +754,8 @@ void postcopy_discard_send_finish(MigrationState *ms, PostcopyDiscardState *pds) >> { >> /* Anything unsent? */ >> if (pds->cur_entry) { >> - qemu_savevm_send_postcopy_ram_discard(ms->file, pds->ramblock_name, >> + qemu_savevm_send_postcopy_ram_discard(ms->to_dst_file, >> + pds->ramblock_name, >> pds->cur_entry, >> pds->start_list, >> pds->length_list); >> diff --git a/migration/savevm.c b/migration/savevm.c >> index 0ad1b93..f102870 100644 >> --- a/migration/savevm.c >> +++ b/migration/savevm.c >> @@ -1163,7 +1163,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp) >> .shared = 0 >> }; >> MigrationState *ms = migrate_init(¶ms); >> - ms->file = f; >> + ms->to_dst_file = f; >> >> if (qemu_savevm_state_blocked(errp)) { >> return -EINVAL; >> 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); >> } >> } >> > > > > > . >
diff --git a/include/migration/migration.h b/include/migration/migration.h index a57a734..ba5bcec 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -140,7 +140,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 41eac0d..a4c690d 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -834,7 +834,7 @@ static void migrate_fd_cleanup(void *opaque) flush_page_queue(s); - if (s->file) { + if (s->to_dst_file) { trace_migrate_fd_cleanup(); qemu_mutex_unlock_iothread(); if (s->migration_thread_running) { @@ -844,8 +844,8 @@ static void migrate_fd_cleanup(void *opaque) 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) && @@ -862,7 +862,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); @@ -871,7 +871,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(); if (s->rp_state.from_dst_file) { @@ -942,7 +942,7 @@ MigrationState *migrate_init(const MigrationParams *params) s->bytes_xfer = 0; s->xfer_limit = 0; s->cleanup_bh = 0; - s->file = NULL; + s->to_dst_file = NULL; s->state = MIGRATION_STATUS_NONE; s->params = *params; s->rp_state.from_dst_file = NULL; @@ -1122,8 +1122,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); } } @@ -1393,7 +1394,7 @@ out: static int open_return_path_on_source(MigrationState *ms) { - ms->rp_state.from_dst_file = qemu_file_get_return_path(ms->file); + ms->rp_state.from_dst_file = qemu_file_get_return_path(ms->to_dst_file); if (!ms->rp_state.from_dst_file) { return -1; } @@ -1415,7 +1416,7 @@ static int await_return_path_close_on_source(MigrationState *ms) * rp_thread will exit, however if there's an error we need to cause * it to exit. */ - if (qemu_file_get_error(ms->file) && ms->rp_state.from_dst_file) { + if (qemu_file_get_error(ms->to_dst_file) && ms->rp_state.from_dst_file) { /* * shutdown(2), if we have it, will cause it to unblock if it's stuck * waiting for the destination. @@ -1458,7 +1459,7 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) * Cause any non-postcopiable, but iterative devices to * send out their final data. */ - qemu_savevm_state_complete_precopy(ms->file, true); + qemu_savevm_state_complete_precopy(ms->to_dst_file, true); /* * in Finish migrate and with the io-lock held everything should @@ -1476,9 +1477,9 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) * will notice we're in POSTCOPY_ACTIVE and not actually * wrap their state up here */ - qemu_file_set_rate_limit(ms->file, INT64_MAX); + qemu_file_set_rate_limit(ms->to_dst_file, INT64_MAX); /* Ping just for debugging, helps line traces up */ - qemu_savevm_send_ping(ms->file, 2); + qemu_savevm_send_ping(ms->to_dst_file, 2); /* * While loading the device state we may trigger page transfer @@ -1512,7 +1513,7 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) qsb = qemu_buf_get(fb); /* Now send that blob */ - if (qemu_savevm_send_packaged(ms->file, qsb)) { + if (qemu_savevm_send_packaged(ms->to_dst_file, qsb)) { goto fail_closefb; } qemu_fclose(fb); @@ -1524,9 +1525,9 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) * Although this ping is just for debug, it could potentially be * used for getting a better measurement of downtime at the source. */ - qemu_savevm_send_ping(ms->file, 4); + qemu_savevm_send_ping(ms->to_dst_file, 4); - ret = qemu_file_get_error(ms->file); + ret = qemu_file_get_error(ms->to_dst_file); if (ret) { error_report("postcopy_start: Migration stream errored"); migrate_set_state(&ms->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, @@ -1569,8 +1570,8 @@ static void migration_completion(MigrationState *s, int current_active_state, 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_precopy(s->file, false); + qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX); + qemu_savevm_state_complete_precopy(s->to_dst_file, false); } } qemu_mutex_unlock_iothread(); @@ -1581,7 +1582,7 @@ static void migration_completion(MigrationState *s, int current_active_state, } else if (s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE) { trace_migration_completion_postcopy_end(); - qemu_savevm_state_complete_postcopy(s->file); + qemu_savevm_state_complete_postcopy(s->to_dst_file); trace_migration_completion_postcopy_end_after_complete(); } @@ -1602,7 +1603,7 @@ static void migration_completion(MigrationState *s, int current_active_state, } } - if (qemu_file_get_error(s->file)) { + if (qemu_file_get_error(s->to_dst_file)) { trace_migration_completion_file_err(); goto fail; } @@ -1647,24 +1648,24 @@ static void *migration_thread(void *opaque) rcu_register_thread(); - qemu_savevm_state_header(s->file); + qemu_savevm_state_header(s->to_dst_file); if (migrate_postcopy_ram()) { /* Now tell the dest that it should open its end so it can reply */ - qemu_savevm_send_open_return_path(s->file); + qemu_savevm_send_open_return_path(s->to_dst_file); /* And do a ping that will make stuff easier to debug */ - qemu_savevm_send_ping(s->file, 1); + qemu_savevm_send_ping(s->to_dst_file, 1); /* * Tell the destination that we *might* want to do postcopy later; * if the other end can't do postcopy it should fail now, nice and * early. */ - qemu_savevm_send_postcopy_advise(s->file); + qemu_savevm_send_postcopy_advise(s->to_dst_file); } - qemu_savevm_state_begin(s->file, &s->params); + qemu_savevm_state_begin(s->to_dst_file, &s->params); s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start; current_active_state = MIGRATION_STATUS_ACTIVE; @@ -1678,10 +1679,10 @@ static void *migration_thread(void *opaque) int64_t current_time; uint64_t pending_size; - if (!qemu_file_rate_limit(s->file)) { + if (!qemu_file_rate_limit(s->to_dst_file)) { uint64_t pend_post, pend_nonpost; - qemu_savevm_state_pending(s->file, max_size, &pend_nonpost, + qemu_savevm_state_pending(s->to_dst_file, max_size, &pend_nonpost, &pend_post); pending_size = pend_nonpost + pend_post; trace_migrate_pending(pending_size, max_size, @@ -1702,7 +1703,7 @@ static void *migration_thread(void *opaque) continue; } /* Just another iteration step */ - qemu_savevm_state_iterate(s->file, entered_postcopy); + qemu_savevm_state_iterate(s->to_dst_file, entered_postcopy); } else { trace_migration_thread_low_pending(pending_size); migration_completion(s, current_active_state, @@ -1711,7 +1712,7 @@ 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, current_active_state, MIGRATION_STATUS_FAILED); trace_migration_thread_file_err(); @@ -1719,7 +1720,8 @@ static void *migration_thread(void *opaque) } 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; @@ -1735,11 +1737,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); } @@ -1757,7 +1759,7 @@ static void *migration_thread(void *opaque) qemu_savevm_state_cleanup(); } if (s->state == MIGRATION_STATUS_COMPLETED) { - 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; if (!entered_postcopy) { s->downtime = end_time - start_time; @@ -1794,7 +1796,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/postcopy-ram.c b/migration/postcopy-ram.c index 22d6b18..f74016d 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -733,7 +733,8 @@ void postcopy_discard_send_range(MigrationState *ms, PostcopyDiscardState *pds, if (pds->cur_entry == MAX_DISCARDS_PER_COMMAND) { /* Full set, ship it! */ - qemu_savevm_send_postcopy_ram_discard(ms->file, pds->ramblock_name, + qemu_savevm_send_postcopy_ram_discard(ms->to_dst_file, + pds->ramblock_name, pds->cur_entry, pds->start_list, pds->length_list); @@ -753,7 +754,8 @@ void postcopy_discard_send_finish(MigrationState *ms, PostcopyDiscardState *pds) { /* Anything unsent? */ if (pds->cur_entry) { - qemu_savevm_send_postcopy_ram_discard(ms->file, pds->ramblock_name, + qemu_savevm_send_postcopy_ram_discard(ms->to_dst_file, + pds->ramblock_name, pds->cur_entry, pds->start_list, pds->length_list); diff --git a/migration/savevm.c b/migration/savevm.c index 0ad1b93..f102870 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1163,7 +1163,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp) .shared = 0 }; MigrationState *ms = migrate_init(¶ms); - ms->file = f; + ms->to_dst_file = f; if (qemu_savevm_state_blocked(errp)) { return -EINVAL; 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); } }
Rename the 'file' member of MigrationState to 'to_dst_file'. Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> Cc: Dr. David Alan Gilbert <dgilbert@redhat.com> --- v11: - Only rename 'file' member of MigrationState --- include/migration/migration.h | 2 +- migration/exec.c | 4 +-- migration/fd.c | 4 +-- migration/migration.c | 72 ++++++++++++++++++++++--------------------- migration/postcopy-ram.c | 6 ++-- migration/savevm.c | 2 +- migration/tcp.c | 4 +-- migration/unix.c | 4 +-- 8 files changed, 51 insertions(+), 47 deletions(-)