Because of the patch
3ea3b7fa9af067982f34b of kvm, now the migration_end()
is a time consuming operation, which takes about dozens of milliseconds, and
will prolong VM downtime. Such an operation should be done after migration
completion.
For a VM with 8G RAM, this patch can reduce the VM downtime about 32 ms during
live migration.
Change-Id: Iddd10bd5a2b1bf52cce36253f303fc458da343cd
Signed-off-by: Liang Li <liang.z.li@intel.com>
qemu_put_be64(f, BLK_MIG_FLAG_EOS);
qemu_put_be64(f, BLK_MIG_FLAG_EOS);
assert(s->state != MIGRATION_STATUS_ACTIVE);
assert(s->state != MIGRATION_STATUS_ACTIVE);
- if (s->state != MIGRATION_STATUS_COMPLETED) {
- qemu_savevm_state_cancel();
- if (s->state == MIGRATION_STATUS_CANCELLING) {
- migrate_set_state(s, MIGRATION_STATUS_CANCELLING,
- MIGRATION_STATUS_CANCELLED);
- }
+ if (s->state == MIGRATION_STATUS_CANCELLING) {
+ migrate_set_state(s, MIGRATION_STATUS_CANCELLING,
+ MIGRATION_STATUS_CANCELLED);
}
notifier_list_notify(&migration_state_notifiers, s);
}
notifier_list_notify(&migration_state_notifiers, s);
int64_t initial_bytes = 0;
int64_t max_size = 0;
int64_t start_time = initial_time;
int64_t initial_bytes = 0;
int64_t max_size = 0;
int64_t start_time = initial_time;
bool old_vm_running = false;
rcu_register_thread();
bool old_vm_running = false;
rcu_register_thread();
+ end_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
+
qemu_mutex_lock_iothread();
qemu_mutex_lock_iothread();
+ qemu_savevm_state_cancel();
if (s->state == MIGRATION_STATUS_COMPLETED) {
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);
s->total_time = end_time - s->total_time;
s->downtime = end_time - start_time;
uint64_t transferred_bytes = qemu_ftell(s->file);
s->total_time = end_time - s->total_time;
s->downtime = end_time - start_time;
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
return 0;
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
return 0;