Browse Source

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>
tags/v3.1.0-rc0
Viktor Prutyanov 9 months ago
parent
commit
7184de64a1
1 changed files with 22 additions and 18 deletions
  1. 22
    18
      win_dump.c

+ 22
- 18
win_dump.c View File

@@ -30,28 +30,32 @@ static size_t write_run(WinDumpPhyMemRun64 *run, int fd, Error **errp)
30 30
     void *buf;
31 31
     uint64_t addr = run->BasePage << TARGET_PAGE_BITS;
32 32
     uint64_t size = run->PageCount << TARGET_PAGE_BITS;
33
-    uint64_t len = size;
33
+    uint64_t len, l;
34
+    size_t total = 0;
34 35
 
35
-    buf = cpu_physical_memory_map(addr, &len, false);
36
-    if (!buf) {
37
-        error_setg(errp, "win-dump: failed to map run");
38
-        return 0;
39
-    }
40
-    if (len != size) {
41
-        error_setg(errp, "win-dump: failed to map entire run");
42
-        len = 0;
43
-        goto out_unmap;
44
-    }
36
+    while (size) {
37
+        len = size;
45 38
 
46
-    len = qemu_write_full(fd, buf, len);
47
-    if (len != size) {
48
-        error_setg(errp, QERR_IO_ERROR);
49
-    }
39
+        buf = cpu_physical_memory_map(addr, &len, false);
40
+        if (!buf) {
41
+            error_setg(errp, "win-dump: failed to map physical range"
42
+                             " 0x%016" PRIx64 "-0x%016" PRIx64, addr, addr + size - 1);
43
+            return 0;
44
+        }
45
+
46
+        l = qemu_write_full(fd, buf, len);
47
+        cpu_physical_memory_unmap(buf, addr, false, len);
48
+        if (l != len) {
49
+            error_setg(errp, QERR_IO_ERROR);
50
+            return 0;
51
+        }
50 52
 
51
-out_unmap:
52
-    cpu_physical_memory_unmap(buf, addr, false, len);
53
+        addr += l;
54
+        size -= l;
55
+        total += l;
56
+    }
53 57
 
54
-    return len;
58
+    return total;
55 59
 }
56 60
 
57 61
 static void write_runs(DumpState *s, WinDumpHeader64 *h, Error **errp)

Loading…
Cancel
Save