On 05/09/2012 11:26 PM, John Wayne wrote:
hi,
i am a bit confused on how to start an inactive domain using the python bindings, any
help would be appreciated.
(inactive as in the domain was created with virConnect.defineXML sometime in the past)
looks like i have to use virDomain.create, however virDomain.create needs a defined
domain xmldesc as a parameter and i am not sure on how to get that
Yes you need to use the create method of virDomain object.
i guess if virConnect.create was happening right after virConnect.defineXML i could get
the return value of virConnect.defineXML and pass that onto virDomain.create.
however, since the domain was created sometime in the past, i am not sure on how to get
the domain ptr which virDomain.create needs
To lookup a previously defined domain, you have to use one of lookup
methods provided by the virConnect object. An example with interactive
python session:
$ python
Python 2.7.2 (default, Nov 3 2011, 10:48:09)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license"
for more information.
>> import libvirt
>> conn = libvirt.open("")
>> dom = conn.lookupByName("Bare")
>> dom.create()
0
>> conn.listDomainsID()
[3]
You also may use lookupByUUID if you prefer UUIDs.
Peter