dump: fix Windows dump memory run mapping

We should map and use guest memory run by parts if it can't be mapped as
a whole.
After this patch, continuos guest physical memory blocks which are not
continuos in host virtual address space will be processed correctly.

Signed-off-by: Viktor Prutyanov <viktor.prutyanov@virtuozzo.com>
Message-Id: <1535567456-6904-1-git-send-email-viktor.prutyanov@virtuozzo.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Viktor Prutyanov 2018-08-29 21:30:56 +03:00 committed by Paolo Bonzini
parent c97595d166
commit 7184de64a1
1 changed files with 23 additions and 19 deletions

View File

@ -30,28 +30,32 @@ static size_t write_run(WinDumpPhyMemRun64 *run, int fd, Error **errp)
void *buf; void *buf;
uint64_t addr = run->BasePage << TARGET_PAGE_BITS; uint64_t addr = run->BasePage << TARGET_PAGE_BITS;
uint64_t size = run->PageCount << TARGET_PAGE_BITS; uint64_t size = run->PageCount << TARGET_PAGE_BITS;
uint64_t len = size; uint64_t len, l;
size_t total = 0;
buf = cpu_physical_memory_map(addr, &len, false); while (size) {
if (!buf) { len = size;
error_setg(errp, "win-dump: failed to map run");
return 0; buf = cpu_physical_memory_map(addr, &len, false);
} if (!buf) {
if (len != size) { error_setg(errp, "win-dump: failed to map physical range"
error_setg(errp, "win-dump: failed to map entire run"); " 0x%016" PRIx64 "-0x%016" PRIx64, addr, addr + size - 1);
len = 0; return 0;
goto out_unmap; }
l = qemu_write_full(fd, buf, len);
cpu_physical_memory_unmap(buf, addr, false, len);
if (l != len) {
error_setg(errp, QERR_IO_ERROR);
return 0;
}
addr += l;
size -= l;
total += l;
} }
len = qemu_write_full(fd, buf, len); return total;
if (len != size) {
error_setg(errp, QERR_IO_ERROR);
}
out_unmap:
cpu_physical_memory_unmap(buf, addr, false, len);
return len;
} }
static void write_runs(DumpState *s, WinDumpHeader64 *h, Error **errp) static void write_runs(DumpState *s, WinDumpHeader64 *h, Error **errp)