thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
0727d3
From 030b54f5a2b2c8976370c962e9847af4746ac2c2 Mon Sep 17 00:00:00 2001
0727d3
From: David Edmondson <david.edmondson@oracle.com>
0727d3
Date: Tue, 21 Dec 2021 09:34:40 +0000
0727d3
Subject: [PATCH 1/9] migration: Introduce ram_transferred_add()
0727d3
MIME-Version: 1.0
0727d3
Content-Type: text/plain; charset=UTF-8
0727d3
Content-Transfer-Encoding: 8bit
0727d3
0727d3
RH-Author: Leonardo Brás <leobras@redhat.com>
0727d3
RH-MergeRequest: 201: Zero-copy-send fixes + improvements
0727d3
RH-Commit: [1/8] a6545760b0de13d533f6164be0545a6720bb42c7
0727d3
RH-Bugzilla: 2110203
0727d3
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
0727d3
RH-Acked-by: Peter Xu <peterx@redhat.com>
0727d3
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
0727d3
0727d3
Replace direct manipulation of ram_counters.transferred with a
0727d3
function.
0727d3
0727d3
Signed-off-by: David Edmondson <david.edmondson@oracle.com>
0727d3
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
0727d3
Reviewed-by: Juan Quintela <quintela@redhat.com>
0727d3
Signed-off-by: Juan Quintela <quintela@redhat.com>
0727d3
(cherry picked from commit 4c2d0f6dca24f3396ab0718ad3f9f53cc53004df)
0727d3
Signed-off-by: Leonardo Bras <leobras@redhat.com>
0727d3
---
0727d3
 migration/ram.c | 23 ++++++++++++++---------
0727d3
 1 file changed, 14 insertions(+), 9 deletions(-)
0727d3
0727d3
diff --git a/migration/ram.c b/migration/ram.c
0727d3
index 3e208efca7..3e82c4ff46 100644
0727d3
--- a/migration/ram.c
0727d3
+++ b/migration/ram.c
0727d3
@@ -391,6 +391,11 @@ uint64_t ram_bytes_remaining(void)
0727d3
 
0727d3
 MigrationStats ram_counters;
0727d3
 
0727d3
+static void ram_transferred_add(uint64_t bytes)
0727d3
+{
0727d3
+    ram_counters.transferred += bytes;
0727d3
+}
0727d3
+
0727d3
 /* used by the search for pages to send */
0727d3
 struct PageSearchStatus {
0727d3
     /* Current block being searched */
0727d3
@@ -772,7 +777,7 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data,
0727d3
      * RAM_SAVE_FLAG_CONTINUE.
0727d3
      */
0727d3
     xbzrle_counters.bytes += bytes_xbzrle - 8;
0727d3
-    ram_counters.transferred += bytes_xbzrle;
0727d3
+    ram_transferred_add(bytes_xbzrle);
0727d3
 
0727d3
     return 1;
0727d3
 }
0727d3
@@ -1203,7 +1208,7 @@ static int save_zero_page(RAMState *rs, RAMBlock *block, ram_addr_t offset)
0727d3
 
0727d3
     if (len) {
0727d3
         ram_counters.duplicate++;
0727d3
-        ram_counters.transferred += len;
0727d3
+        ram_transferred_add(len);
0727d3
         return 1;
0727d3
     }
0727d3
     return -1;
0727d3
@@ -1239,7 +1244,7 @@ static bool control_save_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,
0727d3
     }
0727d3
 
0727d3
     if (bytes_xmit) {
0727d3
-        ram_counters.transferred += bytes_xmit;
0727d3
+        ram_transferred_add(bytes_xmit);
0727d3
         *pages = 1;
0727d3
     }
0727d3
 
0727d3
@@ -1270,8 +1275,8 @@ static bool control_save_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,
0727d3
 static int save_normal_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,
0727d3
                             uint8_t *buf, bool async)
0727d3
 {
0727d3
-    ram_counters.transferred += save_page_header(rs, rs->f, block,
0727d3
-                                                 offset | RAM_SAVE_FLAG_PAGE);
0727d3
+    ram_transferred_add(save_page_header(rs, rs->f, block,
0727d3
+                                         offset | RAM_SAVE_FLAG_PAGE));
0727d3
     if (async) {
0727d3
         qemu_put_buffer_async(rs->f, buf, TARGET_PAGE_SIZE,
0727d3
                               migrate_release_ram() &
0727d3
@@ -1279,7 +1284,7 @@ static int save_normal_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,
0727d3
     } else {
0727d3
         qemu_put_buffer(rs->f, buf, TARGET_PAGE_SIZE);
0727d3
     }
0727d3
-    ram_counters.transferred += TARGET_PAGE_SIZE;
0727d3
+    ram_transferred_add(TARGET_PAGE_SIZE);
0727d3
     ram_counters.normal++;
0727d3
     return 1;
0727d3
 }
0727d3
@@ -1378,7 +1383,7 @@ exit:
0727d3
 static void
0727d3
 update_compress_thread_counts(const CompressParam *param, int bytes_xmit)
0727d3
 {
0727d3
-    ram_counters.transferred += bytes_xmit;
0727d3
+    ram_transferred_add(bytes_xmit);
0727d3
 
0727d3
     if (param->zero_page) {
0727d3
         ram_counters.duplicate++;
0727d3
@@ -2303,7 +2308,7 @@ void acct_update_position(QEMUFile *f, size_t size, bool zero)
0727d3
         ram_counters.duplicate += pages;
0727d3
     } else {
0727d3
         ram_counters.normal += pages;
0727d3
-        ram_counters.transferred += size;
0727d3
+        ram_transferred_add(size);
0727d3
         qemu_update_position(f, size);
0727d3
     }
0727d3
 }
0727d3
@@ -3147,7 +3152,7 @@ out:
0727d3
 
0727d3
         qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
0727d3
         qemu_fflush(f);
0727d3
-        ram_counters.transferred += 8;
0727d3
+        ram_transferred_add(8);
0727d3
 
0727d3
         ret = qemu_file_get_error(f);
0727d3
     }
0727d3
-- 
0727d3
2.31.1
0727d3