(* Memory info for virtual domains. (C) Copyright 2008 Richard W.M. Jones, Red Hat Inc. http://libvirt.org/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *) open Printf open Virt_mem_gettext.Gettext open Virt_mem_utils 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 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_"\ virt-ps prints a process listing for virtual machines running under libvirt." let () = Virt_mem.register "ps" summary description ~run