[Libvir] How to deploy Virtual Machine via libvirt

Hi, I have been using libvirt in my python software for a while just to get deployed domain information. Usually I create a xen configuration file with all the parameters and trigger a "xm create -f file" command to deploy the VM. The problem I have noticed since some time is that as this command is forwarded from Python to Xen, and no error code is returned; I loose track if the domain deployment request fails which is rare but happens. So I thought to use libvirt for virtual machine deployment, and wondered if there are python bindings which I could use. I also try to look up for some kind of small example code to deploy a VM via libvirt on the libvirt site but didn't succeed to find. Can any body help me out with their experience? Thanks, Omer -- ---------------------------------------------------------- CERN – European Organization for Nuclear Research, IT Department, CH-1211 Geneva 23, Switzerland Phone: +41 (0) 22 767 2224 Fax: +41 (0) 22 766 8683 E-mail : Omer.Khalid@cern.ch Homepage: http://cern.ch/Omer.Khalid

Omer Khalid wrote:
Hi,
I have been using libvirt in my python software for a while just to get deployed domain information. Usually I create a xen configuration file with all the parameters and trigger a "xm create -f file" command to deploy the VM.
The problem I have noticed since some time is that as this command is forwarded from Python to Xen, and no error code is returned; I loose track if the domain deployment request fails which is rare but happens.
So I thought to use libvirt for virtual machine deployment, and wondered if there are python bindings which I could use. I also try to look up for some kind of small example code to deploy a VM via libvirt on the libvirt site but didn't succeed to find. Can any body help me out with their experience?
There are low-level calls within libvirt, but if you want to install a new guest (eg. from an ISO) it's best to use virt-install. (http://hg.et.redhat.com/virt/applications/virtinst--devel, http://virt-manager.et.redhat.com/download.html) Code examples can be found in virt-manager. If you already have the guest and just want to start it up, then call virDomainDefineXML followed by virDomainCreate in libvirt. Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

Hi,
If you already have the guest and just want to start it up, then call>> virDomainDefineXML followed by virDomainCreate in libvirt.
What is the XML file format? And for the virDomainCreate function, what would be the domain parameter in Python? Thanks, Omer -- ---------------------------------------------------------- CERN – European Organization for Nuclear Research, IT Department, CH-1211 Geneva 23, Switzerland Phone: +41 (0) 22 767 2224 Fax: +41 (0) 22 766 8683 E-mail : Omer.Khalid@cern.ch Homepage: http://cern.ch/Omer.Khalid

Omer Khalid wrote:
Hi,
If you already have the guest and just want to start it up, then call virDomainDefineXML followed by virDomainCreate in libvirt.
What is the XML file format? And for the virDomainCreate function, what would be the domain parameter in Python?
The XML format is documented here: http://libvirt.org/format.html We can't use the Xen format directly because we have to be portable across different hypervisors. virDomainDefineXML returns a virDomainPtr which you can pass in to virDomainCreate. (Or the equivalent Python functions). Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903
participants (2)
-
Omer Khalid
-
Richard W.M. Jones