Caught unknown libvirt errors on getting runtime VM info

In some cases libvirt doesn't report error code at all. This probably
happens in some stage of domain startup/shutdown. Threat this the same
as domain not running.

Fixes QubesOS/qubes-issues#1537
This commit is contained in:
Marek Marczykowski-Górecki 2016-02-06 05:34:22 +01:00
parent 0d31306b90
commit 8ee909f08c
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -779,6 +779,8 @@ class QubesVm(object):
# libxl_domain_info failed - domain no longer exists
elif e.get_error_code() == libvirt.VIR_ERR_INTERNAL_ERROR:
return 0
elif e.get_error_code() is None: # unknown...
return 0
else:
print >>sys.stderr, "libvirt error code: {!r}".format(
e.get_error_code())
@ -798,6 +800,8 @@ class QubesVm(object):
# libxl_domain_info failed - domain no longer exists
elif e.get_error_code() == libvirt.VIR_INTERNAL_ERROR:
return 0
elif e.get_error_code() is None: # unknown...
return 0
else:
print >>sys.stderr, "libvirt error code: {!r}".format(
e.get_error_code())
@ -918,6 +922,11 @@ class QubesVm(object):
except libvirt.libvirtError as e:
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
return False
# libxl_domain_info failed - domain no longer exists
elif e.get_error_code() == libvirt.VIR_INTERNAL_ERROR:
return False
elif e.get_error_code() is None: # unknown...
return False
else:
print >>sys.stderr, "libvirt error code: {!r}".format(
e.get_error_code())
@ -932,6 +941,11 @@ class QubesVm(object):
except libvirt.libvirtError as e:
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
return False
# libxl_domain_info failed - domain no longer exists
elif e.get_error_code() == libvirt.VIR_INTERNAL_ERROR:
return False
elif e.get_error_code() is None: # unknown...
return False
else:
print >>sys.stderr, "libvirt error code: {!r}".format(
e.get_error_code())