bf143f
From 1f7cb73592a1922b3a981eb3232098281e07679f Mon Sep 17 00:00:00 2001
bf143f
From: Janosch Frank <frankja@linux.ibm.com>
bf143f
Date: Thu, 11 Aug 2022 12:10:59 +0000
bf143f
Subject: [PATCH 27/42] dump: Rework dump_calculate_size function
bf143f
MIME-Version: 1.0
bf143f
Content-Type: text/plain; charset=UTF-8
bf143f
Content-Transfer-Encoding: 8bit
bf143f
bf143f
RH-Author: Cédric Le Goater <clg@redhat.com>
bf143f
RH-MergeRequest: 226: s390: Enhanced Interpretation for PCI Functions and Secure Execution guest dump
bf143f
RH-Bugzilla: 1664378 2043909
bf143f
RH-Acked-by: Thomas Huth <thuth@redhat.com>
bf143f
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
bf143f
RH-Acked-by: Jon Maloy <jmaloy@redhat.com>
bf143f
RH-Commit: [27/41] eaa05c39109b57a119752ad3df66f4c2ace2cbe4
bf143f
bf143f
dump_calculate_size() sums up all the sizes of the guest memory
bf143f
blocks. Since we already have a function that calculates the size of a
bf143f
single memory block (dump_get_memblock_size()) we can simply iterate
bf143f
over the blocks and use the function instead of calculating the size
bf143f
ourselves.
bf143f
bf143f
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
bf143f
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
bf143f
Reviewed-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
bf143f
Message-Id: <20220811121111.9878-7-frankja@linux.ibm.com>
bf143f
(cherry picked from commit c370d5300f9ac1f90f8158082d22262b904fe30e)
bf143f
Signed-off-by: Cédric Le Goater <clg@redhat.com>
bf143f
---
bf143f
 dump/dump.c | 22 ++++++++--------------
bf143f
 1 file changed, 8 insertions(+), 14 deletions(-)
bf143f
bf143f
diff --git a/dump/dump.c b/dump/dump.c
bf143f
index f6fe13e258..902a85ef8e 100644
bf143f
--- a/dump/dump.c
bf143f
+++ b/dump/dump.c
bf143f
@@ -1557,25 +1557,19 @@ bool dump_in_progress(void)
bf143f
     return (qatomic_read(&state->status) == DUMP_STATUS_ACTIVE);
bf143f
 }
bf143f
 
bf143f
-/* calculate total size of memory to be dumped (taking filter into
bf143f
- * acoount.) */
bf143f
+/*
bf143f
+ * calculate total size of memory to be dumped (taking filter into
bf143f
+ * account.)
bf143f
+ */
bf143f
 static int64_t dump_calculate_size(DumpState *s)
bf143f
 {
bf143f
     GuestPhysBlock *block;
bf143f
-    int64_t size = 0, total = 0, left = 0, right = 0;
bf143f
+    int64_t total = 0;
bf143f
 
bf143f
     QTAILQ_FOREACH(block, &s->guest_phys_blocks.head, next) {
bf143f
-        if (dump_has_filter(s)) {
bf143f
-            /* calculate the overlapped region. */
bf143f
-            left = MAX(s->filter_area_begin, block->target_start);
bf143f
-            right = MIN(s->filter_area_begin + s->filter_area_length, block->target_end);
bf143f
-            size = right - left;
bf143f
-            size = size > 0 ? size : 0;
bf143f
-        } else {
bf143f
-            /* count the whole region in */
bf143f
-            size = (block->target_end - block->target_start);
bf143f
-        }
bf143f
-        total += size;
bf143f
+        total += dump_filtered_memblock_size(block,
bf143f
+                                             s->filter_area_begin,
bf143f
+                                             s->filter_area_length);
bf143f
     }
bf143f
 
bf143f
     return total;
bf143f
-- 
bf143f
2.37.3
bf143f