I was wondering if there is a KVM API which allows you to start a KVM virtual machine using a simple command, from a python script.
My Python script performs a series of checks to see whether or not we need to start a specific VM, and I would like to start a VM if I need to.
All I need now is to find the API calls, but I can't find a simple call to start them within the libvirt website. Does anybody know if this is possible?
You can use the create() function from the python API bindings of libvirt:
import libvirt
#connect to hypervisor running on localhost
conn = libvirt.open('qemu:///system')
dom0 = conn.lookupByName('my-vm-1')
dom0.create()
basically the python API is the C API, called by libvirt.C_API_CALL minus the virConnect part or conn.C_API_CALL minus the virDomain part.
see the libvirt API create call and here.