]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
migration/cpr: Avoid crashing QEMU when cpr-exec runs with no args
authorPeter Xu <peterx@redhat.com>
Tue, 21 Oct 2025 22:04:07 +0000 (18:04 -0400)
committerPeter Xu <peterx@redhat.com>
Mon, 3 Nov 2025 21:04:10 +0000 (16:04 -0500)
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>
migration/migration.c

index c8a5712993690202ff8465dbc338564ceccdc3df..4ed2a2e8816127b1e8af37ee03db9140a0349928 100644 (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)) {