Added range library function.
[virt-top.git] / virt-df / virt_df.mli
index 1b3f6ca..d40c934 100644 (file)
@@ -17,9 +17,9 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *)
 
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *)
 
-(* This module (Virt_df) contains functions and values which are
* used throughout the plug-ins and main code.
- *)
+(** This module (Virt_df) contains functions and values which are
   used throughout the plug-ins and main code.
+*)
 
 val debug : bool
 (** If true, emit logs of debugging information to stderr. *)
 
 val debug : bool
 (** If true, emit logs of debugging information to stderr. *)
@@ -71,7 +71,7 @@ v}
    of the physical devices, partitions and filesystems potentially
    available to the guest.
     
    of the physical devices, partitions and filesystems potentially
    available to the guest.
     
-   Volume management schemes (eg. LVM) register themselves here
+   Volume management schemes (eg. LVM2) register themselves here
    and are called later with "spare" physical devices and partitions
    to see if they contain LVM data.  If this results in additional
    logical volumes then these are checked for filesystems.
    and are called later with "spare" physical devices and partitions
    to see if they contain LVM data.  If this results in additional
    logical volumes then these are checked for filesystems.
@@ -119,6 +119,7 @@ type domain = {
   dom_name : string;                   (** Domain name. *)
   dom_id : int option;                 (** Domain ID (if running). *)
   dom_disks : disk list;               (** Domain disks. *)
   dom_name : string;                   (** Domain name. *)
   dom_id : int option;                 (** Domain ID (if running). *)
   dom_disks : disk list;               (** Domain disks. *)
+  dom_lv_filesystems : filesystem list;        (** Domain LV filesystems. *)
 }
 and disk = {
   d_type : string option;              (** The <disk type=...> *)
 }
 and disk = {
   d_type : string option;              (** The <disk type=...> *)
@@ -131,7 +132,7 @@ and disk = {
 and disk_content =
     [ `Filesystem of filesystem                (** Contains a direct filesystem. *)
     | `Partitions of partitions                (** Contains partitions. *)
 and disk_content =
     [ `Filesystem of filesystem                (** Contains a direct filesystem. *)
     | `Partitions of partitions                (** Contains partitions. *)
-    | `PhysicalVolume of unit          (** Contains an LVM PV. *)
+    | `PhysicalVolume of pv            (** Contains an LVM PV. *)
     | `Unknown                         (** Not probed or unknown. *)
     ]
 and partitions = {
     | `Unknown                         (** Not probed or unknown. *)
     ]
 and partitions = {
@@ -147,7 +148,7 @@ and partition = {
 and partition_status = Bootable | Nonbootable | Malformed | NullEntry
 and partition_content =
     [ `Filesystem of filesystem                (** Filesystem. *)
 and partition_status = Bootable | Nonbootable | Malformed | NullEntry
 and partition_content =
     [ `Filesystem of filesystem                (** Filesystem. *)
-    | `PhysicalVolume of unit          (** Contains an LVM PV. *)
+    | `PhysicalVolume of pv            (** Contains an LVM PV. *)
     | `Unknown                         (** Not probed or unknown. *)
     ]
 and filesystem = {
     | `Unknown                         (** Not probed or unknown. *)
     ]
 and filesystem = {
@@ -163,19 +164,56 @@ and filesystem = {
   fs_inodes_avail : int64;             (** Inodes free (available). *)
   fs_inodes_used : int64;              (** Inodes in use. *)
 }
   fs_inodes_avail : int64;             (** Inodes free (available). *)
   fs_inodes_used : int64;              (** Inodes in use. *)
 }
+and pv = {
+  lvm_plugin_id : lvm_plugin_id;        (** The LVM plug-in which detected
+                                           this. *)
+  pv_uuid : string;                    (** UUID. *)
+}
+and lv = {
+  lv_dev : device;                     (** Logical volume device. *)
+}
+
+and lvm_plugin_id
 
 val string_of_partition : partition -> string
 val string_of_filesystem : filesystem -> string
 (** Convert a partition or filesystem struct to a string (for debugging). *)
 
 
 val string_of_partition : partition -> string
 val string_of_filesystem : filesystem -> string
 (** Convert a partition or filesystem struct to a string (for debugging). *)
 
+(** {2 Plug-in registration functions} *)
+
 val partition_type_register : string -> (device -> partitions) -> unit
 val partition_type_register : string -> (device -> partitions) -> unit
-(** Register a partition probing plugin. *)
+(** Register a partition probing plug-in. *)
 
 val probe_for_partitions : device -> partitions option
 (** Do a partition probe on a device.  Returns [Some partitions] or [None]. *)
 
 val filesystem_type_register : string -> (device -> filesystem) -> unit
 
 val probe_for_partitions : device -> partitions option
 (** Do a partition probe on a device.  Returns [Some partitions] or [None]. *)
 
 val filesystem_type_register : string -> (device -> filesystem) -> unit
-(** Register a filesystem probing plugin. *)
+(** Register a filesystem probing plug-in. *)
 
 
-val probe_for_filesystems : device -> filesystem option
+val probe_for_filesystem : device -> filesystem option
 (** Do a filesystem probe on a device.  Returns [Some filesystem] or [None]. *)
 (** Do a filesystem probe on a device.  Returns [Some filesystem] or [None]. *)
+
+val lvm_type_register :
+  string -> (lvm_plugin_id -> device -> pv) -> (device list -> lv list) -> unit
+(** [lvm_type_register lvm_name probe_fn list_lvs_fn]
+    registers a new LVM type.  [probe_fn] is a function which
+    should probe a device to find out if it contains a PV.
+    [list_lvs_fn] is a function which should take a list of
+    devices (PVs) and construct a list of LV devices.
+*)
+
+val probe_for_pv : device -> pv option
+(** Do a PV probe on a device.  Returns [Some pv] or [None]. *)
+
+val list_lvs : lvm_plugin_id -> device list -> lv list
+(** Construct LV devices from a list of PVs. *)
+
+(** {2 Utility functions} *)
+
+val group_by : ?cmp:('a -> 'a -> int) -> ('a * 'b) list -> ('a * 'b list) list
+(** Group a sorted list of pairs by the first element of the pair. *)
+
+val range : int -> int -> int list
+(** [range a b] returns the list of integers [a <= i < b].
+    If [a >= b] then the empty list is returned.
+*)