(** Common types. *) (* 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. Common types. *) (** {2 Kernel symbols} *) type ksym = string (** A kernel symbol. *) module Ksymmap : sig type key = String.t type 'a t = 'a Map.Make(String).t val empty : 'a t val is_empty : 'a t -> bool val add : key -> 'a -> 'a t -> 'a t val find : key -> 'a t -> 'a val remove : key -> 'a t -> 'a t val mem : key -> 'a t -> bool val iter : (key -> 'a -> unit) -> 'a t -> unit val map : ('a -> 'b) -> 'a t -> 'b t val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool end (** Functions available in the map of kernel symbols to addresses. *) type ksymmap = Virt_mem_mmap.addr Ksymmap.t (** Kernel symbol table (map of kernel symbols to addresses). *) (** {2 Kernel memory images and associated metadata} The kimage structure captures everything known about a kernel image, including the source domain details, kernel address, kernel symbols, kernel memory map, and all the kernel structures parsed out of the memory map. *) type utsname = { uts_kernel_name : string; uts_nodename : string; uts_kernel_release : string; uts_kernel_version : string; uts_machine : string; uts_domainname : string; } (** Kernel version, from utsname structure in the kernel. *) type kimage = { dom : Libvirt.ro Libvirt.Domain.t option; (** Domain, if known. *) domname : string; (** Domain name. *) arch : Virt_mem_utils.architecture; (** Architecture, eg. i386. *) kernel_min : Virt_mem_mmap.addr; (** Minimum addr of kernel pointers. *) kernel_max : Virt_mem_mmap.addr; (** Maximum addr of kernel pointers. *) mem : ([`Wordsize], [`Endian], [`HasMapping]) Virt_mem_mmap.t; (** Memory map. *) addrmap : Kernel.addrmap; (** Parsed kernel structures. *) ksyms : ksymmap; (** Kernel symbol table *) have_ksyms : bool; (** True if we were able to load the kernel symbols. *) have_kallsyms : bool; (** True if we were able to load the kallsyms from the kernel. *) utsname : utsname option; (** Kernel version, if we were able to find it. *) have_tasks : bool; (** True if we were able to load the kernel task_struct list. *) have_net_devices : bool; (** True if we were able to load the kernel net_device structures.*) } (** A basic kernel image. *) (** {2 Functions to load kernel memory} *) type load_memory_error = | AddressOutOfRange (** Address not in [kernel_min..kernel_max] *) | DomIsNull (** kimage.dom = None *) exception LoadMemoryError of load_memory_error * string val load_memory : kimage -> Virt_mem_mmap.addr -> int -> kimage (** [load_memory img start size] tries to load [size] bytes from the start address into the memory map. If the memory was loaded previously, then it is not requested again. Note that the memory map may be updated by this, so a modified image structure is returned. This function can raise many different sorts of exceptions and the caller is advised to catch any exceptions and deal with them appropriately. *) val load_static_memory : dom:Libvirt.ro Libvirt.Domain.t -> domname:string -> arch:Virt_mem_utils.architecture -> wordsize:Virt_mem_utils.wordsize -> endian:Bitstring.endian -> kernel_min:Virt_mem_mmap.addr -> kernel_max:Virt_mem_mmap.addr -> Virt_mem_mmap.addr -> int -> kimage (** [load_static_memory ~dom (*...*) start size] creates a [kimage] object, and initializes it with static kernel memory loaded from the [start] address and [size] of [dom]. See also {!load_memory} for exceptions this can raise. *)