[libvirt-users] creating a domain

Doug Goldstein cardoe at cardoe.com
Thu May 10 06:08:29 UTC 2012

On May 9, 2012, at 4:26 PM, John Wayne <m01z04-libvirt at yahoo.com> 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
> 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
> thanks

I think you are confusing methods. libvirt.virDomain.create() just takes a virDomain object while libvirt.virConnect.createXML() takes an xmldesc.

$ python
>>> import libvirt
>>> conn = libvirt.open("qemu:///system")
>>> dom = conn.lookupByName("my-machine")
>>> dom.create()

Should do the trick.

Doug Goldstein

More information about the libvirt-users mailing list