mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
savevm: split the process of different stages for loadvm/savevm
There are several stages during loadvm/savevm process. In different stage, migration incoming processes different types of sections. We want to control these stages more accuracy, it will benefit COLO performance, we don't have to save type of QEMU_VM_SECTION_START sections everytime while do checkpoint, besides, we want to separate the process of saving/loading memory and devices state. So we add three new helper functions: qemu_load_device_state() and qemu_savevm_live_state() to achieve different process during migration. Besides, we make qemu_loadvm_state_main() and qemu_save_device_state() public, and simplify the codes of qemu_save_device_state() by calling the wrapper qemu_savevm_state_header(). Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com> Signed-off-by: Zhang Chen <zhangckid@gmail.com> Signed-off-by: Zhang Chen <chen.zhang@intel.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
parent
f56c0065b8
commit
3f6df99d9d
3 changed files with 65 additions and 16 deletions
|
@ -1378,13 +1378,21 @@ done:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int qemu_save_device_state(QEMUFile *f)
|
||||
void qemu_savevm_live_state(QEMUFile *f)
|
||||
{
|
||||
/* save QEMU_VM_SECTION_END section */
|
||||
qemu_savevm_state_complete_precopy(f, true, false);
|
||||
qemu_put_byte(f, QEMU_VM_EOF);
|
||||
}
|
||||
|
||||
int qemu_save_device_state(QEMUFile *f)
|
||||
{
|
||||
SaveStateEntry *se;
|
||||
|
||||
qemu_put_be32(f, QEMU_VM_FILE_MAGIC);
|
||||
qemu_put_be32(f, QEMU_VM_FILE_VERSION);
|
||||
|
||||
if (!migration_in_colo_state()) {
|
||||
qemu_put_be32(f, QEMU_VM_FILE_MAGIC);
|
||||
qemu_put_be32(f, QEMU_VM_FILE_VERSION);
|
||||
}
|
||||
cpu_synchronize_all_states();
|
||||
|
||||
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
|
||||
|
@ -1440,8 +1448,6 @@ enum LoadVMExitCodes {
|
|||
LOADVM_QUIT = 1,
|
||||
};
|
||||
|
||||
static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis);
|
||||
|
||||
/* ------ incoming postcopy messages ------ */
|
||||
/* 'advise' arrives before any transfers just to tell us that a postcopy
|
||||
* *might* happen - it might be skipped if precopy transferred everything
|
||||
|
@ -2247,7 +2253,7 @@ static bool postcopy_pause_incoming(MigrationIncomingState *mis)
|
|||
return true;
|
||||
}
|
||||
|
||||
static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis)
|
||||
int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis)
|
||||
{
|
||||
uint8_t section_type;
|
||||
int ret = 0;
|
||||
|
@ -2418,6 +2424,22 @@ int qemu_loadvm_state(QEMUFile *f)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int qemu_load_device_state(QEMUFile *f)
|
||||
{
|
||||
MigrationIncomingState *mis = migration_incoming_get_current();
|
||||
int ret;
|
||||
|
||||
/* Load QEMU_VM_SECTION_FULL section */
|
||||
ret = qemu_loadvm_state_main(f, mis);
|
||||
if (ret < 0) {
|
||||
error_report("Failed to load device state: %d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
cpu_synchronize_all_post_init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int save_snapshot(const char *name, Error **errp)
|
||||
{
|
||||
BlockDriverState *bs, *bs1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue