On 08/11/2022 20:56, Vladimir Sementsov-Ogievskiy wrote:
External email: Use caution opening links or attachments


On 11/3/22 19:16, Avihai Horon wrote:
From: Juan Quintela <quint...@redhat.com>

Signed-off-by: Juan Quintela <quint...@redhat.com>
Signed-off-by: Avihai Horon <avih...@nvidia.com>
---
  migration/migration.c | 25 +++++++++++++------------
  1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/migration/migration.c b/migration/migration.c
index ffe868b86f..59cc3c309b 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -3743,23 +3743,24 @@ static MigIterateState migration_iteration_run(MigrationState *s)

      trace_migrate_pending(pending_size, s->threshold_size, pend_pre, pend_post);

-    if (pending_size && pending_size >= s->threshold_size) {
-        /* Still a significant amount to transfer */
-        if (!in_postcopy && pend_pre <= s->threshold_size &&
-            qatomic_read(&s->start_postcopy)) {
-            if (postcopy_start(s)) {
-                error_report("%s: postcopy failed to start", __func__);
-            }
-            return MIG_ITERATE_SKIP;
-        }
-        /* Just another iteration step */
-        qemu_savevm_state_iterate(s->to_dst_file, in_postcopy);
-    } else {
+
+    if (pending_size < s->threshold_size) {

Is corner case "pending_size == s->threshold_size == 0" theoretically possible here? In this case prepatch we go to completion. Afterpatch we go to next iteration..

I guess it's theoretically possible.
Let's address this corner case and keep the functional behavior exactly the same.

Thanks!

trace_migration_thread_low_pending(pending_size);
          migration_completion(s);
          return MIG_ITERATE_BREAK;
      }

+    /* Still a significant amount to transfer */
+    if (!in_postcopy && pend_pre <= s->threshold_size &&
+        qatomic_read(&s->start_postcopy)) {
+        if (postcopy_start(s)) {
+            error_report("%s: postcopy failed to start", __func__);
+        }
+        return MIG_ITERATE_SKIP;
+    }
+
+    /* Just another iteration step */
+    qemu_savevm_state_iterate(s->to_dst_file, in_postcopy);
      return MIG_ITERATE_RESUME;
  }


--
Best regards,
Vladimir


Reply via email to