core: fix getting libvirt error code
This commit is contained in:
parent
5a19f37dc0
commit
1ed4a2cbb2
@ -694,7 +694,7 @@ class QubesVm(object):
|
|||||||
try:
|
try:
|
||||||
return self.libvirt_domain.ID()
|
return self.libvirt_domain.ID()
|
||||||
except libvirt.libvirtError as e:
|
except libvirt.libvirtError as e:
|
||||||
if e.err[0] == libvirt.VIR_ERR_NO_DOMAIN:
|
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
|
||||||
return -1
|
return -1
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
@ -736,7 +736,7 @@ class QubesVm(object):
|
|||||||
return 0
|
return 0
|
||||||
return self.libvirt_domain.info()[1]
|
return self.libvirt_domain.info()[1]
|
||||||
except libvirt.libvirtError as e:
|
except libvirt.libvirtError as e:
|
||||||
if e.err[0] == libvirt.VIR_ERR_NO_DOMAIN:
|
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
@ -750,7 +750,7 @@ class QubesVm(object):
|
|||||||
return 0
|
return 0
|
||||||
return self.libvirt_domain.info()[4]
|
return self.libvirt_domain.info()[4]
|
||||||
except libvirt.libvirtError as e:
|
except libvirt.libvirtError as e:
|
||||||
if e.err[0] == libvirt.VIR_ERR_NO_DOMAIN:
|
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
@ -762,7 +762,7 @@ class QubesVm(object):
|
|||||||
try:
|
try:
|
||||||
return self.libvirt_domain.maxMemory()
|
return self.libvirt_domain.maxMemory()
|
||||||
except libvirt.libvirtError as e:
|
except libvirt.libvirtError as e:
|
||||||
if e.err[0] == libvirt.VIR_ERR_NO_DOMAIN:
|
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
@ -791,7 +791,7 @@ class QubesVm(object):
|
|||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
except libvirt.libvirtError as e:
|
except libvirt.libvirtError as e:
|
||||||
if e.err[0] == libvirt.VIR_ERR_NO_DOMAIN:
|
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
@ -830,7 +830,7 @@ class QubesVm(object):
|
|||||||
else:
|
else:
|
||||||
return 'Halted'
|
return 'Halted'
|
||||||
except libvirt.libvirtError as e:
|
except libvirt.libvirtError as e:
|
||||||
if e.err[0] == libvirt.VIR_ERR_NO_DOMAIN:
|
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
|
||||||
return "Halted"
|
return "Halted"
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
@ -866,7 +866,7 @@ class QubesVm(object):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
except libvirt.libvirtError as e:
|
except libvirt.libvirtError as e:
|
||||||
if e.err[0] == libvirt.VIR_ERR_NO_DOMAIN:
|
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
@ -878,7 +878,7 @@ class QubesVm(object):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
except libvirt.libvirtError as e:
|
except libvirt.libvirtError as e:
|
||||||
if e.err[0] == libvirt.VIR_ERR_NO_DOMAIN:
|
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
@ -1305,7 +1305,7 @@ class QubesVm(object):
|
|||||||
try:
|
try:
|
||||||
self.libvirt_domain.undefine()
|
self.libvirt_domain.undefine()
|
||||||
except libvirt.libvirtError as e:
|
except libvirt.libvirtError as e:
|
||||||
if e.err[0] == libvirt.VIR_ERR_NO_DOMAIN:
|
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
|
||||||
# already undefined
|
# already undefined
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@ -1746,7 +1746,7 @@ class QubesVm(object):
|
|||||||
try:
|
try:
|
||||||
nd = vmm.libvirt_conn.nodeDeviceLookupByName('pci_0000_' + pci.replace(':','_').replace('.','_'))
|
nd = vmm.libvirt_conn.nodeDeviceLookupByName('pci_0000_' + pci.replace(':','_').replace('.','_'))
|
||||||
except libvirt.libvirtError as e:
|
except libvirt.libvirtError as e:
|
||||||
if e.err[0] == libvirt.VIR_ERR_NO_NODE_DEVICE:
|
if e.get_error_code() == libvirt.VIR_ERR_NO_NODE_DEVICE:
|
||||||
raise QubesException(
|
raise QubesException(
|
||||||
"PCI device {} does not exist (domain {})".
|
"PCI device {} does not exist (domain {})".
|
||||||
format(pci, self.name))
|
format(pci, self.name))
|
||||||
@ -1755,8 +1755,8 @@ class QubesVm(object):
|
|||||||
try:
|
try:
|
||||||
nd.dettach()
|
nd.dettach()
|
||||||
except libvirt.libvirtError as e:
|
except libvirt.libvirtError as e:
|
||||||
if e.err[0] == libvirt.VIR_ERR_INTERNAL_ERROR:
|
if e.get_error_code() == libvirt.VIR_ERR_INTERNAL_ERROR:
|
||||||
# allready detached
|
# already detached
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
Loading…
Reference in New Issue
Block a user