mirror of
https://github.com/mii443/qemu.git
synced 2025-09-02 07:09:47 +00:00
migration/postcopy: Ensure postcopy_start() sets errp if it fails
There are several places where postcopy_start() fails without setting errp. This can cause a null pointer de-reference, as in case of error, the caller of postcopy_start() copies/prints the error set in errp. Fix it by setting errp in all of postcopy_start() error paths. Cc: qemu-stable <qemu-stable@nongnu.org> Fixes:908927db28
("migration: Update error description whenever migration fails") Signed-off-by: Avihai Horon <avihaih@nvidia.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> Link: https://lore.kernel.org/r/20240328140252.16756-3-avihaih@nvidia.com Signed-off-by: Peter Xu <peterx@redhat.com> (cherry picked from commitd0ad271a76
) Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
committed by
Michael Tokarev
parent
35fface50f
commit
3168476965
@ -2408,6 +2408,8 @@ static int postcopy_start(MigrationState *ms, Error **errp)
|
|||||||
migration_wait_main_channel(ms);
|
migration_wait_main_channel(ms);
|
||||||
if (postcopy_preempt_establish_channel(ms)) {
|
if (postcopy_preempt_establish_channel(ms)) {
|
||||||
migrate_set_state(&ms->state, ms->state, MIGRATION_STATUS_FAILED);
|
migrate_set_state(&ms->state, ms->state, MIGRATION_STATUS_FAILED);
|
||||||
|
error_setg(errp, "%s: Failed to establish preempt channel",
|
||||||
|
__func__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2427,17 +2429,22 @@ static int postcopy_start(MigrationState *ms, Error **errp)
|
|||||||
global_state_store();
|
global_state_store();
|
||||||
ret = migration_stop_vm(RUN_STATE_FINISH_MIGRATE);
|
ret = migration_stop_vm(RUN_STATE_FINISH_MIGRATE);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_setg_errno(errp, -ret, "%s: Failed to stop the VM", __func__);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = migration_maybe_pause(ms, &cur_state,
|
ret = migration_maybe_pause(ms, &cur_state,
|
||||||
MIGRATION_STATUS_POSTCOPY_ACTIVE);
|
MIGRATION_STATUS_POSTCOPY_ACTIVE);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_setg_errno(errp, -ret, "%s: Failed in migration_maybe_pause()",
|
||||||
|
__func__);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = bdrv_inactivate_all();
|
ret = bdrv_inactivate_all();
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_setg_errno(errp, -ret, "%s: Failed in bdrv_inactivate_all()",
|
||||||
|
__func__);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
restart_block = true;
|
restart_block = true;
|
||||||
@ -2514,6 +2521,7 @@ static int postcopy_start(MigrationState *ms, Error **errp)
|
|||||||
|
|
||||||
/* Now send that blob */
|
/* Now send that blob */
|
||||||
if (qemu_savevm_send_packaged(ms->to_dst_file, bioc->data, bioc->usage)) {
|
if (qemu_savevm_send_packaged(ms->to_dst_file, bioc->data, bioc->usage)) {
|
||||||
|
error_setg(errp, "%s: Failed to send packaged data", __func__);
|
||||||
goto fail_closefb;
|
goto fail_closefb;
|
||||||
}
|
}
|
||||||
qemu_fclose(fb);
|
qemu_fclose(fb);
|
||||||
|
Reference in New Issue
Block a user