Skip to content

Commit

Permalink
v2v: Skip vm if XMLDesc() fails
Browse files Browse the repository at this point in the history
The current code assumes that XMLDesc() always succeeds when dealing
foreign vms, which seems to be too optimistic as seen here:

      File "/usr/share/vdsm/v2v.py", line 152, in get_external_vms
        root = ET.fromstring(vm.XMLDesc(0))
      File "/usr/lib64/python2.7/site-packages/libvirt.py", line 478, in XMLDesc
        if ret is None: raise libvirtError ('virDomainGetXMLDesc() failed', dom=self)
    libvirtError: internal error: Invalid or not yet handled value
    'emptyBackingString' for VMX entry 'ide1:0.fileName' for device type
    'cdrom-image'

If XMLDesc() failed, we aborted the entire request, making it impossible
to import good vm if libvirt could not handle another bad vm on the same
server.

Now we log the libvirt error and continue, increasing the chance to
return useful information to engine.

Change-Id: Iab912bc9524b94834d7f54172dd9401ddb4aa45b
Reported-by: Ian Fraser <ian.fraser@asm.org.uk>
Bug-Url: https://bugzilla.redhat.com/1266088
Backport-to: 3.6
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Reviewed-on: https://gerrit.ovirt.org/46634
Continuous-Integration: Jenkins CI
Reviewed-by: Francesco Romani <fromani@redhat.com>
  • Loading branch information
nirs authored and dankenigsberg committed Sep 25, 2015
1 parent 406ca7b commit f8127d8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion vdsm/v2v.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,15 @@ def get_external_vms(uri, username, password):
with closing(conn):
vms = []
for vm in conn.listAllDomains():
root = ET.fromstring(vm.XMLDesc(0))
params = {}
_add_vm_info(vm, params)
try:
xml = vm.XMLDesc(0)
except libvirt.libvirtError as e:
logging.error("error getting domain xml for vm %r: %s",
vm.name(), e)
continue
root = ET.fromstring(xml)
try:
_add_general_info(root, params)
except InvalidVMConfiguration as e:
Expand Down

0 comments on commit f8127d8

Please sign in to comment.