[Qemu-devel] [PATCH 1/2] qmp: forbid qmp_cont in RUN_STATE_FINISH_MIGRATE

Vladimir Sementsov-Ogievskiy posted 2 patches 6 years, 9 months ago
Maintainers: Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>, Markus Armbruster <armbru@redhat.com>
[Qemu-devel] [PATCH 1/2] qmp: forbid qmp_cont in RUN_STATE_FINISH_MIGRATE
Posted by Vladimir Sementsov-Ogievskiy 6 years, 9 months ago
qmp_cont in RUN_STATE_FINISH_MIGRATE may lead to moving vm to
RUN_STATE_RUNNING, before actual migration finish. So, when migration
thread will try to go to RUN_STATE_POSTMIGRATE, assuming transition
RUN_STATE_FINISH_MIGRATE->RUN_STATE_POSTMIGRATE, it will crash, as
current state is RUN_STATE_RUNNING, and transition
RUN_STATE_RUNNING->RUN_STATE_POSTMIGRATE is forbidden.

Reported-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 qmp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/qmp.c b/qmp.c
index 4c819dd8cf..c2ecf1d804 100644
--- a/qmp.c
+++ b/qmp.c
@@ -156,6 +156,9 @@ void qmp_cont(Error **errp)
         return;
     } else if (runstate_check(RUN_STATE_SUSPENDED)) {
         return;
+    } else if (runstate_check(RUN_STATE_FINISH_MIGRATE)) {
+        error_setg(errp, "Migration is not finalized yet");
+        return;
     }
 
     for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
-- 
2.18.0


Re: [Qemu-devel] [PATCH 1/2] qmp: forbid qmp_cont in RUN_STATE_FINISH_MIGRATE
Posted by Dr. David Alan Gilbert 6 years, 9 months ago
* Vladimir Sementsov-Ogievskiy (vsementsov@virtuozzo.com) wrote:
> qmp_cont in RUN_STATE_FINISH_MIGRATE may lead to moving vm to
> RUN_STATE_RUNNING, before actual migration finish. So, when migration
> thread will try to go to RUN_STATE_POSTMIGRATE, assuming transition
> RUN_STATE_FINISH_MIGRATE->RUN_STATE_POSTMIGRATE, it will crash, as
> current state is RUN_STATE_RUNNING, and transition
> RUN_STATE_RUNNING->RUN_STATE_POSTMIGRATE is forbidden.
> 
> Reported-by: Max Reitz <mreitz@redhat.com>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  qmp.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/qmp.c b/qmp.c
> index 4c819dd8cf..c2ecf1d804 100644
> --- a/qmp.c
> +++ b/qmp.c
> @@ -156,6 +156,9 @@ void qmp_cont(Error **errp)
>          return;
>      } else if (runstate_check(RUN_STATE_SUSPENDED)) {
>          return;
> +    } else if (runstate_check(RUN_STATE_FINISH_MIGRATE)) {
> +        error_setg(errp, "Migration is not finalized yet");
> +        return;
>      }

Yeh, a bit of a hack, but I think that's as best as we can do for now;
we can't ban all cont's during migration.

Note, it's still racy since you could call this partway through the
completion before it's set to finish.


Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>


>      for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
> -- 
> 2.18.0
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK