The libvirt library exposes a virtualization agnostic interface for controlling the full lifecycle of KVM (and other technologies, such as XEN and LXC) instances. Using the Python bindings we can define, start, destroy, and delete virtual guests, along with anything else the virsh userspace tool implements. In fact, we can see that the virsh command uses various libvirt shared libraries, by running:
root@kvm:~# ldd /usr/bin/virsh | grep libvirt
libvirt-lxc.so.0 => /usr/lib/x86_64-linux-gnu/libvirt-lxc.so.0 (0x00007fd050d88000)
libvirt-qemu.so.0 => /usr/lib/x86_64-linux-gnu/libvirt-qemu.so.0 (0x00007fd050b84000)
libvirt.so.0 => /usr/lib/x86_64-linux-gnu/libvirt.so.0 (0x00007fd050394000)
root@kvm:~#
The Python libvirt module, also provides methods to monitor and report the use of CPU, memory, storage, and network resources on the hypervisor node and other capabilities...