[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 03/17] dump: Convert GuestPhysBlock iterators and use the
From: |
Janis Schoetterl-Glausch |
Subject: |
Re: [PATCH v4 03/17] dump: Convert GuestPhysBlock iterators and use the filter functions |
Date: |
Wed, 27 Jul 2022 20:34:22 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 |
On 7/26/22 11:22, Janosch Frank wrote:
> The iteration over the memblocks is hard to understand so it's about
> time to clean it up. Instead of manually grabbing the next memblock we
> can use QTAILQ_FOREACH to iterate over all memblocks.
>
> Additionally we move the calculation of the offset and length out by
> using the dump_get_memblock_*() functions.
>
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
> ---
> dump/dump.c | 51 +++++++++++----------------------------------------
> 1 file changed, 11 insertions(+), 40 deletions(-)
>
> diff --git a/dump/dump.c b/dump/dump.c
> index 0fd7c76c1e..35b9833a00 100644
> --- a/dump/dump.c
> +++ b/dump/dump.c
> @@ -628,56 +628,27 @@ int64_t dump_get_memblock_start(GuestPhysBlock *block,
> int64_t filter_area_start
> return 0;
> }
>
> -static int get_next_block(DumpState *s, GuestPhysBlock *block)
> -{
> - while (1) {
> - block = QTAILQ_NEXT(block, next);
> - if (!block) {
> - /* no more block */
> - return 1;
> - }
> -
> - s->start = 0;
> - s->next_block = block;
> - if (s->has_filter) {
> - if (block->target_start >= s->begin + s->length ||
> - block->target_end <= s->begin) {
> - /* This block is out of the range */
> - continue;
> - }
> -
> - if (s->begin > block->target_start) {
> - s->start = s->begin - block->target_start;
> - }
> - }
> -
> - return 0;
> - }
> -}
> -
> /* write all memory to vmcore */
> static void dump_iterate(DumpState *s, Error **errp)
> {
> ERRP_GUARD();
> GuestPhysBlock *block;
> - int64_t size;
> + int64_t memblock_size, memblock_start;
>
> - do {
> - block = s->next_block;
> -
> - size = block->target_end - block->target_start;
> - if (s->has_filter) {
> - size -= s->start;
> - if (s->begin + s->length < block->target_end) {
> - size -= block->target_end - (s->begin + s->length);
> - }
> + QTAILQ_FOREACH(block, &s->guest_phys_blocks.head, next) {
> + memblock_start = dump_get_memblock_start(block, s->begin, s->length);
> + if (memblock_start == -1) {
> + continue;
> }
> - write_memory(s, block, s->start, size, errp);
> +
> + memblock_size = dump_get_memblock_size(block, s->begin, s->length);
> +
> + /* Write the memory to file */
> + write_memory(s, block, memblock_start, memblock_size, errp);
> if (*errp) {
> return;
> }
> -
> - } while (!get_next_block(s, block));
> + }
> }
>
> static void create_vmcore(DumpState *s, Error **errp)
- [PATCH v4 00/17] dump: Add arch section and s390x PV dump, Janosch Frank, 2022/07/26
- [PATCH v4 03/17] dump: Convert GuestPhysBlock iterators and use the filter functions, Janosch Frank, 2022/07/26
- Re: [PATCH v4 03/17] dump: Convert GuestPhysBlock iterators and use the filter functions,
Janis Schoetterl-Glausch <=
- [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
- [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