Skip to contentSkip to conversation

migration: assert that the same migration handler is not being added twice

PATCH New Ani Sinha 1 participant 1 message Mar 11

lore
Share & tools
lore

Ani Sinha

author
#0 lore raw

PATCH v2 1/1 migration: assert that the same migration handler is not being added twice

Currently the code that adds a migration blocker does not check if the same blocker already exists. Assert that the migration handler being added has not been added already.

CC Markus Armbruster <[email protected]>
CC Peter Xu <[email protected]>
CC Prasad Pandit <[email protected]>
---
 migration/migration.c | 2 ++
 1 file changed, 2 insertions(+)

changelog:
v2: fix indentation

migration/migration.c +2 -0
index f949708629..4459d85ea5 100644
@@ -1694,6 +1694,8 @@ static int add_blockers(Error **reasonp, unsigned modes, Error **errp)
 {
     for (MigMode mode = 0; mode < MIG_MODE__MAX; mode++) {
         if (modes & BIT(mode)) {
+            assert(g_slist_index(migration_blockers[mode],
+                                 *reasonp) == -1);
             migration_blockers[mode] = g_slist_prepend(migration_blockers[mode],
                                                        *reasonp);
         }
Signature · 1 line
2.52.0