thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
bf143f
From b56c362132baef40cc25d910c1e0d217d83cfe44 Mon Sep 17 00:00:00 2001
bf143f
From: Janosch Frank <frankja@linux.ibm.com>
bf143f
Date: Thu, 11 Aug 2022 12:10:57 +0000
bf143f
Subject: [PATCH 25/42] dump: Rework get_start_block
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: [25/41] c93842a1aaeadcc11e91c194452fcd05d163b3ca
bf143f
bf143f
get_start_block() returns the start address of the first memory block
bf143f
or -1.
bf143f
bf143f
With the GuestPhysBlock iterator conversion we don't need to set the
bf143f
start address and can therefore remove that code and the "start"
bf143f
DumpState struct member. The only functionality left is the validation
bf143f
of the start block so it only makes sense to re-name the function to
bf143f
validate_start_block()
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-5-frankja@linux.ibm.com>
bf143f
(cherry picked from commit 0c2994ac9009577b967529ce18e269da5b280351)
bf143f
Signed-off-by: Cédric Le Goater <clg@redhat.com>
bf143f
---
bf143f
 dump/dump.c           | 20 ++++++--------------
bf143f
 include/sysemu/dump.h |  2 --
bf143f
 2 files changed, 6 insertions(+), 16 deletions(-)
bf143f
bf143f
diff --git a/dump/dump.c b/dump/dump.c
bf143f
index d981e843dd..e6aa037f59 100644
bf143f
--- a/dump/dump.c
bf143f
+++ b/dump/dump.c
bf143f
@@ -1509,30 +1509,22 @@ static void create_kdump_vmcore(DumpState *s, Error **errp)
bf143f
     }
bf143f
 }
bf143f
 
bf143f
-static ram_addr_t get_start_block(DumpState *s)
bf143f
+static int validate_start_block(DumpState *s)
bf143f
 {
bf143f
     GuestPhysBlock *block;
bf143f
 
bf143f
     if (!s->has_filter) {
bf143f
-        s->next_block = QTAILQ_FIRST(&s->guest_phys_blocks.head);
bf143f
         return 0;
bf143f
     }
bf143f
 
bf143f
     QTAILQ_FOREACH(block, &s->guest_phys_blocks.head, next) {
bf143f
+        /* This block is out of the range */
bf143f
         if (block->target_start >= s->begin + s->length ||
bf143f
             block->target_end <= s->begin) {
bf143f
-            /* This block is out of the range */
bf143f
             continue;
bf143f
         }
bf143f
-
bf143f
-        s->next_block = block;
bf143f
-        if (s->begin > block->target_start) {
bf143f
-            s->start = s->begin - block->target_start;
bf143f
-        } else {
bf143f
-            s->start = 0;
bf143f
-        }
bf143f
-        return s->start;
bf143f
-    }
bf143f
+        return 0;
bf143f
+   }
bf143f
 
bf143f
     return -1;
bf143f
 }
bf143f
@@ -1679,8 +1671,8 @@ static void dump_init(DumpState *s, int fd, bool has_format,
bf143f
         goto cleanup;
bf143f
     }
bf143f
 
bf143f
-    s->start = get_start_block(s);
bf143f
-    if (s->start == -1) {
bf143f
+    /* Is the filter filtering everything? */
bf143f
+    if (validate_start_block(s) == -1) {
bf143f
         error_setg(errp, QERR_INVALID_PARAMETER, "begin");
bf143f
         goto cleanup;
bf143f
     }
bf143f
diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h
bf143f
index ffc2ea1072..7fce1d4af6 100644
bf143f
--- a/include/sysemu/dump.h
bf143f
+++ b/include/sysemu/dump.h
bf143f
@@ -166,8 +166,6 @@ typedef struct DumpState {
bf143f
     hwaddr memory_offset;
bf143f
     int fd;
bf143f
 
bf143f
-    GuestPhysBlock *next_block;
bf143f
-    ram_addr_t start;
bf143f
     bool has_filter;
bf143f
     int64_t begin;
bf143f
     int64_t length;
bf143f
-- 
bf143f
2.37.3
bf143f