[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 06/18] dump: Rework dump_calculate_size function
From: |
Janosch Frank |
Subject: |
[PATCH v5 06/18] dump: Rework dump_calculate_size function |
Date: |
Thu, 11 Aug 2022 12:10:59 +0000 |
dump_calculate_size() sums up all the sizes of the guest memory
blocks. Since we already have a function that calculates the size of a
single memory block (dump_get_memblock_size()) we can simply iterate
over the blocks and use the function instead of calculating the size
ourselves.
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
dump/dump.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/dump/dump.c b/dump/dump.c
index b043337bc7..d82cc46d7d 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -1548,25 +1548,19 @@ bool qemu_system_dump_in_progress(void)
return (qatomic_read(&state->status) == DUMP_STATUS_ACTIVE);
}
-/* calculate total size of memory to be dumped (taking filter into
- * acoount.) */
+/*
+ * calculate total size of memory to be dumped (taking filter into
+ * account.)
+ */
static int64_t dump_calculate_size(DumpState *s)
{
GuestPhysBlock *block;
- int64_t size = 0, total = 0, left = 0, right = 0;
+ int64_t total = 0;
QTAILQ_FOREACH(block, &s->guest_phys_blocks.head, next) {
- if (dump_has_filter(s)) {
- /* calculate the overlapped region. */
- left = MAX(s->filter_area_begin, block->target_start);
- right = MIN(s->filter_area_begin + s->filter_area_length,
block->target_end);
- size = right - left;
- size = size > 0 ? size : 0;
- } else {
- /* count the whole region in */
- size = (block->target_end - block->target_start);
- }
- total += size;
+ total += dump_filtered_memblock_size(block,
+ s->filter_area_begin,
+ s->filter_area_length);
}
return total;
--
2.34.1
- Re: [PATCH v5 16/18] s390x: Introduce PV query interface, (continued)
- [PATCH v5 17/18] s390x: Add KVM PV dump interface, Janosch Frank, 2022/08/11
- [PATCH v5 18/18] s390x: pv: Add dump support, Janosch Frank, 2022/08/11
- [PATCH v5 02/18] dump: Rename write_elf_loads to write_elf_phdr_loads, Janosch Frank, 2022/08/11
- [PATCH v5 07/18] dump: Split elf header functions into prepare and write, Janosch Frank, 2022/08/11
- [PATCH v5 06/18] dump: Rework dump_calculate_size function,
Janosch Frank <=
- [PATCH v5 04/18] dump: Rework get_start_block, Janosch Frank, 2022/08/11
- [PATCH v5 12/18] dump/dump: Add section string table support, Janosch Frank, 2022/08/11
- [PATCH v5 11/18] dump: Swap segment and section header locations, Janosch Frank, 2022/08/11
- [PATCH v5 08/18] dump: Rename write_elf*_phdr_note to prepare_elf*_phdr_note, Janosch Frank, 2022/08/11
- [PATCH v5 01/18] dump: Replace opaque DumpState pointer with a typed one, Janosch Frank, 2022/08/11