+++ /dev/null
-(* Memory info command 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
-
-(*
-open Kernel_task_struct
-
-let max_tasks = 10000
-
-let find_tasks debug image ksymmap kernel_version =
- if not (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")
- image.domname kernel_version;
- image, None
- ) else (
- let size = task_struct_size kernel_version in
-
- let init_task_addr =
- try Some (Ksymmap.find "init_task" ksymmap)
- with Not_found ->
- eprintf (f_"%s: could not find init_task in kernel image\n")
- image.domname;
- None in
- match init_task_addr with
- | None -> image, None
- | Some init_task_addr ->
- let { field_offset = offset } =
- field_signature_of_task_struct_tasks'next kernel_version in
-
- let lh = Virt_mem_list_head.create_base image init_task_addr offset in
- let image, lh = Virt_mem_list_head.load_all lh size in
-
- let tasks, _ =
- Virt_mem_list_head.fold lh ([], 0) (
- fun (tasks, i) addr ->
- if i > max_tasks then
- failwith (sprintf (f_"%s: too many tasks") image.domname);
-
- let task = get_task_struct kernel_version image.mem addr in
- let tasks = task :: tasks in
- (tasks, i+1)
- ) in
-
- (* Convert to the internal format. *)
- let tasks = List.rev_map (
- fun task ->
- { task_state = task.task_struct_state;
- task_prio = task.task_struct_prio;
- task_normal_prio = task.task_struct_normal_prio;
- task_static_prio = task.task_struct_static_prio;
- task_comm = truncate_c_string task.task_struct_comm;
- task_pid = task.task_struct_pid }
- ) tasks in
-
- image, Some tasks
- )
-*)