migration/cpr: Avoid crashing QEMU when cpr-exec runs with no args

If an user invokes cpr-exec without setting the exec args first, currently
it'll crash QEMU.

Avoid it, instead fail the QMP migrate command.

Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20251021220407.2662288-5-peterx@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
This commit is contained in:
Peter Xu 2025-10-21 18:04:07 -04:00
parent 89471ef237
commit ded3cf4aaf

View file

@ -2195,6 +2195,12 @@ static bool migrate_prepare(MigrationState *s, bool resume, Error **errp)
error_setg(errp, "Cannot use %s with CPR", conflict);
return false;
}
if (s->parameters.mode == MIG_MODE_CPR_EXEC &&
!s->parameters.cpr_exec_command) {
error_setg(errp, "Parameter 'cpr-exec-command' required for cpr-exec");
return false;
}
}
if (migrate_init(s, errp)) {