virt_ps.cmo: ../lib/virt_mem_utils.cmo ../lib/virt_mem_types.cmi \
- ../lib/virt_mem_gettext.cmo ../lib/virt_mem.cmi
+ ../lib/virt_mem_mmap.cmi ../lib/virt_mem_gettext.cmo ../lib/virt_mem.cmi \
+ ../lib/kernel_task_struct.cmi
virt_ps.cmx: ../lib/virt_mem_utils.cmx ../lib/virt_mem_types.cmx \
- ../lib/virt_mem_gettext.cmx ../lib/virt_mem.cmx
+ ../lib/virt_mem_mmap.cmx ../lib/virt_mem_gettext.cmx ../lib/virt_mem.cmx \
+ ../lib/kernel_task_struct.cmx
open Virt_mem_types
+let run debug ({ domname = domname; mem = mem }, ksymmap, utsname) =
+ try
+ let kernel_version =
+ match utsname with
+ | None ->
+ eprintf (f_"%s: could not guess kernel version\n") domname;
+ raise Exit
+ | Some { kernel_release = v } -> v in
-let run debug ({ mem = mem }, ksymmap, _) =
- ()
+ if not (Kernel_task_struct.known kernel_version) then (
+ eprintf (f_"%s: %s: unknown kernel version
+Try a newer version of virt-mem, or if the guest is not from a
+supported Linux distribution, see this page about adding support:
+ http://et.redhat.com/~rjones/virt-mem/faq.html\n") domname kernel_version;
+ raise Exit
+ );
+
+ let init_task =
+ let addr =
+ try Ksymmap.find "init_task" ksymmap
+ with Not_found ->
+ eprintf (f_"%s: could not find init_task in kernel image\n") domname;
+ raise Exit in
+ let addr =
+ (Virt_mem_mmap.unsafe_typed_addr_of_addr addr :
+ [ `task_struct ] Virt_mem_mmap.typed_addr) in
+ Kernel_task_struct.get kernel_version mem addr in
+
+ printf "comm = %S prio = %Ld state = %Ld static_prio = %Ld tasks'next = %Lx\n"
+ init_task.Kernel_task_struct.comm
+ init_task.Kernel_task_struct.prio
+ init_task.Kernel_task_struct.state
+ init_task.Kernel_task_struct.static_prio
+ (Virt_mem_mmap.unsafe_addr_of_typed_addr init_task.Kernel_task_struct.tasks'next);
+
+ with Exit -> ()
let summary = s_"list processes in virtual machine"
let description = s_"\