Change to using internal format for kernel structures.
[virt-mem.git] / lib / virt_mem_types.mli
index 2d6e9ee..9792f03 100644 (file)
@@ -46,7 +46,7 @@ end
 type ksymmap = Virt_mem_mmap.addr Ksymmap.t
   (** Kernel symbol table (map of kernel symbols to addresses). *)
 
-(** {2 Kernel images and associated data} *)
+(** {2 Kernel memory images and associated metadata} *)
 
 type image = {
   dom : Libvirt.ro Libvirt.Domain.t option; (** Domain, if known. *)
@@ -59,38 +59,66 @@ type image = {
 }
   (** A basic kernel image. *)
 
+(** {2 Kernel structures internal format}
+
+    So that we don't need to reiterate over certain important
+    kernel structures in each tool, we convert them into a more
+    convenient internal format.
+
+    See {!Virt_mem_tasks}, {!Virt_mem_net_devices}.
+*)
+
 type utsname = {
-  kernel_name : string;
-  nodename : string;
-  kernel_release : string;
-  kernel_version : string;
-  machine : string;
-  domainname : string;
+  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 task = {
+  task_state : int64;
+  task_prio : int64;
+  task_normal_prio : int64;
+  task_static_prio : int64;
+  task_comm : string;                  (** Short command name. *)
+  task_pid : int64;                    (** Process ID. *)
+}
+  (** Internal version of the kernel [task_struct]. *)
+
+type net_device = {
+  netdev_name : string;                        (** Device name. *)
+  netdev_dev_addr : string;            (** Interface network address. *)
+}
+  (** Internal version of the kernel [net_device] (network device struct). *)
+
 type kdata = {
-  ksyms : ksymmap option;               (** Kernel symbol lookup function. *)
-  utsname : utsname option;            (** Kernel version. *)
-  tasks : Virt_mem_mmap.addr option;    (** Linked list of tasks (processes)
-                                           starting at the address of
-                                           init_task (swapper). *)
-  net_devices : Virt_mem_mmap.addr option; (** Linked list of net devices
-                                              starting at the address of
-                                              dev_base_head. *)
+  ksyms : ksymmap option;       (** Kernel symbol lookup function. *)
+  utsname : utsname option;     (** Kernel version. *)
+  tasks : task list option;     (** List of tasks (processes). *)
+  net_devices : net_device list option; (** List of net devices. *)
 }
   (** Optional data derived from the raw kernel image by the main
       program and passed to the tools' [~run] functions.
 
       What fields get filled in is controlled by the [~needs_*]
       options passed when tools register themselves, and also of
-      course by what we are able to find out about the memory image.
+      course by what we are able to find out about the memory image
+      (see {!Virt_mem.register}).
 
       Note there is significant cost to filling in some of these
       fields.
 *)
 
-(** {2 Kernel structure parsers} *)
+(** {2 Helper declarations for kernel structure parsers}
+
+    The kernel structure parsers (in {!Kernel_task_struct} et al (see
+    [lib/kernel_*])) share a few common types declared here.
+
+    Note that the parsers themselves are generated automatically.
+*)
 
 exception ParseError of string * string * string
   (** Parsing exception raised by [Kernel_*] parser functions.
@@ -104,7 +132,7 @@ type fieldsig = {
 }
   (** Returned by [Kernel_*.field_signature_of_*] functions. *)
 
-(** {2 Load kernel memory} *)
+(** {2 Functions to load kernel memory} *)
 
 type load_memory_error =
   | AddressOutOfRange          (** Address not in [kernel_min..kernel_max] *)