97168e
From b56c362132baef40cc25d910c1e0d217d83cfe44 Mon Sep 17 00:00:00 2001
97168e
From: Janosch Frank <frankja@linux.ibm.com>
97168e
Date: Thu, 11 Aug 2022 12:10:57 +0000
97168e
Subject: [PATCH 25/42] dump: Rework get_start_block
97168e
MIME-Version: 1.0
97168e
Content-Type: text/plain; charset=UTF-8
97168e
Content-Transfer-Encoding: 8bit
97168e
97168e
RH-Author: Cédric Le Goater <clg@redhat.com>
97168e
RH-MergeRequest: 226: s390: Enhanced Interpretation for PCI Functions and Secure Execution guest dump
97168e
RH-Bugzilla: 1664378 2043909
97168e
RH-Acked-by: Thomas Huth <thuth@redhat.com>
97168e
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
97168e
RH-Acked-by: Jon Maloy <jmaloy@redhat.com>
97168e
RH-Commit: [25/41] c93842a1aaeadcc11e91c194452fcd05d163b3ca
97168e
97168e
get_start_block() returns the start address of the first memory block
97168e
or -1.
97168e
97168e
With the GuestPhysBlock iterator conversion we don't need to set the
97168e
start address and can therefore remove that code and the "start"
97168e
DumpState struct member. The only functionality left is the validation
97168e
of the start block so it only makes sense to re-name the function to
97168e
validate_start_block()
97168e
97168e
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
97168e
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
97168e
Reviewed-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
97168e
Message-Id: <20220811121111.9878-5-frankja@linux.ibm.com>
97168e
(cherry picked from commit 0c2994ac9009577b967529ce18e269da5b280351)
97168e
Signed-off-by: Cédric Le Goater <clg@redhat.com>
97168e
---
97168e
 dump/dump.c           | 20 ++++++--------------
97168e
 include/sysemu/dump.h |  2 --
97168e
 2 files changed, 6 insertions(+), 16 deletions(-)
97168e
97168e
diff --git a/dump/dump.c b/dump/dump.c
97168e
index d981e843dd..e6aa037f59 100644
97168e
--- a/dump/dump.c
97168e
+++ b/dump/dump.c
97168e
@@ -1509,30 +1509,22 @@ static void create_kdump_vmcore(DumpState *s, Error **errp)
97168e
     }
97168e
 }
97168e
 
97168e
-static ram_addr_t get_start_block(DumpState *s)
97168e
+static int validate_start_block(DumpState *s)
97168e
 {
97168e
     GuestPhysBlock *block;
97168e
 
97168e
     if (!s->has_filter) {
97168e
-        s->next_block = QTAILQ_FIRST(&s->guest_phys_blocks.head);
97168e
         return 0;
97168e
     }
97168e
 
97168e
     QTAILQ_FOREACH(block, &s->guest_phys_blocks.head, next) {
97168e
+        /* This block is out of the range */
97168e
         if (block->target_start >= s->begin + s->length ||
97168e
             block->target_end <= s->begin) {
97168e
-            /* This block is out of the range */
97168e
             continue;
97168e
         }
97168e
-
97168e
-        s->next_block = block;
97168e
-        if (s->begin > block->target_start) {
97168e
-            s->start = s->begin - block->target_start;
97168e
-        } else {
97168e
-            s->start = 0;
97168e
-        }
97168e
-        return s->start;
97168e
-    }
97168e
+        return 0;
97168e
+   }
97168e
 
97168e
     return -1;
97168e
 }
97168e
@@ -1679,8 +1671,8 @@ static void dump_init(DumpState *s, int fd, bool has_format,
97168e
         goto cleanup;
97168e
     }
97168e
 
97168e
-    s->start = get_start_block(s);
97168e
-    if (s->start == -1) {
97168e
+    /* Is the filter filtering everything? */
97168e
+    if (validate_start_block(s) == -1) {
97168e
         error_setg(errp, QERR_INVALID_PARAMETER, "begin");
97168e
         goto cleanup;
97168e
     }
97168e
diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h
97168e
index ffc2ea1072..7fce1d4af6 100644
97168e
--- a/include/sysemu/dump.h
97168e
+++ b/include/sysemu/dump.h
97168e
@@ -166,8 +166,6 @@ typedef struct DumpState {
97168e
     hwaddr memory_offset;
97168e
     int fd;
97168e
 
97168e
-    GuestPhysBlock *next_block;
97168e
-    ram_addr_t start;
97168e
     bool has_filter;
97168e
     int64_t begin;
97168e
     int64_t length;
97168e
-- 
97168e
2.37.3
97168e