X-Git-Url: http://git.annexia.org/?p=virt-top.git;a=blobdiff_plain;f=libvirt%2Flibvirt.mli;h=af372aff24ef4d80b1018e13e042bafb87be0c80;hp=0ccaf92f49f0d85d6e84ffbcc8d3fd3e2126dc52;hb=87751781213a1252711b896290a7cc3f07ec0169;hpb=9b4bab1fe618affd0e69666ec6467b414cee325e diff --git a/libvirt/libvirt.mli b/libvirt/libvirt.mli index 0ccaf92..af372af 100644 --- a/libvirt/libvirt.mli +++ b/libvirt/libvirt.mli @@ -242,6 +242,9 @@ v} See also the source of [mlvirsh]. *) +type ('a, 'b) job_t +(** Forward definition of {!Job.t} to avoid recursive module dependencies. *) + (** {3 Connections} *) module Connect : @@ -327,6 +330,15 @@ sig Call {!num_of_defined_networks} first to get a value for [max]. *) + val num_of_pools : [>`R] t -> int + (** Returns the number of storage pools. *) + val list_pools : [>`R] t -> int -> string array + (** Return list of storage pools. *) + val num_of_defined_pools : [>`R] t -> int + (** Returns the number of storage pools. *) + val list_defined_pools : [>`R] t -> int -> string array + (** Return list of storage pools. *) + (* The name of this function is inconsistent, but the inconsistency * is really in libvirt itself. *) @@ -373,8 +385,7 @@ sig *) end (** Module dealing with connections. [Connect.t] is the - connection object. - *) + connection object. *) (** {3 Domains} *) @@ -437,6 +448,8 @@ sig (** Create a new guest domain (not necessarily a Linux one) from the given XML. *) + val create_linux_job : [>`W] Connect.t -> xml -> ([`Domain], rw) job_t + (** Asynchronous domain creation. *) val lookup_by_id : 'a Connect.t -> int -> 'a t (** Lookup a domain by ID. *) val lookup_by_uuid : 'a Connect.t -> uuid -> 'a t @@ -461,10 +474,16 @@ sig (** Resume a domain. *) val save : [>`W] t -> filename -> unit (** Suspend a domain, then save it to the file. *) + val save_job : [>`W] t -> filename -> ([`Domain_nocreate], rw) job_t + (** Asynchronous domain suspend. *) val restore : [>`W] Connect.t -> filename -> unit (** Restore a domain from a file. *) + val restore_job : [>`W] Connect.t -> filename -> ([`Domain_nocreate], rw) job_t + (** Asynchronous domain restore. *) val core_dump : [>`W] t -> filename -> unit (** Force a domain to core dump to the named file. *) + val core_dump_job : [>`W] t -> filename -> ([`Domain_nocreate], rw) job_t + (** Asynchronous core dump. *) val shutdown : [>`W] t -> unit (** Shutdown a domain. *) val reboot : [>`W] t -> unit @@ -506,6 +525,8 @@ sig (** Undefine a domain - removes its configuration. *) val create : [>`W] t -> unit (** Launch a defined (inactive) domain. *) + val create_job : [>`W] t -> ([`Domain_nocreate], rw) job_t + (** Asynchronous launch domain. *) val get_autostart : [>`R] t -> bool (** Get the autostart flag for a domain. *) val set_autostart : [>`W] t -> bool -> unit @@ -551,8 +572,7 @@ sig *) end (** Module dealing with domains. [Domain.t] is the - domain object. - *) + domain object. *) (** {3 Networks} *) @@ -571,12 +591,16 @@ sig (** Lookup a network by UUID string. *) val create_xml : [>`W] Connect.t -> xml -> rw t (** Create a network. *) + val create_xml_job : [>`W] Connect.t -> xml -> ([`Network], rw) job_t + (** Asynchronous create network. *) val define_xml : [>`W] Connect.t -> xml -> rw t (** Define but don't activate a network. *) val undefine : [>`W] t -> unit (** Undefine configuration of a network. *) val create : [>`W] t -> unit (** Start up a defined (inactive) network. *) + val create_job : [>`W] t -> ([`Network_nocreate], rw) job_t + (** Asynchronous start network. *) val destroy : [>`W] t -> unit (** Destroy a network. *) val free : [>`R] t -> unit @@ -608,8 +632,207 @@ sig *) end (** Module dealing with networks. [Network.t] is the - network object. - *) + network object. *) + +(** {3 Storage pools} *) + +module Pool : +sig + type 'rw t + (** Storage pool handle. *) + + type pool_state = Inactive | Building | Running | Degraded + (** State of the storage pool. *) + + type pool_build_flags = New | Repair | Resize + (** Flags for creating a storage pool. *) + + type pool_delete_flags = Normal | Zeroed + (** Flags for deleting a storage pool. *) + + type pool_info = { + state : pool_state; (** Pool state. *) + capacity : int64; (** Logical size in bytes. *) + allocation : int64; (** Currently allocated in bytes. *) + available : int64; (** Remaining free space bytes. *) + } + + val lookup_by_name : 'a Connect.t -> string -> 'a t + val lookup_by_uuid : 'a Connect.t -> uuid -> 'a t + val lookup_by_uuid_string : 'a Connect.t -> string -> 'a t + (** Look up a storage pool by name, UUID or UUID string. *) + + val create_xml : [>`W] Connect.t -> xml -> rw t + (** Create a storage pool. *) + val define_xml : [>`W] Connect.t -> xml -> rw t + (** Define but don't activate a storage pool. *) + val build : [>`W] t -> pool_build_flags -> unit + (** Build a storage pool. *) + val undefine : [>`W] t -> unit + (** Undefine configuration of a storage pool. *) + val create : [>`W] t -> unit + (** Start up a defined (inactive) storage pool. *) + val destroy : [>`W] t -> unit + (** Destroy a storage pool. *) + val delete : [>`W] t -> unit + (** Delete a storage pool. *) + val free : [>`R] t -> unit + (** Free a storage pool object in memory. + + The storage pool object is automatically freed if it is garbage + collected. This function just forces it to be freed right + away. + *) + val refresh : [`R] t -> unit + (** Refresh the list of volumes in the storage pool. *) + + val get_name : [`R] t -> string + (** Name of the pool. *) + val get_uuid : [`R] t -> uuid + (** Get the UUID (as a packed byte array). *) + val get_uuid_string : [`R] t -> string + (** Get the UUID (as a printable string). *) + val get_info : [`R] t -> pool_info + (** Get information about the pool. *) + val get_xml_desc : [`R] t -> xml + (** Get the XML description. *) + val get_autostart : [`R] t -> bool + (** Get the autostart flag for the storage pool. *) + val set_autostart : [`W] t -> bool -> unit + (** Set the autostart flag for the storage pool. *) + + val num_of_volumes : [`R] t -> int + (** Returns the number of storage volumes within the storage pool. *) + val list_volumes : [`R] t -> int -> string array + (** Return list of storage volumes. *) + + external const : [>`R] t -> ro t = "%identity" + (** [const conn] turns a read/write storage pool into a read-only + pool. Note that the opposite operation is impossible. + *) +end + (** Module dealing with storage pools. *) + +(** {3 Storage volumes} *) + +module Volume : +sig + type 'rw t + (** Storage volume handle. *) + + type vol_type = File | Block + (** Type of a storage volume. *) + + type vol_delete_flags = Normal | Zeroed + (** Flags for deleting a storage volume. *) + + type vol_info = { + typ : vol_type; (** Type of storage volume. *) + capacity : int64; (** Logical size in bytes. *) + allocation : int64; (** Currently allocated in bytes. *) + } + + val lookup_by_name : 'a Pool.t -> string -> 'a t + val lookup_by_key : 'a Connect.t -> string -> 'a t + val lookup_by_path : 'a Connect.t -> string -> 'a t + (** Look up a storage volume by name, key or path volume. *) + + val pool_of_volume : 'a t -> 'a Pool.t + (** Get the storage pool containing this volume. *) + + val get_name : [`R] t -> string + (** Name of the volume. *) + val get_key : [`R] t -> string + (** Key of the volume. *) + val get_path : [`R] t -> string + (** Path of the volume. *) + val get_info : [`R] t -> vol_info + (** Get information about the storage volume. *) + val get_xml_desc : [`R] t -> xml + (** Get the XML description. *) + + val create_xml : [`W] Pool.t -> xml -> unit + (** Create a storage volume. *) + val delete : [`W] t -> unit + (** Delete a storage volume. *) + val free : [>`R] t -> unit + (** Free a storage volume object in memory. + + The storage volume object is automatically freed if it is garbage + collected. This function just forces it to be freed right + away. + *) + + external const : [>`R] t -> ro t = "%identity" + (** [const conn] turns a read/write storage volume into a read-only + volume. Note that the opposite operation is impossible. + *) +end + (** Module dealing with storage volumes. *) + +(** {3 Jobs and asynchronous processing} *) + +module Job : +sig + type ('jobclass, 'rw) t = ('jobclass, 'rw) job_t + (** A background asynchronous job. + + Jobs represent a pending operation such as domain creation. + The possible types for a job are: + +{v +(`Domain, `W) Job.t Job creating a new domain +(`Domain_nocreate, `W) Job.t Job acting on an existing domain +(`Network, `W) Job.t Job creating a new network +(`Network_nocreate, `W) Job.t Job acting on an existing network +v} + *) + + type job_type = Bounded | Unbounded + (** A Bounded job is one where we can estimate time to completion. *) + + type job_state = Running | Complete | Failed | Cancelled + (** State of the job. *) + + type job_info = { + typ : job_type; (** Job type (Bounded, Unbounded) *) + state : job_state; (** Job state (Running, etc.) *) + running_time : int; (** Actual running time (seconds) *) + (** The following fields are only available in Bounded jobs: *) + remaining_time : int; (** Estimated time left (seconds) *) + percent_complete : int (** Estimated percent complete *) + } + + val get_info : ('a,'b) t -> job_info + (** Get information and status about the job. *) + + val get_domain : ([`Domain], 'a) t -> 'a Domain.t + (** Get the completed domain from a job. + + You should only call it on a job in state Complete. *) + + val get_network : ([`Network], 'a) t -> 'a Network.t + (** Get the completed network from a job. + + You should only call it on a job in state Complete. *) + + val cancel : ('a,'b) t -> unit + (** Cancel a job. *) + + val free : ('a, [>`R]) t -> unit + (** Free a job object in memory. + + The job object is automatically freed if it is garbage + collected. This function just forces it to be freed right + away. + *) + + external const : ('a, [>`R]) t -> ('a, ro) t = "%identity" + (** [const conn] turns a read/write job into a read-only + job. Note that the opposite operation is impossible. + *) +end + (** Module dealing with asynchronous jobs. *) (** {3 Error handling and exceptions} *) @@ -661,7 +884,14 @@ sig | VIR_ERR_NO_DOMAIN | VIR_ERR_NO_NETWORK | VIR_ERR_INVALID_MAC - (* ^^ NB: If you add a variant you MUST edit libvirt_c.c:MAX_VIR_* *) + | VIR_ERR_AUTH_FAILED + | VIR_ERR_INVALID_STORAGE_POOL + | VIR_ERR_INVALID_STORAGE_VOL + | VIR_WAR_NO_STORAGE + | VIR_ERR_NO_STORAGE_POOL + | VIR_ERR_NO_STORAGE_VOL + (* ^^ NB: If you add a variant you MUST edit + libvirt_c_epilogue.c:MAX_VIR_* *) | VIR_ERR_UNKNOWN of int (** See [] for meaning of these codes. *) @@ -685,7 +915,9 @@ sig | VIR_FROM_OPENVZ | VIR_FROM_XENXM | VIR_FROM_STATS_LINUX - (* ^^ NB: If you add a variant you MUST edit libvirt_c.c: MAX_VIR_* *) + | VIR_FROM_STORAGE + (* ^^ NB: If you add a variant you MUST edit + libvirt_c_epilogue.c: MAX_VIR_* *) | VIR_FROM_UNKNOWN of int (** Subsystem / driver which produced the error. *)