open Virt_mem_gettext.Gettext
open Virt_mem_utils
-open Virt_mem_mmap
+open Virt_mem_types
-let usage = s_"NAME
- virt-ps - process listing command for virtual machines
+open Kernel_task_struct
-SUMMARY
- virt-ps [-options] [domains]
+let run debug { domname = domname; mem = mem } { tasks = tasks } =
+ let tasks = Option.get tasks in
-DESCRIPTION
- virt-ps prints a process listing for virtual machines running under
- libvirt."
+ (* Sort tasks by PID. *)
+ let cmp { task_pid = p1 } { task_pid = p2 } = compare p1 p2 in
+ let tasks = List.sort cmp tasks in
-let debug, images = Virt_mem.start usage
+ printf " PID STAT COMMAND\n";
+
+ List.iter (
+ fun task ->
+ printf "%5Ld %s\n" task.task_pid task.task_comm
+ ) tasks
+
+let summary = s_"list processes in virtual machine"
+let description = s_"\
+virt-ps prints a process listing for virtual machines running under
+libvirt."
+
+let () =
+ Virt_mem.register "ps" summary description ~needs_tasks:true ~run