summaryrefslogtreecommitdiffstats
path: root/dump/dump.c
diff options
context:
space:
mode:
authorMarc-André Lureau2022-08-25 10:40:12 +0200
committerMarc-André Lureau2022-10-06 17:31:46 +0200
commit08df343874fcddd260021a04ce3c5a34f2c48164 (patch)
tree569993fde8d571da0aee4d1decbd67d03ade7c4c /dump/dump.c
parentdump: Rename write_elf*_phdr_note to prepare_elf*_phdr_note (diff)
downloadqemu-08df343874fcddd260021a04ce3c5a34f2c48164.tar.gz
qemu-08df343874fcddd260021a04ce3c5a34f2c48164.tar.xz
qemu-08df343874fcddd260021a04ce3c5a34f2c48164.zip
dump: simplify a bit kdump get_next_page()
This should be functionally equivalent, but slightly easier to read, with simplified paths and checks at the end of the function. The following patch is a major rewrite to get rid of the assert(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com>
Diffstat (limited to 'dump/dump.c')
-rw-r--r--dump/dump.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/dump/dump.c b/dump/dump.c
index a905316fe5..b55a497c42 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -1132,17 +1132,11 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
if (!block) {
block = QTAILQ_FIRST(&s->guest_phys_blocks.head);
*blockptr = block;
- assert((block->target_start & ~target_page_mask) == 0);
- assert((block->target_end & ~target_page_mask) == 0);
- *pfnptr = dump_paddr_to_pfn(s, block->target_start);
- if (bufptr) {
- *bufptr = block->host_addr;
- }
- return true;
+ addr = block->target_start;
+ } else {
+ addr = dump_pfn_to_paddr(s, *pfnptr + 1);
}
-
- *pfnptr = *pfnptr + 1;
- addr = dump_pfn_to_paddr(s, *pfnptr);
+ assert(block != NULL);
if ((addr >= block->target_start) &&
(addr + s->dump_info.page_size <= block->target_end)) {
@@ -1154,12 +1148,13 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
if (!block) {
return false;
}
- assert((block->target_start & ~target_page_mask) == 0);
- assert((block->target_end & ~target_page_mask) == 0);
- *pfnptr = dump_paddr_to_pfn(s, block->target_start);
+ addr = block->target_start;
buf = block->host_addr;
}
+ assert((block->target_start & ~target_page_mask) == 0);
+ assert((block->target_end & ~target_page_mask) == 0);
+ *pfnptr = dump_paddr_to_pfn(s, addr);
if (bufptr) {
*bufptr = buf;
}