Skip to contentSkip to conversation

migration: current_migration is never NULL

PATCH In review Wei Yang 3 participants 3 messages Jun 26, 2019 – Jul 20, 2019

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 migration: current_migration is never NULL

migration_object_init() create and assign current_migration, which means it will never be null until migration_shutdown().

---
 migration/migration.c | 4 ----
 1 file changed, 4 deletions(-)
migration/migration.c +0 -4
index 0fd2364961..43fd8297ef 100644
@@ -1667,10 +1667,6 @@ bool migration_is_idle(void)
 {
     MigrationState *s = current_migration;
 
-    if (!s) {
-        return true;
-    }
-
     switch (s->state) {
     case MIGRATION_STATUS_NONE:
     case MIGRATION_STATUS_CANCELLED:
Signature · 1 line
2.19.1
#1 lore raw
Quoted 13 lines · * Wei Yang ([email protected]) wrote:

migration_object_init() create and assign current_migration, which means it will never be null until migration_shutdown().

---
 migration/migration.c | 4 ----
 1 file changed, 4 deletions(-)
migration/migration.c +0 -0
index 0fd2364961..43fd8297ef 100644

migration/migration.c bool migration_is_idle(void) · line 1673

Quoted 7 lines
migration/migration.c +0 -4
@@ -1667,10 +1667,6 @@ bool migration_is_idle(void)
 {
     MigrationState *s = current_migration;
 
-    if (!s) {
-        return true;
-    }
-

I'd prefer to keep that because it's used by migrate_add_blocker and without this check it means we'd only be able to add a blocker after the migration object init - which is probably fine but we would have to check all the cases and make sure no one breaks it in the future; where as this check makes it just work and we don't need to worry about the order.

Dave

Quoted 6 lines
migration/migration.c +0 -0
     switch (s->state) {
     case MIGRATION_STATUS_NONE:
     case MIGRATION_STATUS_CANCELLED:
Signature · 1 line
2.19.1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#2 lore raw
Quoted 17 lines · Dr. David Alan Gilbert
Quoted 16 lines · * Wei Yang ([email protected]) wrote:

migration_object_init() create and assign current_migration, which means it will never be null until migration_shutdown().

---
 migration/migration.c | 4 ----
 1 file changed, 4 deletions(-)
migration/migration.c +0 -0
index 0fd2364961..43fd8297ef 100644
@@ -1667,10 +1667,6 @@ bool migration_is_idle(void)
 {
     MigrationState *s = current_migration;
 
Quoted 12 lines

migration/migration.c bool migration_is_idle(void) · line 1673

Quoted 4 lines
migration/migration.c +0 -4
-    if (!s) {
-        return true;
-    }
-

I'd prefer to keep that because it's used by migrate_add_blocker and without this check it means we'd only be able to add a blocker after the migration object init - which is probably fine but we would have to check all the cases and make sure no one breaks it in the future; where as this check makes it just work and we don't need to worry about the order.

Reasonable, Thanks :-)

Quoted 10 lines

Dave

Quoted 6 lines
migration/migration.c +0 -0
     switch (s->state) {
     case MIGRATION_STATUS_NONE:
     case MIGRATION_STATUS_CANCELLED:
Signature · 1 line
2.19.1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

Signature · 2 lines
Wei Yang
Help you, Help me