1 (* Memory info for virtual domains.
2 (C) Copyright 2008 Richard W.M. Jones, Red Hat Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 open Virt_mem_gettext.Gettext
27 let run debug ({ domname = domname; mem = mem }, ksymmap, utsname) =
32 eprintf (f_"%s: could not guess kernel version\n") domname;
34 | Some { kernel_release = v } -> v in
36 if not (Kernel_task_struct.known kernel_version) then (
37 eprintf (f_"%s: %s: unknown kernel version
38 Try a newer version of virt-mem, or if the guest is not from a
39 supported Linux distribution, see this page about adding support:
40 http://et.redhat.com/~rjones/virt-mem/faq.html\n") domname kernel_version;
46 try Ksymmap.find "init_task" ksymmap
48 eprintf (f_"%s: could not find init_task in kernel image\n") domname;
51 (Virt_mem_mmap.unsafe_typed_addr_of_addr addr :
52 [ `task_struct ] Virt_mem_mmap.typed_addr) in
53 Kernel_task_struct.get kernel_version mem addr in
55 printf "comm = %S prio = %Ld state = %Ld static_prio = %Ld tasks'next = %Lx\n"
56 init_task.Kernel_task_struct.comm
57 init_task.Kernel_task_struct.prio
58 init_task.Kernel_task_struct.state
59 init_task.Kernel_task_struct.static_prio
60 (Virt_mem_mmap.unsafe_addr_of_typed_addr init_task.Kernel_task_struct.tasks'next);
64 let summary = s_"list processes in virtual machine"
65 let description = s_"\
66 virt-ps prints a process listing for virtual machines running under
69 let () = Virt_mem.register "ps" summary description ~run