PHP API Reference guide

Functions

Total number of functions: 81. Functions supported are:

libvirt_get_last_error()
libvirt_connect($url, $readonly, $credentials)
libvirt_node_get_info($conn)
libvirt_get_uri($conn)
libvirt_get_hostname($conn)
libvirt_domain_get_counts($conn)
libvirt_domain_get_autostart($res)
libvirt_domain_set_autostart($res, $flags)
libvirt_domain_is_active($res)
libvirt_domain_lookup_by_name($res, $name)
libvirt_domain_lookup_by_uuid($res, $uuid)
libvirt_domain_lookup_by_uuid_string($res, $uuid)
libvirt_domain_lookup_by_id($conn, $id)
libvirt_domain_get_name($res)
libvirt_domain_get_uuid_string($res)
libvirt_domain_get_uuid($res)
libvirt_domain_get_id($res)
libvirt_domain_get_xml_desc($res)
libvirt_domain_get_info($res)
libvirt_domain_create($res)
libvirt_domain_destroy($res)
libvirt_domain_resume($res)
libvirt_domain_shutdown($res)
libvirt_domain_suspend($res)
libvirt_domain_undefine($res)
libvirt_domain_reboot($res)
libvirt_domain_define_xml($conn, $xml)
libvirt_domain_create_xml($conn, $xml)
libvirt_domain_memory_peek($res)
libvirt_domain_memory_stats($res)
libvirt_domain_update_device($res, $xml, $flags)
libvirt_domain_block_stats($res, $path)
libvirt_domain_get_network_info($res, $mac)
libvirt_domain_get_block_info($res, $dev)
libvirt_domain_xml_xpath($res, $xpath)
libvirt_domain_interface_stats($res, $path)
libvirt_domain_get_connect($res)
libvirt_domain_migrate_to_uri($res, $dest_uri, $flags, $dname, $bandwidth)
libvirt_domain_migrate($res, $dest_conn, $flags, $dname, $bandwidth)
libvirt_domain_get_job_info($res)
libvirt_storagepool_lookup_by_name($res, $name)
libvirt_storagepool_list_volumes($res)
libvirt_storagepool_get_info($res)
libvirt_storagevolume_lookup_by_name($res, $name)
libvirt_storagevolume_get_info($res)
libvirt_storagevolume_get_xml_desc($res)
libvirt_storagevolume_create_xml($res, $xml)
libvirt_storagepool_get_uuid_string($res)
libvirt_storagepool_get_name($res)
libvirt_storagepool_lookup_by_uuid_string($res, $uuid)
libvirt_storagepool_get_xml_desc($res)
libvirt_storagepool_define_xml($res, $xml, $flags)
libvirt_storagepool_undefine($res)
libvirt_storagepool_create($res)
libvirt_storagepool_destroy($res)
libvirt_storagepool_is_active($res)
libvirt_storagepool_get_volume_count($res)
libvirt_storagepool_refresh($res, $flags)
libvirt_storagepool_set_autostart($res, $flags)
libvirt_storagepool_get_autostart($res)
libvirt_list_storagepools($res)
libvirt_list_active_storagepools($res)
libvirt_list_inactive_storagepools($res)
libvirt_list_domains($res)
libvirt_list_domain_resources($res)
libvirt_list_active_domain_ids($res)
libvirt_list_active_domains($res)
libvirt_list_inactive_domains($res)
libvirt_list_networks($res, $flags)
libvirt_list_nodedevs($res, $cap)
libvirt_nodedev_get($res, $name)
libvirt_nodedev_capabilities($res)
libvirt_nodedev_get_xml_desc($res)
libvirt_nodedev_get_information($res)
libvirt_network_get($res, $name)
libvirt_network_get_bridge($res)
libvirt_network_get_active($res)
libvirt_network_get_information($res)
libvirt_network_set_active($res)
libvirt_network_get_xml_desc($res)
libvirt_version($type)
libvirt_check_version($major, $minor, $micro, $type)

libvirt_get_last_error

libvirt_get_last_error()

This function is used to get the last error coming either from libvirt or the PHP extension itself.

Returns: last error string

libvirt_connect

libvirt_connect($url, $readonly, $credentials)

libvirt_connect() is used to connect to the specified libvirt daemon using the specified URL, user can also set the readonly flag and/or set credentials for connection.

@url [string]: URI for connection
@readonly [bool]: flag whether to use read-only connection or not
@credentials [array]: array of connection credentials
Returns: libvirt connection resource

libvirt_node_get_info

