Skip to contentSkip to conversation

migration: trivial cleanup and refine

PATCH In review Wei Yang 3 participants 11 messages Oct 5, 2019 – Oct 11, 2019

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

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
author
#1 lore raw

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
index 31051935c8..769d3f6454 100644
@@ -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
#2 lore raw

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_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 +0 -0
index 31051935c8..769d3f6454 100644

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 -0
             break;
         }
Signature · 1 line
2.17.1

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

author
#3 lore raw

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_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 +0 -0
index 31051935c8..769d3f6454 100644
@@ -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 -4
         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.

Reasonable.

Quoted 8 lines

Dave

Quoted 5 lines
migration/ram.c +0 -0
             break;
         }
Signature · 1 line
2.17.1

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

Signature · 2 lines
Wei Yang
Help you, Help me
author
#4 lore raw

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
index d2bdd21ae3..a394c7c3a6 100644
@@ -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
Reviewed-by on v1 2/4
#5 lore raw

Re: [PATCH 2/4] migration/postcopy: fix typo in mark_postcopy_blocktime_begin's comment

Quoted 15 lines · Wei Yang
---
  migration/postcopy-ram.c | 8 +++++---
  1 file changed, 5 insertions(+), 3 deletions(-)
migration/postcopy-ram.c +0 -1
index d2bdd21ae3..a394c7c3a6 100644
@@ -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);
author
#6 lore raw

PATCH 3/4 migration: pass in_postcopy instead of check state again

In reply to Wei Yang

Not necessary to do the check again.

---
 migration/migration.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
migration/migration.c +1 -2
index c8eaa85867..56031305e3 100644
@@ -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
Reviewed-by on v1 3/4
#7 lore raw

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.

Quoted 21 lines
---
 migration/migration.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
migration/migration.c +1 -2
index c8eaa85867..56031305e3 100644
@@ -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

author
#8 lore raw

PATCH 4/4 migration: report SaveStateEntry id and name on failure

In reply to Wei Yang

This provides helpful information on which entry failed.

---
 migration/savevm.c | 2 ++
 1 file changed, 2 insertions(+)
migration/savevm.c +2 -0
index 9f0122583d..feb757de79 100644
@@ -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
Reviewed-by on v1 4/4
#9 lore raw

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.

---
  migration/savevm.c | 2 ++
  1 file changed, 2 insertions(+)
migration/savevm.c +0 -0
index 9f0122583d..feb757de79 100644

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) {
#10 lore raw
In reply to Wei Yang
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 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

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