[libvirt] libvirt strange behavior possibly bug with version 0.7.2

Dan Kenigsberg danken at redhat.com
Thu Nov 12 15:54:29 UTC 2009


On Wed, Nov 11, 2009 at 07:48:41PM +0100, Ricardo Mendes wrote:
> >>>import libvirt
> >>>con=libvirt.open('xen:///')
> >> libvirt.getVersion()
> 7002
> >>>dom=con.defineXML('<domain type="xen"><name>rtiago_test2</name><clock offset="utc"/><vcpu>8</vcpu><on_poweroff>restart</on_poweroff><devices><disk device="disk" type="file"><source file="/images/SLC-4-x86.img"/><driver name="file"/><target bus="xen" dev="xvda1"/></disk><console tty="/dev/pts/2" type="pty"><source path="/dev/pts/2"/><target port="0"/></console></devices><on_crash>restart</on_crash><currentMemory>300000</currentMemory><memory>300000</memory><on_reboot>restart</on_reboot><os><kernel>/root/vmlinuz</kernel><initrd>/root/initrd.img</initrd><type>linux</type><root>/dev/xvda1 ro</root><cmdline>rtiago</cmdline></os></domain>')
> 
> >>> dom.create()
> >>>0
> 
> >>> dom.destroy()
> >>> 0
> 
> >>> dom.create()
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "/usr/lib64/python2.4/site-packages/libvirt.py", line 287, in create
> if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
> libvirt.libvirtError: Unknown failure
> 
> Every call to create will raise the same exception, It only works if I do a new connection to the 
> hypervisor. Is there an workaround??

It depends on what you are trying to do. If you have a persistent domain
XML that you want to keep, define it once with defineXML and later get
access to it with conn.lookupByName() or friends, create(), and finally
destroy() it.

Anyway, dom.destroy() makes the dom object useless as the name may
suggest ;-)




More information about the libvir-list mailing list