libvirt_node_get_info($conn)

Function is used to get the information about host node, mainly total memory installed, total CPUs installed and model information are useful.

@conn [resource]: resource for connection
Returns: array of node information

libvirt_get_uri

libvirt_get_uri($conn)

Function is used to get the connection URI. This is useful to check the hypervisor type of host machine when using "null" uri to libvirt_connect().

@conn [resource]: resource for connection
Returns: connection URI string

libvirt_get_hostname

libvirt_get_hostname($conn)

Function is used to get the hostname of the guest associated with the connection.

@conn [resource]: resource for connection
Returns: hostname of the host node

libvirt_domain_get_counts

libvirt_domain_get_counts($conn)

Function is getting domain counts for all, active and inactive domains.

@conn [resource]: libvirt connection resource from libvirt_connect()
Returns: array of total, active and inactive (but defined) domain counts

libvirt_domain_get_autostart

libvirt_domain_get_autostart($res)

Function is getting the autostart value for the domain.

@res [resource]: libvirt domain resource
Returns: autostart value or -1

libvirt_domain_set_autostart

libvirt_domain_set_autostart($res, $flags)

Function is setting the autostart value for the domain.

@res [resource]: libvirt domain resource
@flags [int]: flag to enable/disable autostart
Returns: TRUE on success, FALSE on error

libvirt_domain_is_active

libvirt_domain_is_active($res)

Function is getting information whether domain identified by resource is active or not.

@res [resource]: libvirt domain resource
Returns: virDomainIsActive() result on the domain

libvirt_domain_lookup_by_name

libvirt_domain_lookup_by_name($res, $name)

Function is used to lookup for domain by it's name.

@res [resource]: libvirt connection resource from libvirt_connect()
@name [string]: domain name to look for
Returns: libvirt domain resource

libvirt_domain_lookup_by_uuid

libvirt_domain_lookup_by_uuid($res, $uuid)

Function is used to lookup for domain by it's UUID in the binary format.

@res [resource]: libvirt connection resource from libvirt_connect()
@uuid [string]: binary defined UUID to look for
Returns: libvirt domain resource

libvirt_domain_lookup_by_uuid_string

libvirt_domain_lookup_by_uuid_string($res, $uuid)

Function is used to get the domain by it's UUID that's accepted in string format.

@res [resource]: libvirt connection resource from libvirt_connect()
@uuid [string]: domain UUID [in string format] to look for
Returns: libvirt domain resource

libvirt_domain_lookup_by_id

libvirt_domain_lookup_by_id($conn, $id)

Function is used to get domain by it's ID, applicable only to running guests.

@conn [resource]: libvirt connection resource from libvirt_connect()
@id [string]: domain id to look for
Returns: libvirt domain resource

libvirt_domain_get_name

libvirt_domain_get_name($res)

Function is used to get domain name from it's resource.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
Returns: domain name string

libvirt_domain_get_uuid_string

libvirt_domain_get_uuid_string($res)

Function is used to get the domain's UUID in string format.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
Returns: domain UUID string

libvirt_domain_get_uuid

libvirt_domain_get_uuid($res)

Function is used to get the domain's UUID in binary format.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
Returns: domain UUID in binary format

libvirt_domain_get_id

libvirt_domain_get_id($res)

Function is used to get the domain's ID, applicable to running guests.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
Returns: running domain ID or -1 if not running

libvirt_domain_get_xml_desc

libvirt_domain_get_xml_desc($res)

Function is used to get the domain's XML description.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
Returns: domain XML description string

libvirt_domain_get_info

libvirt_domain_get_info($res)

Function is used to get the domain's information.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
Returns: domain information array

libvirt_domain_create

libvirt_domain_create($res)

Function is used to create the domain identified by it's resource.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
Returns: result of domain creation (startup)

libvirt_domain_destroy

libvirt_domain_destroy($res)

Function is used to destroy the domain identified by it's resource.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
Returns: result of domain destroy

libvirt_domain_resume

libvirt_domain_resume($res)

Function is used to resume the domain identified by it's resource.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
Returns: result of domain resume

libvirt_domain_shutdown

libvirt_domain_shutdown($res)

Function is used to shutdown the domain identified by it's resource.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
Returns: result of domain shutdown

libvirt_domain_suspend

libvirt_domain_suspend($res)

Function is used to suspend the domain identified by it's resource.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
Returns: result of domain suspend

libvirt_domain_undefine

libvirt_domain_undefine($res)

Function is used to undefine the domain identified by it's resource.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
Returns: result of domain undefine

libvirt_domain_reboot

libvirt_domain_reboot($res)

Function is used to reboot the domain identified by it's resource.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
Returns: result of domain reboot

libvirt_domain_define_xml

libvirt_domain_define_xml($conn, $xml)

Function is used to define the domain from XML string.

@conn [resource]: libvirt connection resource
@xml [string]: XML string to define guest from
Returns: newly defined domain resource

libvirt_domain_create_xml

libvirt_domain_create_xml($conn, $xml)

Function is used to create the domain identified by it's resource.

@conn [resource]: libvirt connection resource
@xml [string]: XML string to create guest from
Returns: newly started/created domain resource

libvirt_domain_memory_peek

libvirt_domain_memory_peek($res)

Function is used to get the domain's memory peek value.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
Returns: domain memory peek

libvirt_domain_memory_stats

libvirt_domain_memory_stats($res)

Function is used to get the domain's memory stats.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
Returns: domain memory stats array

libvirt_domain_update_device

libvirt_domain_update_device($res, $xml, $flags)

Function is used to update the domain's devices from the XML string.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
@xml [string]: XML string for the update
@flags [int]: Flags to update the device (VIR_DOMAIN_DEVICE_MODIFY_CURRENT, VIR_DOMAIN_DEVICE_MODIFY_LIVE, VIR_DOMAIN_DEVICE_MODIFY_CONFIG, VIR_DOMAIN_DEVICE_MODIFY_FORCE)
Returns: 0 on success, -1 on failure

libvirt_domain_block_stats

libvirt_domain_block_stats($res, $path)

Function is used to get the domain's block stats.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
@path [string]: device path to get statistics about
Returns: domain block stats array

libvirt_domain_get_network_info

libvirt_domain_get_network_info($res, $mac)

Function is used to get the domain's network information.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
@mac [string]: mac address of the network device
Returns: domain network info array

libvirt_domain_get_block_info

libvirt_domain_get_block_info($res, $dev)

Function is used to get the domain's block device information.

res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
@dev [string]: device to get block information about
Returns: domain block device information array

libvirt_domain_xml_xpath

libvirt_domain_xml_xpath($res, $xpath)

Function is used to get the result of xPath expression that's run against the domain.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
@xpath [string]: xPath expression to parse against the domain
Returns: result of the expression

libvirt_domain_interface_stats

libvirt_domain_interface_stats($res, $path)

Function is used to get the domain's interface stats.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
@path [string]: path to interface device
Returns: interface stats array

libvirt_domain_get_connect

libvirt_domain_get_connect($res)

Function is used to get the domain's connection resource. This function should *not* be used!.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
Returns: libvirt connection resource

libvirt_domain_migrate_to_uri

libvirt_domain_migrate_to_uri($res, $dest_uri, $flags, $dname, $bandwidth)

Function is used migrate domain to another libvirt daemon specified by it's URI.

res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
@dest_uri [string]: destination URI to migrate to
@flags [int]: migration flags
@dname [string]: domain name to rename domain to on destination side
@bandwidth [int]: migration bandwidth in Mbps
Returns: migration result as boolean

libvirt_domain_migrate

libvirt_domain_migrate($res, $dest_conn, $flags, $dname, $bandwidth)

Function is used migrate domain to another domain.

res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
@dest_conn [string]: destination host connection object
@flags [int]: migration flags
@dname [string]: domain name to rename domain to on destination side
@bandwidth [int]: migration bandwidth in Mbps
Returns: migration result as boolean

libvirt_domain_get_job_info

libvirt_domain_get_job_info($res)

Function is used get job information for the domain.

@res [resource]: libvirt domain resource, e.g. from libvirt_domain_get_by_*()
Returns: job information array

libvirt_storagepool_lookup_by_name

libvirt_storagepool_lookup_by_name($res, $name)

Function is used to lookup for storage pool by it's name.

@res [resource]: libvirt connection resource
@name [string]: storage pool name
Returns: libvirt storagepool resource

libvirt_storagepool_list_volumes

libvirt_storagepool_list_volumes($res)

Function is used to list volumes in the specified storage pool.

@res [resource]: libvirt storagepool resource
Returns: list of storage volume names in the storage pool

libvirt_storagepool_get_info

libvirt_storagepool_get_info($res)

Function is used to get information about the storage pool.

@res [resource]: libvirt storagepool resource
Returns: storage pool information array

libvirt_storagevolume_lookup_by_name

libvirt_storagevolume_lookup_by_name($res, $name)

Function is used to lookup for storage volume by it's name.

@res [resource]: libvirt storagepool resource
@name [string]: name of the storage volume to look for
Returns: libvirt storagevolume resource

libvirt_storagevolume_get_info

libvirt_storagevolume_get_info($res)

Function is used to get the storage volume information.

@res [resource]: libvirt storagevolume resource
Returns: storage volume information

libvirt_storagevolume_get_xml_desc

libvirt_storagevolume_get_xml_desc($res)

Function is used to get the storage volume XML description.

@res [resource]: libvirt storagevolume resource
Returns: storagevolume XML description

libvirt_storagevolume_create_xml

libvirt_storagevolume_create_xml($res, $xml)

Function is used to create the new storage pool and return the handle to new storage pool.

@res [resource]: libvirt storagepool resource
@xml [string]: XML string to create the storage volume in the storage pool
Returns: libvirt storagevolume resource

libvirt_storagepool_get_uuid_string

libvirt_storagepool_get_uuid_string($res)

Function is used to get storage pool by UUID string.

@res [resource]: libvirt storagepool resource
Returns: storagepool UUID string

libvirt_storagepool_get_name

libvirt_storagepool_get_name($res)

Function is used to get storage pool name from the storage pool resource.

@res [resource]: libvirt storagepool resource
Returns: storagepool name string

libvirt_storagepool_lookup_by_uuid_string

libvirt_storagepool_lookup_by_uuid_string($res, $uuid)

Function is used to lookup for storage pool identified by UUID string.

@res [resource]: libvirt connection resource
@uuid [string]: UUID string to look for storagepool
Returns: libvirt storagepool resource

libvirt_storagepool_get_xml_desc

libvirt_storagepool_get_xml_desc($res)

Function is used to get the XML description for the storage pool identified by res.

@res [resource]: libvirt storagepool resource
Returns: XML description

libvirt_storagepool_define_xml

libvirt_storagepool_define_xml($res, $xml, $flags)

Function is used to define the storage pool from XML string and return it's resource.

@res [resource]: libvirt connection resource
@xml [string]: XML string definition of storagepool
@flags [int]: flags to define XML
Returns: libvirt storagepool resource

libvirt_storagepool_undefine

libvirt_storagepool_undefine($res)

Function is used to undefine the storage pool identified by it's resource.

@res [resource]: libvirt storagepool resource
Returns: TRUE if success, FALSE on error

libvirt_storagepool_create

libvirt_storagepool_create($res)

Function is used to create/start the storage pool.

@res [resource]: libvirt storagepool resource
Returns: TRUE if success, FALSE on error

libvirt_storagepool_destroy

libvirt_storagepool_destroy($res)

Function is used to destory the storage pool.

@res [resource]: libvirt storagepool resource
Returns: TRUE if success, FALSE on error

libvirt_storagepool_is_active

libvirt_storagepool_is_active($res)

Function is used to get information whether storage pool is active or not.

@res [resource]: libvirt storagepool resource
Returns: result of virStoragePoolIsActive

libvirt_storagepool_get_volume_count

libvirt_storagepool_get_volume_count($res)

Function is used to get storage volume count in the storage pool.

@res [resource]: libvirt storagepool resource
Returns: number of volumes in the pool

libvirt_storagepool_refresh

libvirt_storagepool_refresh($res, $flags)

Function is used to refresh the storage pool information.

@res [resource]: libvirt storagepool resource
@flags [int]: refresh flags
Returns: TRUE if success, FALSE on error

libvirt_storagepool_set_autostart

libvirt_storagepool_set_autostart($res, $flags)

Function is used to set autostart of the storage pool.

@res [resource]: libvirt storagepool resource
@flags [int]: flags to set autostart
Returns: result on setting storagepool autostart value

libvirt_storagepool_get_autostart

libvirt_storagepool_get_autostart($res)

Function is used to get autostart of the storage pool.

@res [resource]: libvirt storagepool resource
Returns: autostart value for storagepool

libvirt_list_storagepools

libvirt_list_storagepools($res)

Function is used to list storage pools on the connection.

@res [resource]: libvirt connection resource
Returns: libvirt storagepool names array for the connection

libvirt_list_active_storagepools

libvirt_list_active_storagepools($res)

Function is used to list active storage pools on the connection.

@res [resource]: libvirt connection resource
Returns: libvirt storagepool names array for the connection

libvirt_list_inactive_storagepools

libvirt_list_inactive_storagepools($res)

Function is used to list inactive storage pools on the connection.

@res [resource]: libvirt connection resource
Returns: libvirt storagepool names array for the connection

libvirt_list_domains

libvirt_list_domains($res)

Function is used to list domains on the connection.

@res [resource]: libvirt connection resource
Returns: libvirt domain names array for the connection

libvirt_list_domain_resources

libvirt_list_domain_resources($res)

Function is used to list domain resources on the connection.

@res [resource]: libvirt connection resource
Returns: libvirt domain resources array for the connection

libvirt_list_active_domain_ids

libvirt_list_active_domain_ids($res)

Function is used to list active domain IDs on the connection.

@res [resource]: libvirt connection resource
Returns: libvirt active domain ids array for the connection

libvirt_list_active_domains

libvirt_list_active_domains($res)

Function is used to list active domain names on the connection.

@res [resource]: libvirt connection resource
Returns: libvirt active domain names array for the connection

libvirt_list_inactive_domains

libvirt_list_inactive_domains($res)

Function is used to list inactive domain names on the connection.

@res [resource]: libvirt connection resource
Returns: libvirt inactive domain names array for the connection

libvirt_list_networks

libvirt_list_networks($res, $flags)

Function is used to list networks on the connection.

@res [resource]: libvirt connection resource
@flags [int]: flags whether to list active, inactive or all networks (VIR_NETWORKS_{ACTIVE|INACTIVE|ALL} constants)
Returns: libvirt network names array for the connection

libvirt_list_nodedevs

libvirt_list_nodedevs($res, $cap)

Function is used to list node devices on the connection.

@res [resource]: libvirt connection resource
@cap [string]: optional capability string
Returns: libvirt nodedev names array for the connection

libvirt_nodedev_get

libvirt_nodedev_get($res, $name)

Function is used to get the node device by it's name.

@res [resource]: libvirt connection resource
@name [string]: name of the nodedev to get resource
Returns: libvirt nodedev resource

libvirt_nodedev_capabilities

libvirt_nodedev_capabilities($res)

Function is used to list node devices by capabilities.

@res [resource]: libvirt nodedev resource
Returns: nodedev capabilities array

libvirt_nodedev_get_xml_desc

libvirt_nodedev_get_xml_desc($res)

Function is used to get the node device's XML description.

@res [resource]: libvirt nodedev resource
Returns: nodedev XML description

libvirt_nodedev_get_information

libvirt_nodedev_get_information($res)

Function is used to get the node device's information.

@res [resource]: libvirt nodedev resource
Returns: nodedev information array

libvirt_network_get

libvirt_network_get($res, $name)

Function is used to get the network resource from name.

@res [resource]: libvirt connection resource
@name [string]: network name string
Returns: libvirt network resource

libvirt_network_get_bridge

libvirt_network_get_bridge($res)

Function is used to get the bridge associated with the network.

@res [resource]: libvirt network resource
Returns: bridge name string

libvirt_network_get_active

libvirt_network_get_active($res)

Function is used to get the activity state of the network.

@res [resource]: libvirt network resource
Returns: 1 when active, 0 when inactive, FALSE on error

libvirt_network_get_information

libvirt_network_get_information($res)

Function is used to get the network information.

@res [resource]: libvirt network resource
Returns: network information array

libvirt_network_set_active

libvirt_network_set_active($res)

Function is used to set the activity state of the network.

@res [resource]: libvirt network resource
Returns: TRUE if success, FALSE on error

libvirt_network_get_xml_desc

libvirt_network_get_xml_desc($res)

Function is used to get the XML description for the network.

@res [resource]: libvirt network resource
Returns: network XML string

libvirt_version

libvirt_version($type)

Function is used to get libvirt, driver and libvirt-php version numbers. Can be used for information purposes, for version checking please use libvirt_check_version() defined below.

@type [string]: optional type string to identify driver to look at
Returns: libvirt, type (driver) and connector (libvirt-php) version numbers array

libvirt_check_version

libvirt_check_version($major, $minor, $micro, $type)

Function is used to check major, minor and micro (also sometimes called release) versions of libvirt-php or libvirt itself. This could useful when you want your application to support only versions of libvirt or libvirt-php higher than some version specified..

@major [int]: major version number to check for
@minor [int]: minor version number to check for
@micro [int]: micro (also release) version number to check for
@type [int]: type of checking, VIR_VERSION_BINDING to check against libvirt-php binding or VIR_VERSION_LIBVIRT to check against libvirt version
Returns: TRUE if version is equal or higher than required, FALSE if not, FALSE with error [for libvirt_get_last_error()] on unsupported version type check