2 (* Memory info command for virtual domains.
3 (C) Copyright 2008 Richard W.M. Jones, Red Hat Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 (** {2 Kernel symbols} *)
26 (** A kernel symbol. *)
30 type 'a t = 'a Map.Make(String).t
32 val is_empty : 'a t -> bool
33 val add : key -> 'a -> 'a t -> 'a t
34 val find : key -> 'a t -> 'a
35 val remove : key -> 'a t -> 'a t
36 val mem : key -> 'a t -> bool
37 val iter : (key -> 'a -> unit) -> 'a t -> unit
38 val map : ('a -> 'b) -> 'a t -> 'b t
39 val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t
40 val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
41 val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
42 val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
44 (** Functions available in the map of kernel symbols to addresses. *)
46 type ksymmap = Virt_mem_mmap.addr Ksymmap.t
47 (** Kernel symbol table (map of kernel symbols to addresses). *)
49 (** {2 Kernel images and associated data} *)
52 dom : Libvirt.ro Libvirt.Domain.t option; (** Domain, if known. *)
53 domname : string; (** Domain name. *)
54 arch : Virt_mem_utils.architecture; (** Architecture, eg. i386. *)
55 mem : ([`Wordsize], [`Endian], [`HasMapping]) Virt_mem_mmap.t;
57 kernel_min : Virt_mem_mmap.addr; (** Minimum addr of kernel pointers. *)
58 kernel_max : Virt_mem_mmap.addr; (** Maximum addr of kernel pointers. *)
60 (** A basic kernel image. *)
65 kernel_release : string;
66 kernel_version : string;
70 (** Kernel version, from utsname structure in the kernel. *)
73 ksyms : ksymmap option; (** Kernel symbol lookup function. *)
74 utsname : utsname option; (** Kernel version. *)
75 tasks : Virt_mem_mmap.addr option; (** Linked list of tasks (processes)
76 starting at the address of
77 init_task (swapper). *)
79 (** Optional data derived from the raw kernel image by the main
80 program and passed to the tools' [~run] functions.
82 What fields get filled in is controlled by the [~needs_*]
83 options passed when tools register themselves, and also of
84 course by what we are able to find out about the memory image.
86 Note there is significant cost to filling in some of these
90 (** {2 Load kernel memory} *)
92 type load_memory_error =
93 | AddressOutOfRange (** Address not in [kernel_min..kernel_max] *)
94 | DomIsNull (** image.dom = None *)
96 exception LoadMemoryError of load_memory_error * string
98 val load_memory : image -> Virt_mem_mmap.addr -> int -> image
99 (** [load_memory img start size] tries to load [size] bytes from
100 the start address into the memory map. If the memory was loaded
101 previously, then it is not requested again.
103 Note that the memory map may be updated by this, so a modified
104 image structure is returned.
106 This function can raise many different sorts of exceptions and
107 the caller is advised to catch any exceptions and deal with them
110 val load_static_memory : dom:Libvirt.ro Libvirt.Domain.t ->
112 arch:Virt_mem_utils.architecture ->
113 wordsize:Virt_mem_utils.wordsize -> endian:Bitstring.endian ->
114 kernel_min:Virt_mem_mmap.addr -> kernel_max:Virt_mem_mmap.addr ->
115 Virt_mem_mmap.addr -> int -> image
116 (** [load_static_memory ~dom (*...*) start size] creates an [image0]
117 object, and initializes it with static kernel memory loaded
118 from the [start] address and [size] of [dom].
120 See also {!load_memory} for exceptions this can raise. *)