mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
migration: Add .save_prepare() handler to struct SaveVMHandlers
Add a new .save_prepare() handler to struct SaveVMHandlers. This handler is called early, even before migration starts, and can be used by devices to perform early checks. Refactor migrate_init() to be able to return errors and call .save_prepare() from there. Suggested-by: Peter Xu <peterx@redhat.com> Signed-off-by: Avihai Horon <avihaih@nvidia.com> Reviewed-by: Peter Xu <peterx@redhat.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
parent
f543aa222d
commit
08fc4cb517
5 changed files with 48 additions and 4 deletions
|
@ -1233,6 +1233,30 @@ bool qemu_savevm_state_guest_unplug_pending(void)
|
|||
return false;
|
||||
}
|
||||
|
||||
int qemu_savevm_state_prepare(Error **errp)
|
||||
{
|
||||
SaveStateEntry *se;
|
||||
int ret;
|
||||
|
||||
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
|
||||
if (!se->ops || !se->ops->save_prepare) {
|
||||
continue;
|
||||
}
|
||||
if (se->ops->is_active) {
|
||||
if (!se->ops->is_active(se->opaque)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
ret = se->ops->save_prepare(se->opaque, errp);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void qemu_savevm_state_setup(QEMUFile *f)
|
||||
{
|
||||
MigrationState *ms = migrate_get_current();
|
||||
|
@ -1619,7 +1643,10 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
migrate_init(ms);
|
||||
ret = migrate_init(ms, errp);
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
ms->to_dst_file = f;
|
||||
|
||||
qemu_mutex_unlock_iothread();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue