Skip to contentSkip to conversation

Avoid migration if guest is in postmigrated status

PATCH In review Li Zhang 3 participants 3 messages Dec 9, 2020

lore
Share & tools
lore

Li Zhang

author
#0 lore raw

PATCH 1/1 Avoid migration if guest is in postmigrated status

This patch is to avoid executing migrations twice, which causes coredump. After the migration has been completed, guest is in postmigrated status on source host and the block device is inactive. If executing migration again, it will cause coredump and a block error. For exmaple, executing #migrate "exec:cat>file" twice on source host, block error:
bdrv_inactivate_recurse: Assertion `!(bs->open_flags & BDRV_O_INACTIVE)' failed

---
 migration/migration.c | 5 +++++
 1 file changed, 5 insertions(+)
migration/migration.c +5 -0
index 87a9b59f83..113f7e1e41 100644
@@ -2115,6 +2115,11 @@ static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc,
         return false;
     }
 
+    if (runstate_check(RUN_STATE_POSTMIGRATE)) {
+        error_setg(errp, "Unable to migrate, guest has been migrated");
+        return false;
+    }
+
     if (migration_is_blocked(errp)) {
         return false;
     }
Signature · 1 line
2.18.4
#1 lore raw
Quoted 8 lines · Li Zhang

This patch is to avoid executing migrations twice, which causes coredump. After the migration has been completed, guest is in postmigrated status on source host and the block device is inactive. If executing migration again, it will cause coredump and a block error. For exmaple, executing #migrate "exec:cat>file" twice on source host, block error:
bdrv_inactivate_recurse: Assertion `!(bs->open_flags & BDRV_O_INACTIVE)' failed

There is an existing proposal for this (the same approach) in
https://lore.kernel.org/r/[email protected].

Quoted 22 lines
---
 migration/migration.c | 5 +++++
 1 file changed, 5 insertions(+)
migration/migration.c +5 -0
index 87a9b59f83..113f7e1e41 100644
@@ -2115,6 +2115,11 @@ static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc,
         return false;
     }
 
+    if (runstate_check(RUN_STATE_POSTMIGRATE)) {
+        error_setg(errp, "Unable to migrate, guest has been migrated");
+        return false;
+    }
+
     if (migration_is_blocked(errp)) {
         return false;
     }
Signature · 1 line
2.18.4

dme.

Signature · 1 line
Ah, oh your hair is beautiful.
#2 lore raw

Thanks for telling me that. I didn't notice this patch.
I just caught this error when I used it and read the source code, it should be fixed.

Thanks
Li

Quoted 44 lines · David Edmondson
Quoted 2 lines · Li Zhang

This patch is to avoid executing migrations twice, which causes coredump. After the migration has been completed, guest is in

postmigrated

Quoted 4 lines

status on source host and the block device is inactive. If executing migration again, it will cause coredump and a block error. For exmaple, executing #migrate "exec:cat>file" twice on source host, block error:
bdrv_inactivate_recurse: Assertion `!(bs->open_flags & BDRV_O_INACTIVE)'

failed

Quoted 2 lines

There is an existing proposal for this (the same approach) in
https://lore.kernel.org/r/[email protected].

migration/migration.c static bool migrate_prepare(MigrationState *s,

Quoted 9 lines
---
 migration/migration.c | 5 +++++
 1 file changed, 5 insertions(+)
migration/migration.c +0 -0
index 87a9b59f83..113f7e1e41 100644
@@ -2115,6 +2115,11 @@ static bool migrate_prepare(MigrationState *s,

bool blk, bool blk_inc,

Quoted 12 lines
migration/migration.c +5 -1
         return false;
     }
 
+    if (runstate_check(RUN_STATE_POSTMIGRATE)) {
+        error_setg(errp, "Unable to migrate, guest has been migrated");
+        return false;
+    }
+
     if (migration_is_blocked(errp)) {
         return false;
     }
--
Quoted 1 line

2.18.4

dme.
--
Ah, oh your hair is beautiful.