X-Git-Url: http://git.annexia.org/?p=virt-mem.git;a=blobdiff_plain;f=ps%2Fvirt_ps.ml;h=fe538a9f15b17e3230cce4bce64abe01e4726865;hp=94301ce87e7f23f8ef648569672342f3a000b184;hb=2e1de51e35bea53ebece1a6fd6d6970534f4cbe9;hpb=8a8c035f78a41d68ba62bb35a6fba503481324e2 diff --git a/ps/virt_ps.ml b/ps/virt_ps.ml index 94301ce..fe538a9 100644 --- a/ps/virt_ps.ml +++ b/ps/virt_ps.ml @@ -21,16 +21,28 @@ open Printf 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