Blame SOURCES/kvm-migration-introduce-save_normal_page.patch

383d26
From 45b68ea328fbac00681b1c2eec1eb1499005020a Mon Sep 17 00:00:00 2001
383d26
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
383d26
Date: Fri, 22 Jun 2018 18:59:56 +0200
383d26
Subject: [PATCH 17/57] migration: introduce save_normal_page()
383d26
383d26
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
383d26
Message-id: <20180622190005.21297-10-dgilbert@redhat.com>
383d26
Patchwork-id: 81003
383d26
O-Subject: [RHEL7.6 qemu-kvm-rhev PATCH 09/18] migration: introduce save_normal_page()
383d26
Bugzilla: 1584139
383d26
RH-Acked-by: Peter Xu <peterx@redhat.com>
383d26
RH-Acked-by: Juan Quintela <quintela@redhat.com>
383d26
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
383d26
383d26
From: Xiao Guangrong <xiaoguangrong@tencent.com>
383d26
383d26
It directly sends the page to the stream neither checking zero nor
383d26
using xbzrle or compression
383d26
383d26
Reviewed-by: Peter Xu <peterx@redhat.com>
383d26
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
383d26
Signed-off-by: Xiao Guangrong <xiaoguangrong@tencent.com>
383d26
Message-Id: <20180330075128.26919-10-xiaoguangrong@tencent.com>
383d26
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
383d26
(cherry picked from commit 65dacaa04fa7e6104cbcee9251c7845355769a10)
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 migration/ram.c | 50 ++++++++++++++++++++++++++++++--------------------
383d26
 1 file changed, 30 insertions(+), 20 deletions(-)
383d26
383d26
diff --git a/migration/ram.c b/migration/ram.c
383d26
index 6e8a7e2..908879f 100644
383d26
--- a/migration/ram.c
383d26
+++ b/migration/ram.c
383d26
@@ -1013,6 +1013,34 @@ static bool control_save_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,
383d26
     return true;
383d26
 }
383d26
 
383d26
+/*
383d26
+ * directly send the page to the stream
383d26
+ *
383d26
+ * Returns the number of pages written.
383d26
+ *
383d26
+ * @rs: current RAM state
383d26
+ * @block: block that contains the page we want to send
383d26
+ * @offset: offset inside the block for the page
383d26
+ * @buf: the page to be sent
383d26
+ * @async: send to page asyncly
383d26
+ */
383d26
+static int save_normal_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,
383d26
+                            uint8_t *buf, bool async)
383d26
+{
383d26
+    ram_counters.transferred += save_page_header(rs, rs->f, block,
383d26
+                                                 offset | RAM_SAVE_FLAG_PAGE);
383d26
+    if (async) {
383d26
+        qemu_put_buffer_async(rs->f, buf, TARGET_PAGE_SIZE,
383d26
+                              migrate_release_ram() &
383d26
+                              migration_in_postcopy());
383d26
+    } else {
383d26
+        qemu_put_buffer(rs->f, buf, TARGET_PAGE_SIZE);
383d26
+    }
383d26
+    ram_counters.transferred += TARGET_PAGE_SIZE;
383d26
+    ram_counters.normal++;
383d26
+    return 1;
383d26
+}
383d26
+
383d26
 /**
383d26
  * ram_save_page: send the given page to the stream
383d26
  *
383d26
@@ -1053,18 +1081,7 @@ static int ram_save_page(RAMState *rs, PageSearchStatus *pss, bool last_stage)
383d26
 
383d26
     /* XBZRLE overflow or normal page */
383d26
     if (pages == -1) {
383d26
-        ram_counters.transferred +=
383d26
-            save_page_header(rs, rs->f, block, offset | RAM_SAVE_FLAG_PAGE);
383d26
-        if (send_async) {
383d26
-            qemu_put_buffer_async(rs->f, p, TARGET_PAGE_SIZE,
383d26
-                                  migrate_release_ram() &
383d26
-                                  migration_in_postcopy());
383d26
-        } else {
383d26
-            qemu_put_buffer(rs->f, p, TARGET_PAGE_SIZE);
383d26
-        }
383d26
-        ram_counters.transferred += TARGET_PAGE_SIZE;
383d26
-        pages = 1;
383d26
-        ram_counters.normal++;
383d26
+        pages = save_normal_page(rs, block, offset, p, send_async);
383d26
     }
383d26
 
383d26
     XBZRLE_cache_unlock();
383d26
@@ -1195,14 +1212,7 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss,
383d26
          * we post it as normal page as compression will take much
383d26
          * CPU resource.
383d26
          */
383d26
-        ram_counters.transferred += save_page_header(rs, rs->f, block,
383d26
-                                        offset | RAM_SAVE_FLAG_PAGE);
383d26
-        qemu_put_buffer_async(rs->f, p, TARGET_PAGE_SIZE,
383d26
-                              migrate_release_ram() &
383d26
-                              migration_in_postcopy());
383d26
-        ram_counters.transferred += TARGET_PAGE_SIZE;
383d26
-        ram_counters.normal++;
383d26
-        pages = 1;
383d26
+        pages = save_normal_page(rs, block, offset, p, true);
383d26
     } else {
383d26
         pages = compress_page_with_multi_thread(rs, block, offset);
383d26
     }
383d26
-- 
383d26
1.8.3.1
383d26