26ba25
From e3c0812c4d61c956ac5b0641826c4e4fbda55954 Mon Sep 17 00:00:00 2001
26ba25
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
26ba25
Date: Wed, 1 Aug 2018 13:55:14 +0100
26ba25
Subject: [PATCH 10/21] migration: remove ram_save_compressed_page()
26ba25
26ba25
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
26ba25
Message-id: <20180801135522.11658-11-dgilbert@redhat.com>
26ba25
Patchwork-id: 81578
26ba25
O-Subject: [qemu-kvm RHEL8/virt212 PATCH 10/18] migration: remove ram_save_compressed_page()
26ba25
Bugzilla: 1594384
26ba25
RH-Acked-by: Peter Xu <peterx@redhat.com>
26ba25
RH-Acked-by: John Snow <jsnow@redhat.com>
26ba25
RH-Acked-by: Juan Quintela <quintela@redhat.com>
26ba25
26ba25
From: Xiao Guangrong <xiaoguangrong@tencent.com>
26ba25
26ba25
Now, we can reuse the path in ram_save_page() to post the page out
26ba25
as normal, then the only thing remained in ram_save_compressed_page()
26ba25
is compression that we can move it out to the caller
26ba25
26ba25
Reviewed-by: Peter Xu <peterx@redhat.com>
26ba25
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
26ba25
Signed-off-by: Xiao Guangrong <xiaoguangrong@tencent.com>
26ba25
Message-Id: <20180330075128.26919-11-xiaoguangrong@tencent.com>
26ba25
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
26ba25
(cherry picked from commit da3f56cb2e767016d3f204837a77caf35b463f90)
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 migration/ram.c | 45 ++++++++-------------------------------------
26ba25
 1 file changed, 8 insertions(+), 37 deletions(-)
26ba25
26ba25
diff --git a/migration/ram.c b/migration/ram.c
26ba25
index 908879f..466609f 100644
26ba25
--- a/migration/ram.c
26ba25
+++ b/migration/ram.c
26ba25
@@ -1186,41 +1186,6 @@ static int compress_page_with_multi_thread(RAMState *rs, RAMBlock *block,
26ba25
 }
26ba25
 
26ba25
 /**
26ba25
- * ram_save_compressed_page: compress the given page and send it to the stream
26ba25
- *
26ba25
- * Returns the number of pages written.
26ba25
- *
26ba25
- * @rs: current RAM state
26ba25
- * @block: block that contains the page we want to send
26ba25
- * @offset: offset inside the block for the page
26ba25
- * @last_stage: if we are at the completion stage
26ba25
- */
26ba25
-static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss,
26ba25
-                                    bool last_stage)
26ba25
-{
26ba25
-    int pages = -1;
26ba25
-    uint8_t *p;
26ba25
-    RAMBlock *block = pss->block;
26ba25
-    ram_addr_t offset = pss->page << TARGET_PAGE_BITS;
26ba25
-
26ba25
-    p = block->host + offset;
26ba25
-
26ba25
-    if (block != rs->last_sent_block) {
26ba25
-        /*
26ba25
-         * Make sure the first page is sent out before other pages.
26ba25
-         *
26ba25
-         * we post it as normal page as compression will take much
26ba25
-         * CPU resource.
26ba25
-         */
26ba25
-        pages = save_normal_page(rs, block, offset, p, true);
26ba25
-    } else {
26ba25
-        pages = compress_page_with_multi_thread(rs, block, offset);
26ba25
-    }
26ba25
-
26ba25
-    return pages;
26ba25
-}
26ba25
-
26ba25
-/**
26ba25
  * find_dirty_block: find the next dirty page and update any state
26ba25
  * associated with the search process.
26ba25
  *
26ba25
@@ -1519,8 +1484,14 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss,
26ba25
         return res;
26ba25
     }
26ba25
 
26ba25
-    if (save_page_use_compression(rs)) {
26ba25
-        return ram_save_compressed_page(rs, pss, last_stage);
26ba25
+    /*
26ba25
+     * Make sure the first page is sent out before other pages.
26ba25
+     *
26ba25
+     * we post it as normal page as compression will take much
26ba25
+     * CPU resource.
26ba25
+     */
26ba25
+    if (block == rs->last_sent_block && save_page_use_compression(rs)) {
26ba25
+        res = compress_page_with_multi_thread(rs, block, offset);
26ba25
     }
26ba25
 
26ba25
     return ram_save_page(rs, pss, last_stage);
26ba25
-- 
26ba25
1.8.3.1
26ba25