[PATCH v2 4/4] migration/cpr: Avoid crashing QEMU when cpr-exec runs with no args

Peter Xu posted 4 patches 3 weeks, 2 days ago
Maintainers: Steve Sistare <steven.sistare@oracle.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>
[PATCH v2 4/4] migration/cpr: Avoid crashing QEMU when cpr-exec runs with no args
Posted by Peter Xu 3 weeks, 2 days ago
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.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 migration/migration.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/migration/migration.c b/migration/migration.c
index c8a5712993..4ed2a2e881 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -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)) {
-- 
2.50.1
Re: [PATCH v2 4/4] migration/cpr: Avoid crashing QEMU when cpr-exec runs with no args
Posted by Fabiano Rosas 3 weeks, 2 days ago
Peter Xu <peterx@redhat.com> writes:

> 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.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  migration/migration.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/migration/migration.c b/migration/migration.c
> index c8a5712993..4ed2a2e881 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -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)) {

Reviewed-by: Fabiano Rosas <farosas@suse.de>