Developer's API Reference guide
Functions
Total number of functions: 16. Functions supported are:get_datetime
()set_logfile
($filename, $maxsize)translate_counter_type
($type)resource_change_counter
($type, $conn, $mem, $inc)get_feature_binary
($name)set_error
($msg)set_error_if_unset
($msg)reset_error
()free_resource
($type, $mem)free_resources_on_connection
($conn)check_resource_allocation
($conn, $type, $memp)count_resources
($type)get_string_from_xpath
($xml, $xpath, $val, $retVal)dec_to_bin
($decimal, $binary)get_subnet_bits
($ip)get_next_free_numeric_value
($res, $xpath)
get_datetime
get_datetime()
[Since version 0.4.2]
Function can be used to get date and time in the `YYYY-mm-dd HH:mm:ss` format, internally used for logging when debug logging is enabled using libvirt_set_logfile() API function..
Returns: | Date/time string in `YYYY-mm-dd HH:mm:ss` format |
set_logfile
set_logfile($filename, $maxsize)
[Since version 0.4.2]
Function to set the log file. You can set log file to NULL to disable logging (default). Useful for debugging purposes..
@filename [string]: | name of log file or NULL to disable |
@maxsize [long]: | integer value of maximum file size, file will be truncated after reaching max file size. Value is set in KiB. |
Returns: | 0 on success, -errno otherwise |
translate_counter_type
translate_counter_type($type)
[Since version 0.4.2]
Function to translate the counter type into the string format.
@type [int]: | integer identifier of the counter type |
Returns: | string interpretation of the counter type |
resource_change_counter
resource_change_counter($type, $conn, $mem, $inc)
[Since version 0.4.2]
Function to increment (inc = 1) / decrement (inc = 0) the resource pointers count including the memory location.
@type [int]: | type of resource (INT_RESOURCE_x defines where x can be { CONNECTION | DOMAIN | NETWORK | NODEDEV | STORAGEPOOL | VOLUME | SNAPSHOT }) |
@conn [virConnectPtr]: | libvirt connection pointer associated with the resource, NULL for libvirt connection objects |
@mem [pointer]: | Pointer to memory location for the resource. Will be converted to appropriate uint for the arch. |
@inc [int/bool]: | Increment the counter (1 = add memory location) or decrement the counter (0 = remove memory location) from entries. |
Returns: | 0 on success, -errno otherwise |
get_feature_binary
get_feature_binary($name)
[Since version 0.4.1(-3)]
Function to get the existing feature binary for the specified feature, e.g. screenshot feature.
@name [string]: | name of the feature to check against |
Returns: | Existing and executable binary name or NULL value |
set_error
set_error($msg)
[Since version 0.4.1(-1)]
This private function is used to set the error string to the library. This string can be obtained by libvirt_get_last_error() from the PHP application..
@msg [string]: | error message string |
Returns: | None |
set_error_if_unset
set_error_if_unset($msg)
[Since version 0.4.2]
Function to set the error only if no other error is set yet.
@msg [string]: | error message string |
Returns: | None |
reset_error
reset_error()
[Since version 0.4.2]
Function to reset the error string set by set_error(). Same as set_error(NULL)..
Returns: | None |
free_resource
free_resource($type, $mem)
[Since version 0.4.2]
Function is used to free the the internal libvirt-php resource identified by it's type and memory location.
@type [int]: | type of the resource to be freed, INT_RESOURCE_x where x can be { CONNECTION | DOMAIN | NETWORK | NODEDEV | STORAGEPOOL | VOLUME | SNAPSHOT } |
@mem [uint]: | memory location of the resource to be freed |
Returns: | None |
free_resources_on_connection
free_resources_on_connection($conn)
[Since version 0.4.2]
Function is used to free all the resources assigned to the connection identified by conn.
@conn [virConnectPtr]: | libvirt connection pointer |
Returns: | None |
check_resource_allocation
check_resource_allocation($conn, $type, $memp)
[Since version 0.4.2]
Function is used to check whether the resource identified by type and memory is allocated for connection conn or not.
@conn [virConnectPtr]: | libvirt connection pointer |
@type [int]: | type of the counter to be checked, please see free_resource() API for possible values |
@memp [pointer]: | pointer to the memory |
Returns: | 1 if resource is allocated, 0 otherwise |
count_resources
count_resources($type)
[Since version 0.4.2]
Function counts the internal resources of module instance.
@type [int]: | integer interpretation of the type, see free_resource() API function for possible values |
Returns: | number of resources already used |
get_string_from_xpath
get_string_from_xpath($xml, $xpath, $val, $retVal)
[Since version 0.4.1(-1)]
Function is used to get the XML xPath expression from the XML document. This can be added to val array if not NULL..
@xml [string]: | input XML document |
@xpath [string]: | xPath expression to find nodes in the XML document |
@val [array]: | Zend array resource to put data to |
@retVal [int]: | return value of the parsing |
Returns: | string containing data of last match found |
dec_to_bin
dec_to_bin($decimal, $binary)
[Since version 0.4.1(-1)]
Function dec_to_bin() converts the unsigned long long decimal (used e.g. for IPv4 address) to it's binary representation.
@decimal [int]: | decimal value to be converted to binary interpretation |
@binary [string]: | output binary string with the binary interpretation |
Returns: | None |
get_subnet_bits
get_subnet_bits($ip)
[Since version 0.4.1(-1)]
Function is used to get number of bits used by subnet determined by IP. Useful to get the CIDR IPv4 address representation.
@ip [string]: | IP address to calculate subnet bits from |
Returns: | number of bits used by subnet mask |
get_next_free_numeric_value
get_next_free_numeric_value($res, $xpath)
[Since version 0.4.2]
Function is used to get the next free slot to be used for adding new NIC device or others.
@res [virDomainPtr]: | standard libvirt domain pointer identified by virDomainPtr |
@xpath [string]: | xPath expression of items to get the next free value of |
Returns: | next free numeric value |