[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 06/17] dump: Rework dump_calculate_size function
From: |
Marc-André Lureau |
Subject: |
Re: [PATCH v4 06/17] dump: Rework dump_calculate_size function |
Date: |
Tue, 26 Jul 2022 15:36:14 +0400 |
On Tue, Jul 26, 2022 at 1:23 PM Janosch Frank <frankja@linux.ibm.com> wrote:
>
> 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 | 20 ++++++--------------
> 1 file changed, 6 insertions(+), 14 deletions(-)
>
> diff --git a/dump/dump.c b/dump/dump.c
> index b59faf9941..57558a4d4b 100644
> --- a/dump/dump.c
> +++ b/dump/dump.c
> @@ -1540,25 +1540,17 @@ 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 (s->has_filter) {
> - /* calculate the overlapped region. */
> - left = MAX(s->begin, block->target_start);
> - right = MIN(s->begin + s->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_get_memblock_size(block, s->begin, s->length);
> }
>
> return total;
> --
> 2.34.1
>
[PATCH v4 03/17] dump: Convert GuestPhysBlock iterators and use the filter functions, Janosch Frank, 2022/07/26
[PATCH v4 01/17] dump: Rename write_elf_loads to write_elf_phdr_loads, Janosch Frank, 2022/07/26
[PATCH v4 06/17] dump: Rework dump_calculate_size function, Janosch Frank, 2022/07/26
- Re: [PATCH v4 06/17] dump: Rework dump_calculate_size function,
Marc-André Lureau <=
[PATCH v4 05/17] dump: Cleanup and annotate guest memory related DumpState struct members, Janosch Frank, 2022/07/26
[PATCH v4 07/17] dump: Allocate header, Janosch Frank, 2022/07/26
[PATCH v4 04/17] dump: Rework get_start_block, Janosch Frank, 2022/07/26
[PATCH v4 08/17] dump: Split write of section headers and data and add a prepare step, Janosch Frank, 2022/07/26