Skip to contentSkip to conversation

migration: return EEXIST when trying to add the same migration blocker

PATCH New Ani Sinha 1 participant 1 message Feb 25

lore
Share & tools
lore

Ani Sinha

author
#0 lore raw

PATCH v7 1/1 migration: return EEXIST when trying to add the same migration blocker

Currently the code that adds a migration blocker does not check if the same blocker already exists. Return an EEXIST error code if there is an attempt to add the same migration blocker again. This way the same migration blocker will not get added twice.

---
 migration/migration.c | 6 ++++++
 1 file changed, 6 insertions(+)
migration/migration.c +6 -0
index a5b0465ed3..eb82e964b2 100644
@@ -1702,6 +1702,12 @@ static int add_blockers(Error **reasonp, unsigned modes, Error **errp)
 {
     for (MigMode mode = 0; mode < MIG_MODE__MAX; mode++) {
         if (modes & BIT(mode)) {
+            if (g_slist_index(migration_blockers[mode],
+                                 *reasonp) >= 0) {
+                error_propagate_prepend(errp, *reasonp,
+                                        "migration blocker already added for: ");
+                return -EEXIST;
+            }
             migration_blockers[mode] = g_slist_prepend(migration_blockers[mode],
                                                        *reasonp);
         }
Signature · 1 line
2.42.0