diff mbox series

[v2,1/3] migration: Make migration blocker work for snapshots too

Message ID 20210826185813.248441-2-peterx@redhat.com
State New
Headers show
Series dump-guest-memory: Add blocker for migration | expand

Commit Message

Peter Xu Aug. 26, 2021, 6:58 p.m. UTC
save_snapshot() checks migration blocker, which looks sane.  At the meantime we
should also teach the blocker add helper to fail if during a snapshot, just
like for migrations.

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

Comments

Marc-André Lureau Sept. 22, 2021, 3:05 p.m. UTC | #1
On Thu, Aug 26, 2021 at 11:00 PM Peter Xu <peterx@redhat.com> wrote:

> save_snapshot() checks migration blocker, which looks sane.  At the
> meantime we
> should also teach the blocker add helper to fail if during a snapshot, just
> like for migrations.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

---
>  migration/migration.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/migration/migration.c b/migration/migration.c
> index 041b8451a6..f476e2101e 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -2062,15 +2062,16 @@ int migrate_add_blocker(Error *reason, Error
> **errp)
>          return -EACCES;
>      }
>
> -    if (migration_is_idle()) {
> -        migration_blockers = g_slist_prepend(migration_blockers, reason);
> -        return 0;
> +    /* Snapshots are similar to migrations, so check RUN_STATE_SAVE_VM
> too. */
> +    if (runstate_check(RUN_STATE_SAVE_VM) || !migration_is_idle()) {
> +        error_propagate_prepend(errp, error_copy(reason),
> +                                "disallowing migration blocker "
> +                                "(migration/snapshot in progress) for: ");
> +        return -EBUSY;
>      }
>
> -    error_propagate_prepend(errp, error_copy(reason),
> -                            "disallowing migration blocker "
> -                            "(migration in progress) for: ");
> -    return -EBUSY;
> +    migration_blockers = g_slist_prepend(migration_blockers, reason);
> +    return 0;
>  }
>
>  void migrate_del_blocker(Error *reason)
> --
> 2.31.1
>
>
>
diff mbox series

Patch

diff --git a/migration/migration.c b/migration/migration.c
index 041b8451a6..f476e2101e 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2062,15 +2062,16 @@  int migrate_add_blocker(Error *reason, Error **errp)
         return -EACCES;
     }
 
-    if (migration_is_idle()) {
-        migration_blockers = g_slist_prepend(migration_blockers, reason);
-        return 0;
+    /* Snapshots are similar to migrations, so check RUN_STATE_SAVE_VM too. */
+    if (runstate_check(RUN_STATE_SAVE_VM) || !migration_is_idle()) {
+        error_propagate_prepend(errp, error_copy(reason),
+                                "disallowing migration blocker "
+                                "(migration/snapshot in progress) for: ");
+        return -EBUSY;
     }
 
-    error_propagate_prepend(errp, error_copy(reason),
-                            "disallowing migration blocker "
-                            "(migration in progress) for: ");
-    return -EBUSY;
+    migration_blockers = g_slist_prepend(migration_blockers, reason);
+    return 0;
 }
 
 void migrate_del_blocker(Error *reason)