[libvirt] creating domain with same name and different UUID

Hello, I have small problem with libvirt, which I'm trying to solve... I'm using defineXML function to create KVM machines. from time to time, I need to delete the domain, and create new one with the same name. every newly created domain has new UUID. and this is where the problem starts, defineXML function documentation tells that previous definition domain would be overriden if it already exists, but it ends up with following error: libvir: Domain Config error : operation failed: domain 'vmnci01' already exists with uuid 8d9795b3-461e-11df-9882-00304834195b Traceback (most recent call last): File "/usr/libexec/vm2.py", line 173, in ? vm.start() File "/usr/libexec/vmmain2.py", line 433, in start self.dom = self.svconn.defineXML(self.xmldef.vm.domain.xml()) File "/usr/lib64/python2.4/site-packages/libvirt.py", line 1120, in defineXML if ret is None:raise libvirtError('virDomainDefineXML() failed', conn=self) libvirt.libvirtError: operation failed: domain 'vmnci01' already exists with uuid 8d9795b3-461e-11df-9882-00304834195b If I try to undefine domain first, it still seems to behave weirdly: [root@vbox1 libexec]# vm __start__ vmnci01 undefining domain... Starting HVM guest vmnci01 libvir: QEMU error : Domain not found: no domain with matching uuid '8d9795b3-461e-11df-9882-00304834195b' Traceback (most recent call last): File "/usr/libexec/vm2.py", line 173, in ? vm.start() File "/usr/libexec/vmmain2.py", line 436, in start self.dom.create() File "/usr/lib64/python2.4/site-packages/libvirt.py", line 300, in create if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self) libvirt.libvirtError: Domain not found: no domain with matching uuid '8d9795b3-461e-11df-9882-00304834195b' Could anybody help me with this? Am I doing something wrong? Currently, I'm using libvirt-0.7.6 Thanks a lot in advance! with best regards nik A -- ------------------------------------- Ing. Nikola CIPRICH LinuxBox.cz, s.r.o. 28. rijna 168, 709 01 Ostrava tel.: +420 596 603 142 fax: +420 596 621 273 mobil: +420 777 093 799 www.linuxbox.cz mobil servis: +420 737 238 656 email servis: servis@linuxbox.cz -------------------------------------

On Mon, Apr 12, 2010 at 12:58:08PM +0200, Nikola Ciprich wrote:
Hello, I have small problem with libvirt, which I'm trying to solve... I'm using defineXML function to create KVM machines. from time to time, I need to delete the domain, and create new one with the same name. every newly created domain has new UUID. and this is where the problem starts, defineXML function documentation tells that previous definition domain would be overriden if it already exists, but it ends up with following error:
libvir: Domain Config error : operation failed: domain 'vmnci01' already exists with uuid 8d9795b3-461e-11df-9882-00304834195b Traceback (most recent call last): File "/usr/libexec/vm2.py", line 173, in ? vm.start() File "/usr/libexec/vmmain2.py", line 433, in start self.dom = self.svconn.defineXML(self.xmldef.vm.domain.xml()) File "/usr/lib64/python2.4/site-packages/libvirt.py", line 1120, in defineXML if ret is None:raise libvirtError('virDomainDefineXML() failed', conn=self) libvirt.libvirtError: operation failed: domain 'vmnci01' already exists with uuid 8d9795b3-461e-11df-9882-00304834195b
If I try to undefine domain first, it still seems to behave weirdly: [root@vbox1 libexec]# vm __start__ vmnci01 undefining domain... Starting HVM guest vmnci01 libvir: QEMU error : Domain not found: no domain with matching uuid '8d9795b3-461e-11df-9882-00304834195b' Traceback (most recent call last): File "/usr/libexec/vm2.py", line 173, in ? vm.start() File "/usr/libexec/vmmain2.py", line 436, in start self.dom.create() File "/usr/lib64/python2.4/site-packages/libvirt.py", line 300, in create if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self) libvirt.libvirtError: Domain not found: no domain with matching uuid '8d9795b3-461e-11df-9882-00304834195b' Could anybody help me with this? Am I doing something wrong?
The old python object representing the original virDomainPtr is likely not yet garbage collected. Python is rather painful in this respect, because even assigning None to the object won't immediately garbage collect it sometimes. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (2)
-
Daniel P. Berrange
-
Nikola Ciprich