Skip to contentSkip to conversation

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

PATCH Superseded Ani Sinha 3 participants 4 messages Mar 8 – Mar 10

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ani Sinha

author
#0 lore raw

PATCH 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(+)
migration/migration.c +2 -0
index a5b0465ed3..840cf0dfe2 100644
@@ -1702,6 +1702,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
#2 lore raw
In reply to Ani Sinha
Quoted 17 lines · Ani Sinha

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(+)
migration/migration.c +0 -0
index a5b0465ed3..840cf0dfe2 100644

migration/migration.c static int add_blockers(Error **reasonp, unsigned modes, Error **errp) · line 1706

Quoted 5 lines
migration/migration.c +2 -0
@@ -1702,6 +1702,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);

Indentation is off.

Have we run into such extra additions, or is this just out of caution?

What would happen if such an extra addition went uncaught?

Quoted 3 lines
migration/migration.c +0 -0
             migration_blockers[mode] = g_slist_prepend(migration_blockers[mode],
                                                        *reasonp);
         }
author
#3 lore raw
Quoted 31 lines · Markus Armbruster
Quoted 17 lines · Ani Sinha

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(+)
migration/migration.c +0 -0
index a5b0465ed3..840cf0dfe2 100644

migration/migration.c static int add_blockers(Error **reasonp, unsigned modes, Error **errp) · line 1706

Quoted 5 lines
migration/migration.c +2 -0
@@ -1702,6 +1702,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);

Indentation is off.

Quoted 1 line

Have we run into such extra additions, or is this just out of caution?

Out of caution I suspect.

Quoted 5 lines

What would happen if such an extra addition went uncaught?

Quoted 2 lines
migration/migration.c +0 -0
            migration_blockers[mode] = g_slist_prepend(migration_blockers[mode],
                                                       *reasonp);

I vaguely recall multiple blockers causing some crash.

Quoted 1 line
Quoted 1 line
migration/migration.c +0 -0
        }