migration: Stop migration immediately in RDMA error paths
PATCH v2 1/1 migration: Stop migration immediately in RDMA error paths
In multiple places, RDMA errors are handled in a strange way, where it only sets qemu_file_set_error() but not stop the migration immediately.
It's not obvious what will happen later if there is already an error. Make all such failures stop migration immediately.
---
v2:
- One more line squashed into to fix the build error... Please ignore v1, sorry for the noise.
This patch is based on Thomas's patch:
[PATCH v2] migration/ram: Fix compilation with -Wshadow=local
https://lore.kernel.org/r/[email protected]
Above patch should have been queued by both Markus and Juan.
--- migration/ram.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
migration/ram.c +8 -5
@@ -3034,11 +3034,13 @@ static int ram_save_setup(QEMUFile *f, void *opaque) ret =rdma_registration_start (f,RAM_CONTROL_SETUP );if (ret <0 ) {qemu_file_set_error (f, ret); +return ret; } ret =rdma_registration_stop (f,RAM_CONTROL_SETUP );if (ret <0 ) {qemu_file_set_error (f, ret); +return ret; } migration_ops =g_malloc0 (sizeof (MigrationOps));
@@ -3104,6 +3106,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) ret =rdma_registration_start (f,RAM_CONTROL_ROUND );if (ret <0 ) {qemu_file_set_error (f, ret); + goto out; } t0 =qemu_clock_get_ns (QEMU_CLOCK_REALTIME );
@@ -3208,8 +3211,6 @@ static int ram_save_complete(QEMUFile *f, void *opaque) rs->last_stage = !migration_in_colo_state (); WITH_RCU_READ_LOCK_GUARD() { -int rdma_reg_ret; -if (!migration_in_postcopy ()) {migration_bitmap_sync_precopy (rs, true); }
@@ -3217,6 +3218,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque) ret =rdma_registration_start (f,RAM_CONTROL_FINISH );if (ret <0 ) {qemu_file_set_error (f, ret); +break ; }/* try transferring iterative blocks of memory */
@@ -3240,9 +3242,10 @@ static int ram_save_complete(QEMUFile *f, void *opaque)ram_flush_compressed_data (rs); - rdma_reg_ret =rdma_registration_stop (f,RAM_CONTROL_FINISH ); -if (rdma_reg_ret <0 ) { -qemu_file_set_error (f, rdma_reg_ret); + ret =rdma_registration_stop (f,RAM_CONTROL_FINISH ); +if (ret <0 ) { +qemu_file_set_error (f, ret); +break ; } }
Signature · 1 line
2.41.0
Quoted 33 lines · Peter Xu
In multiple places, RDMA errors are handled in a strange way, where it only sets
qemu_file_set_error()but not stop the migration immediately.It's not obvious what will happen later if there is already an error. Make all such failures stop migration immediately.
Cc Zhijian Li (Fujitsu) <[email protected]>Cc Markus Armbruster <[email protected]>Cc Juan Quintela <[email protected]>Cc Fabiano Rosas <[email protected]>Reported-by Thomas Huth <[email protected]>Signed-off-by Peter Xu <[email protected]>---
v2:
- One more line squashed into to fix the build error... Please ignore v1, sorry for the noise.This patch is based on Thomas's patch:
[PATCH v2] migration/ram: Fix compilation with -Wshadow=local
https://lore.kernel.org/r/[email protected]Above patch should have been queued by both Markus and Juan.
--- migration/ram.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)migration/ram.c +0
-0
migration/ram.c static int ram_save_setup(QEMUFile *f, void *opaque) · line 3037
Quoted 4 lines
migration/ram.c +1
-0@@ -3034,11 +3034,13 @@ static int ram_save_setup(QEMUFile *f, void *opaque) ret =rdma_registration_start (f,RAM_CONTROL_SETUP );if (ret <0 ) {qemu_file_set_error (f, ret); +return ret;
I agree
migration/ram.c static int ram_save_setup(QEMUFile *f, void *opaque) · line 3043
Quoted 6 lines
migration/ram.c +1
-0} ret =rdma_registration_stop (f,RAM_CONTROL_SETUP );if (ret <0 ) {qemu_file_set_error (f, ret); +return ret;
I agree
migration/ram.c static int ram_save_iterate(QEMUFile *f, void *opaque) · line 3109
Quoted 8 lines
migration/ram.c +1
-0} migration_ops =g_malloc0 (sizeof (MigrationOps));@@ -3104,6 +3106,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) ret =rdma_registration_start (f,RAM_CONTROL_ROUND );if (ret <0 ) {qemu_file_set_error (f, ret); + goto out;
Seems sensible
Quoted 13 lines
migration/ram.c +0
-2} t0 =qemu_clock_get_ns (QEMU_CLOCK_REALTIME );@@ -3208,8 +3211,6 @@ static int ram_save_complete(QEMUFile *f, void *opaque) rs->last_stage = !migration_in_colo_state (); WITH_RCU_READ_LOCK_GUARD() { -int rdma_reg_ret; -if (!migration_in_postcopy ()) {migration_bitmap_sync_precopy (rs, true); }
migration/ram.c static int ram_save_complete(QEMUFile *f, void *opaque) · line 3221
Quoted 4 lines
migration/ram.c +1
-0@@ -3217,6 +3218,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque) ret =rdma_registration_start (f,RAM_CONTROL_FINISH );if (ret <0 ) {qemu_file_set_error (f, ret); +break ;
Please
return ret;
We can do exactly the same with pages < 0.
Quoted 6 lines
migration/ram.c +0
-0}/* try transferring iterative blocks of memory */ @@ -3240,9 +3242,10 @@ static int ram_save_complete(QEMUFile *f, void *opaque)ram_flush_compressed_data (rs);
migration/ram.c static int ram_save_complete(QEMUFile *f, void *opaque) · line 3250
Quoted 10 lines
migration/ram.c +4
-3- rdma_reg_ret =rdma_registration_stop (f,RAM_CONTROL_FINISH ); -if (rdma_reg_ret <0 ) { -qemu_file_set_error (f, rdma_reg_ret); + ret =rdma_registration_stop (f,RAM_CONTROL_FINISH ); +if (ret <0 ) { +qemu_file_set_error (f, ret); +break ; } }
And if we return here, we can just drop the:
if (ret < 0) {
return ret;
}At the ext of the loop.
Later, Juan.
Quoted 104 lines · Juan Quintela
Quoted 33 lines · Peter Xu
In multiple places, RDMA errors are handled in a strange way, where it only sets
qemu_file_set_error()but not stop the migration immediately.It's not obvious what will happen later if there is already an error. Make all such failures stop migration immediately.
Cc Zhijian Li (Fujitsu) <[email protected]>Cc Markus Armbruster <[email protected]>Cc Juan Quintela <[email protected]>Cc Fabiano Rosas <[email protected]>Reported-by Thomas Huth <[email protected]>Signed-off-by Peter Xu <[email protected]>---
v2:
- One more line squashed into to fix the build error... Please ignore v1, sorry for the noise.This patch is based on Thomas's patch:
[PATCH v2] migration/ram: Fix compilation with -Wshadow=local
https://lore.kernel.org/r/[email protected]Above patch should have been queued by both Markus and Juan.
--- migration/ram.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)migration/ram.c +0
-0migration/ram.c static int ram_save_setup(QEMUFile *f, void *opaque) · line 3037
Quoted 4 lines
migration/ram.c +1
-0@@ -3034,11 +3034,13 @@ static int ram_save_setup(QEMUFile *f, void *opaque) ret =rdma_registration_start (f,RAM_CONTROL_SETUP );if (ret <0 ) {qemu_file_set_error (f, ret); +return ret;I agree
migration/ram.c static int ram_save_setup(QEMUFile *f, void *opaque) · line 3043
Quoted 6 lines
migration/ram.c +1
-0} ret =rdma_registration_stop (f,RAM_CONTROL_SETUP );if (ret <0 ) {qemu_file_set_error (f, ret); +return ret;I agree
migration/ram.c static int ram_save_iterate(QEMUFile *f, void *opaque) · line 3109
Quoted 8 lines
migration/ram.c +1
-0} migration_ops =g_malloc0 (sizeof (MigrationOps));@@ -3104,6 +3106,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) ret =rdma_registration_start (f,RAM_CONTROL_ROUND );if (ret <0 ) {qemu_file_set_error (f, ret); + goto out;Seems sensible
Quoted 13 lines
migration/ram.c +0
-2} t0 =qemu_clock_get_ns (QEMU_CLOCK_REALTIME );@@ -3208,8 +3211,6 @@ static int ram_save_complete(QEMUFile *f, void *opaque) rs->last_stage = !migration_in_colo_state (); WITH_RCU_READ_LOCK_GUARD() { -int rdma_reg_ret; -if (!migration_in_postcopy ()) {migration_bitmap_sync_precopy (rs, true); }migration/ram.c static int ram_save_complete(QEMUFile *f, void *opaque) · line 3221
Quoted 4 lines
migration/ram.c +1
-0@@ -3217,6 +3218,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque) ret =rdma_registration_start (f,RAM_CONTROL_FINISH );if (ret <0 ) {qemu_file_set_error (f, ret); +break ;Please
return ret;We can do exactly the same with pages < 0.
Quoted 6 lines
migration/ram.c +0
-0}/* try transferring iterative blocks of memory */ @@ -3240,9 +3242,10 @@ static int ram_save_complete(QEMUFile *f, void *opaque)ram_flush_compressed_data (rs);migration/ram.c static int ram_save_complete(QEMUFile *f, void *opaque) · line 3250
Quoted 10 lines
migration/ram.c +4
-3- rdma_reg_ret =rdma_registration_stop (f,RAM_CONTROL_FINISH ); -if (rdma_reg_ret <0 ) { -qemu_file_set_error (f, rdma_reg_ret); + ret =rdma_registration_stop (f,RAM_CONTROL_FINISH ); +if (ret <0 ) { +qemu_file_set_error (f, ret); +break ; } }And if we return here, we can just drop the:
Quoted 6 lines
if (ret < 0) { return ret; }At the ext of the loop.
IIUC that'll be the same as this patch, but sure thing I'll prepare a v3.
Thanks,
Signature · 1 line
Peter Xu
Quoted 105 lines · Peter Xu
Quoted 104 lines · Juan Quintela
Quoted 33 lines · Peter Xu
In multiple places, RDMA errors are handled in a strange way, where it only sets
qemu_file_set_error()but not stop the migration immediately.It's not obvious what will happen later if there is already an error. Make all such failures stop migration immediately.
Cc Zhijian Li (Fujitsu) <[email protected]>Cc Markus Armbruster <[email protected]>Cc Juan Quintela <[email protected]>Cc Fabiano Rosas <[email protected]>Reported-by Thomas Huth <[email protected]>Signed-off-by Peter Xu <[email protected]>---
v2:
- One more line squashed into to fix the build error... Please ignore v1, sorry for the noise.This patch is based on Thomas's patch:
[PATCH v2] migration/ram: Fix compilation with -Wshadow=local
https://lore.kernel.org/r/[email protected]Above patch should have been queued by both Markus and Juan.
--- migration/ram.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)migration/ram.c +0
-0migration/ram.c static int ram_save_setup(QEMUFile *f, void *opaque) · line 3037
Quoted 4 lines
migration/ram.c +1
-0@@ -3034,11 +3034,13 @@ static int ram_save_setup(QEMUFile *f, void *opaque) ret =rdma_registration_start (f,RAM_CONTROL_SETUP );if (ret <0 ) {qemu_file_set_error (f, ret); +return ret;I agree
migration/ram.c static int ram_save_setup(QEMUFile *f, void *opaque) · line 3043
Quoted 6 lines
migration/ram.c +1
-0} ret =rdma_registration_stop (f,RAM_CONTROL_SETUP );if (ret <0 ) {qemu_file_set_error (f, ret); +return ret;I agree
migration/ram.c static int ram_save_iterate(QEMUFile *f, void *opaque) · line 3109
Quoted 8 lines
migration/ram.c +1
-0} migration_ops =g_malloc0 (sizeof (MigrationOps));@@ -3104,6 +3106,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) ret =rdma_registration_start (f,RAM_CONTROL_ROUND );if (ret <0 ) {qemu_file_set_error (f, ret); + goto out;Seems sensible
Quoted 13 lines
migration/ram.c +0
-2} t0 =qemu_clock_get_ns (QEMU_CLOCK_REALTIME );@@ -3208,8 +3211,6 @@ static int ram_save_complete(QEMUFile *f, void *opaque) rs->last_stage = !migration_in_colo_state (); WITH_RCU_READ_LOCK_GUARD() { -int rdma_reg_ret; -if (!migration_in_postcopy ()) {migration_bitmap_sync_precopy (rs, true); }migration/ram.c static int ram_save_complete(QEMUFile *f, void *opaque) · line 3221
Quoted 4 lines
migration/ram.c +1
-0@@ -3217,6 +3218,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque) ret =rdma_registration_start (f,RAM_CONTROL_FINISH );if (ret <0 ) {qemu_file_set_error (f, ret); +break ;Please
return ret;We can do exactly the same with pages < 0.
Quoted 6 lines
migration/ram.c +0
-0}/* try transferring iterative blocks of memory */ @@ -3240,9 +3242,10 @@ static int ram_save_complete(QEMUFile *f, void *opaque)ram_flush_compressed_data (rs);migration/ram.c static int ram_save_complete(QEMUFile *f, void *opaque) · line 3250
Quoted 10 lines
migration/ram.c +4
-3- rdma_reg_ret =rdma_registration_stop (f,RAM_CONTROL_FINISH ); -if (rdma_reg_ret <0 ) { -qemu_file_set_error (f, rdma_reg_ret); + ret =rdma_registration_stop (f,RAM_CONTROL_FINISH ); +if (ret <0 ) { +qemu_file_set_error (f, ret); +break ; } }And if we return here, we can just drop the:
Quoted 8 lines
Quoted 6 lines
if (ret < 0) { return ret; }At the ext of the loop.
IIUC that'll be the same as this patch,
No.
if you see a break, you need to search for the loop, and go to the end and see what happens.
return ret;
It is completely obvious what we do in case of error.
Quoted 1 line
but sure thing I'll prepare a v3.
Thanks.