migration: trivial cleanup and refine
cover migration: trivial cleanup and refine
This patch set contains several cleanup and refine for migration.
simplify some calculation
reuse the result
fix typo in comment
provide error message when failed
Wei Yang (4):
migration/ram: only possible bit set in invalid_flags is
RAM_SAVE_FLAG_COMPRESS_PAGE
migration/postcopy: fix typo in mark_postcopy_blocktime_begin's
comment
migration: pass in_postcopy instead of check state again
migration: report SaveStateEntry id and name on failure
migration/migration.c | 3 +-- migration/postcopy-ram.c | 8 +++++--- migration/ram.c | 5 +---- migration/savevm.c | 2 ++ 4 files changed, 9 insertions(+), 9 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/4 migration/ram: only possible bit set in invalid_flags is RAM_SAVE_FLAG_COMPRESS_PAGE
The only possible bit set in invalid_flags is RAM_SAVE_FLAG_COMPRESS_PAGE at the beginning of function ram_load_precopy(), which means it is not necessary to do another check for RAM_SAVE_FLAG_COMPRESS_PAGE bit.
--- migration/ram.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
migration/ram.c +1 -4
@@ -4263,10 +4263,7 @@ static int ram_load_precopy(QEMUFile *f) addr &=TARGET_PAGE_MASK ;if (flags & invalid_flags) { -if (flags & invalid_flags &RAM_SAVE_FLAG_COMPRESS_PAGE ) { -error_report ("Received an unexpected compressed page" ); - } - +error_report ("Received an unexpected compressed page" ); ret = -EINVAL ;break ; }
Signature · 1 line
2.17.1
Re: [PATCH 1/4] migration/ram: only possible bit set in invalid_flags is RAM_SAVE_FLAG_COMPRESS_PAGE
Quoted 15 lines · * Wei Yang ([email protected]) wrote:
The only possible bit set in
invalid_flagsisRAM_SAVE_FLAG_COMPRESS_PAGEat the beginning of functionram_load_precopy(), which means it is not necessary to do another check forRAM_SAVE_FLAG_COMPRESS_PAGEbit.Signed-off-by Wei Yang <[email protected]>--- migration/ram.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)migration/ram.c +0
-0
migration/ram.c static int ram_load_precopy(QEMUFile *f) · line 4267
Quoted 9 lines
migration/ram.c +1
-4@@ -4263,10 +4263,7 @@ static int ram_load_precopy(QEMUFile *f) addr &=TARGET_PAGE_MASK ;if (flags & invalid_flags) { -if (flags & invalid_flags &RAM_SAVE_FLAG_COMPRESS_PAGE ) { -error_report ("Received an unexpected compressed page" ); - } - +error_report ("Received an unexpected compressed page" ); ret = -EINVAL ;
I'd rather keep this one; I think Juan's idea is that we might make other flags illegal here and then it's easy to add to invalid_flags at the top.
Dave
Quoted 5 lines
migration/ram.c +0
-0break ; }Signature · 1 line
2.17.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [PATCH 1/4] migration/ram: only possible bit set in invalid_flags is RAM_SAVE_FLAG_COMPRESS_PAGE
Quoted 18 lines · Dr. David Alan Gilbert
Quoted 17 lines · * Wei Yang ([email protected]) wrote:
The only possible bit set in
invalid_flagsisRAM_SAVE_FLAG_COMPRESS_PAGEat the beginning of functionram_load_precopy(), which means it is not necessary to do another check forRAM_SAVE_FLAG_COMPRESS_PAGEbit.Signed-off-by Wei Yang <[email protected]>--- migration/ram.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)migration/ram.c +0
-0@@ -4263,10 +4263,7 @@ static int ram_load_precopy(QEMUFile *f) addr &=TARGET_PAGE_MASK ;
Quoted 12 lines
migration/ram.c static int ram_load_precopy(QEMUFile *f) · line 4267
Quoted 7 lines
migration/ram.c +1
-4if (flags & invalid_flags) { -if (flags & invalid_flags &RAM_SAVE_FLAG_COMPRESS_PAGE ) { -error_report ("Received an unexpected compressed page" ); - } - +error_report ("Received an unexpected compressed page" ); ret = -EINVAL ;I'd rather keep this one; I think Juan's idea is that we might make other flags illegal here and then it's easy to add to
invalid_flagsat the top.
Reasonable.
Quoted 8 lines
Dave
Quoted 5 lines
migration/ram.c +0
-0break ; }Signature · 1 line
2.17.1--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Signature · 2 lines
Wei Yang Help you, Help me
PATCH 2/4 migration/postcopy: fix typo in mark_postcopy_blocktime_begin's comment
In reply to Wei Yang--- migration/postcopy-ram.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
migration/postcopy-ram.c +5 -3
@@ -768,9 +768,11 @@ static void mark_postcopy_blocktime_begin(uintptr_t addr, uint32_t ptid,atomic_xchg (&dc->page_fault_vcpu_time[cpu], low_time_offset);atomic_xchg (&dc->vcpu_addr[cpu], addr); -/* check it here, not at the begining of the function, -* due to, check could accur early than bitmap_set in -* qemu_ufd_copy_ioctl */ +/* +* check it here, not at the beginning of the function, +* due to, check could occur early than bitmap_set in +* qemu_ufd_copy_ioctl +*/ already_received =ramblock_recv_bitmap_test (rb, (void *)addr);if (already_received) {atomic_xchg (&dc->vcpu_addr[cpu],0 );
Signature · 1 line
2.17.1
Re: [PATCH 2/4] migration/postcopy: fix typo in mark_postcopy_blocktime_begin's comment
Quoted 15 lines · Wei Yang
Signed-off-by Wei Yang <[email protected]>--- migration/postcopy-ram.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)migration/postcopy-ram.c +0
-1@@ -768,9 +768,11 @@ static void mark_postcopy_blocktime_begin(uintptr_t addr, uint32_t ptid,atomic_xchg (&dc->page_fault_vcpu_time[cpu], low_time_offset);atomic_xchg (&dc->vcpu_addr[cpu], addr); -/* check it here, not at the begining of the function,
migration/postcopy-ram.c static void mark_postcopy_blocktime_begin(uintptr_t addr, uint32_t ptid, · line 778
Quoted 10 lines
migration/postcopy-ram.c +5
-2-* due to, check could accur early than bitmap_set in -* qemu_ufd_copy_ioctl */ +/* +* check it here, not at the beginning of the function, +* due to, check could occur early than bitmap_set in +* qemu_ufd_copy_ioctl +*/ already_received =ramblock_recv_bitmap_test (rb, (void *)addr);if (already_received) {atomic_xchg (&dc->vcpu_addr[cpu],0 );
PATCH 3/4 migration: pass in_postcopy instead of check state again
In reply to Wei YangNot necessary to do the check again.
--- migration/migration.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
migration/migration.c +1 -2
@@ -3148,8 +3148,7 @@ static MigIterateState migration_iteration_run(MigrationState *s)return MIG_ITERATE_SKIP ; }/* Just another iteration step */ -qemu_savevm_state_iterate (s->to_dst_file, - s->state ==MIGRATION_STATUS_POSTCOPY_ACTIVE ); +qemu_savevm_state_iterate (s->to_dst_file, in_postcopy); }else {trace_migration_thread_low_pending (pending_size);migration_completion (s);
Signature · 1 line
2.17.1
Re: [PATCH 3/4] migration: pass in_postcopy instead of check state again
Quoted 3 lines · * Wei Yang ([email protected]) wrote:
Not necessary to do the check again.
Signed-off-by Wei Yang <[email protected]>
Quoted 21 lines
--- migration/migration.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)migration/migration.c +1
-2@@ -3148,8 +3148,7 @@ static MigIterateState migration_iteration_run(MigrationState *s)return MIG_ITERATE_SKIP ; }/* Just another iteration step */ -qemu_savevm_state_iterate (s->to_dst_file, - s->state ==MIGRATION_STATUS_POSTCOPY_ACTIVE ); +qemu_savevm_state_iterate (s->to_dst_file, in_postcopy); }else {trace_migration_thread_low_pending (pending_size);migration_completion (s);Signature · 1 line
2.17.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 4/4 migration: report SaveStateEntry id and name on failure
In reply to Wei YangThis provides helpful information on which entry failed.
--- migration/savevm.c | 2 ++ 1 file changed, 2 insertions(+)
migration/savevm.c +2 -0
@@ -1215,6 +1215,8 @@ int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy)save_section_footer (f, se);if (ret <0 ) { +error_report ("failed to save SaveStateEntry with id(name): %d(%s)" , + se->section_id, se->idstr);qemu_file_set_error (f, ret); }if (ret <=0 ) {
Signature · 1 line
2.17.1
Re: [PATCH 4/4] migration: report SaveStateEntry id and name on failure
Quoted 13 lines · Wei Yang
This provides helpful information on which entry failed.
Signed-off-by Wei Yang <[email protected]>--- migration/savevm.c | 2 ++ 1 file changed, 2 insertions(+)migration/savevm.c +0
-0
migration/savevm.c int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy) · line 1222
Quoted 8 lines
migration/savevm.c +2
-0@@ -1215,6 +1215,8 @@ int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy)save_section_footer (f, se);if (ret <0 ) { +error_report ("failed to save SaveStateEntry with id(name): %d(%s)" , + se->section_id, se->idstr);qemu_file_set_error (f, ret); }if (ret <=0 ) {
Quoted 6 lines · * Wei Yang ([email protected]) wrote:
This patch set contains several cleanup and refine for migration.
simplify some calculation
reuse the result
fix typo in comment
provide error message when failed
2,3,4 queued
Quoted 9 lines
Wei Yang (4):
migration/ram: only possible bit set ininvalid_flagsis
RAM_SAVE_FLAG_COMPRESS_PAGE
migration/postcopy: fix typo in mark_postcopy_blocktime_begin's
comment
migration: passin_postcopyinstead of check state again
migration: report SaveStateEntry id and name on failure
Quoted 10 lines
migration/migration.c | 3 +-- migration/postcopy-ram.c | 8 +++++--- migration/ram.c | 5 +---- migration/savevm.c | 2 ++ 4 files changed, 9 insertions(+), 9 deletions(-)Signature · 1 line
2.17.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK