Product SiteDocumentation Site

3.2. URI formats

Libvirt uses Uniform Resource Identifiers (URIs) to identify hypervisor connections. Both local and remote hypervisors are addressed by libvirt using URIs. The URI scheme and path defines the hypervisor to connect to, while the host part of the URI determines where it is located.

3.2.1. Local URIs

Libvirt local URIs have one of the following forms:
driver:///system
driver:///session
driver+unix:///system
driver+unix:///session
All other uses of the libvirt URIs are considered remote, and behave as such, even if connecting to localhost. See Section 3.2.2, “Remote URIs” for details on remote URIs.
The following drivers are currently supported:

Table 3.1. Supported Drivers

Driver
Description
qemu
For managing qemu and KVM guests
xen
For managing old-style (Xen 3.1 and older) Xen guests
xenapi
For managing new-style Xen guests
uml
For managing UML guests
lxc
For managing Linux Containers
vbox
For managing VirtualBox guests
openvz
For managing OpenVZ containers
esx
For managing VMware ESX guests
gsx
For managing VMware GSX guests
vpx
For managing VMware VPX guests
hyperv
For managing Microsoft Hyper-V guests
The following example shows how to connect to a local QEMU hypervisor using a local URI.

Example 3.5. Connecting to a local QEMU hypervisor

# Example-6.py
#!/usr/bin/env python3
import sys
import libvirt

conn = None
try:
    conn = libvirt.open("qemu:///system")
except libvirt.libvirtError as e:
    print(repr(e), file=sys.stderr)
    exit(1)
conn.close()
exit(0)
Note that not all listed drivers can be used this way. The two notable exceptions are the LXC driver, and client-side-only drivers. Establishing a connection to the LXC driver can be done in the way shown in the next example.

Example 3.6. Connecting to a local LXC hypervisor

# Example-32.py
#!/usr/bin/env python3
import sys
import libvirt

conn = None
try:
    conn = libvirt.open('lxc://')
except libvirt.libvirtError as e:
    print(repr(e), file=sys.stderr)
    exit(1)
conn.close()
exit(0)
Client-side-only drivers include ESX, VPX, GPX and Hyper-V. In contrast to the other drivers, these ones cannot be used with remote transport mechanisms. This means that URIs like the following are invalid:
esx+ssh://example.com
An example of the proper usage of these drivers is given below.

Example 3.7. Connecting to a client-side-only driver

# Example-33.py
#!/usr/bin/env python3
import sys
import libvirt

# use VPX over HTTPS, select ESX server 'srv1' in datacenter 'dc1'
conn = None
try:
    conn = libvirt.open('vpx://example-vcenter.com/dc1/srv1')
except libvirt.libvirtError as e:
    print(repr(e), file=sys.stderr)
    exit(1)
conn.close()
exit(0)