diff mbox series

[v2,4/8] migration: Integrate control_save_page() logic into ram_save_target_page()

Message ID 20250221063612.695909-5-lizhijian@fujitsu.com (mailing list archive)
State New
Headers show
Series migration/rdma: fixes, refactor and cleanup | expand

Commit Message

Li Zhijian Feb. 21, 2025, 6:36 a.m. UTC
Refactor the page saving logic by integrating the control_save_page()
function directly into ram_save_target_page(). This change consolidates the
RDMA migration decision-making process into a single function, enhancing
clarity and maintainability.

Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
---
 migration/ram.c | 35 +++++++----------------------------
 1 file changed, 7 insertions(+), 28 deletions(-)
diff mbox series

Patch

diff --git a/migration/ram.c b/migration/ram.c
index b7157b9b175..e07651aee8d 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1143,33 +1143,6 @@  static int save_zero_page(RAMState *rs, PageSearchStatus *pss,
     return len;
 }
 
-/*
- * @pages: the number of pages written by the control path,
- *        < 0 - error
- *        > 0 - number of pages written
- *
- * Return true if the pages has been saved, otherwise false is returned.
- */
-static bool control_save_page(PageSearchStatus *pss,
-                              ram_addr_t offset, int *pages)
-{
-    int ret;
-
-    if (migrate_rdma() && !migration_in_postcopy()) {
-        ret = rdma_control_save_page(pss->pss_channel, pss->block->offset,
-                                     offset, TARGET_PAGE_SIZE);
-
-        if (ret == RAM_SAVE_CONTROL_DELAYED) {
-            *pages = 1;
-        } else {
-            *pages = ret;
-        }
-        return true;
-    }
-
-    return false;
-}
-
 /*
  * directly send the page to the stream
  *
@@ -1966,7 +1939,13 @@  static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss)
     int res;
 
     /* Hand over to RDMA first */
-    if (control_save_page(pss, offset, &res)) {
+    if (migrate_rdma() && !migration_in_postcopy()) {
+        res = rdma_control_save_page(pss->pss_channel, pss->block->offset,
+                                     offset, TARGET_PAGE_SIZE);
+
+        if (res == RAM_SAVE_CONTROL_DELAYED) {
+            res = 1;
+        }
         return res;
     }