Elementary -- and broken -- implementation of virt-mem capture.
authorRichard W.M. Jones <rjones@redhat.com>
Tue, 22 Jul 2008 16:01:56 +0000 (17:01 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Tue, 22 Jul 2008 16:01:56 +0000 (17:01 +0100)
lib/virt_mem_capture.ml

index 413af56..29f7466 100644 (file)
@@ -65,11 +65,25 @@ let rec beforeksyms debug = function
          save_image image filename
       ) images
 
          save_image image filename
       ) images
 
-and save_image (_, domname, arch, mmap) filename =
-  printf (f_"virt-mem capture: saving kernel image from %s to filename %s\n")
-    domname filename;
+and save_image (_, domname, arch, mem) filename =
+  let chan = open_out filename in
 
 
-  assert false
+  (* XXX At the moment, CONTRARY to what it says in the manual, we
+   * are only able to dump out raw data.  We don't save the header,
+   * start address, etc. (which we should do). XXX
+   *)
+  assert (Virt_mem_mmap.nr_mappings mem = 1);
+
+  Virt_mem_mmap.iter mem (
+    fun start size ->
+      let bytes = Virt_mem_mmap.get_bytes mem start (Int64.to_int size) in
+      output_string chan bytes
+  );
+
+  close_out chan;
+
+  printf (f_"virt-mem capture: wrote kernel image from %s to filename %s\n")
+    domname filename
 
 let summary = s_"capture memory image for post-mortem analysis"
 let description = s_"Capture a memory image to a file for later post-mortem
 
 let summary = s_"capture memory image for post-mortem analysis"
 let description = s_"Capture a memory image to a file for later post-mortem