Bug 1309271 - VM creation fails by defineXML(), if not using domain.undefine().
VM creation fails by defineXML(), if not using domain.undefine().
Status: CLOSED NOTABUG
Product: Virtualization Tools
Classification: Community
Component: libvirt-python (Show other bugs)
unspecified
x86_64 Linux
unspecified Severity medium
: ---
: ---
Assigned To: Libvirt Maintainers
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-02-17 05:58 EST by Robert Ozga
Modified: 2016-02-17 06:20 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-02-17 06:20:12 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Robert Ozga 2016-02-17 05:58:03 EST
Description of problem:


By redefine of Domain using the function "defineXML()" from libvirt-module in python, causes that Domain creation fails. 
Domain has current state "shutdown()". In documentation of defineXML() I read:

"...A previous definition for this domain would be overridden if it already exists. ..."

But this works only than, before using the function undefine().


Version-Release number of selected component (if applicable):
libvirt 1.2.2
QEMU 1.2.2
Hypervisor: QEMU 2.0.0


Steps to Reproduce:

1. Define Domain with libvirt.defineXML(xml)
2. Create VM using domain.create()
3. Using domain.shutdown() function
4. Redefine Domain with libvirt.defineXML(xml)
5. New creation using domain.create()

Actual results:
File "/usr/lib/python2.7/dist-packages/libvirt.py", line 3240, in defineXML
    if ret is None:raise libvirtError('virDomainDefineXML() failed', conn=self)

libvirtd.log
------------
2016-02-17 08:41:16.552+0000: 1658: error : virDomainObjListAddLocked:2335 : operation failed: domain 'ecmprt11' already exists with uuid 491cf4b7-7573-4f36-acb8-52dbd9be8e48

Expected results:

Creation of Domain with new definition.

Additional info:

It works for me perfectly, if using between step 3 and 4 additionaly domain.undefine().

Question:
Is it only documentation bug, or I  missunderstood the description of defineXML()?

Many thanks and best regards
Comment 2 Ján Tomko 2016-02-17 06:16:31 EST
libvirt 1.2.2 was never released in RHEL, moving to the upstream tracker.
Comment 3 Jiri Denemark 2016-02-17 06:20:12 EST
It all depends on the XMLs you passed to defineXML (and you didn't attach them).
But in general, redefining a domain is only supported if the name and UUID in the new XML matches the original definition. Beware, if you don't specify any UUID libvirt will automatically assign it to a domain. Thus trying to redefine a domain with an XML which lacks UUID will never work. You should either generate the UUID in your script and use it in both XMLs or fetch it from libvirt after step 1 and use this UUID in step 4.

Note You need to log in before you can comment on or make changes to this bug.