virt-manager: ignore VIR_ERR_NO_DOMAIN when a domain was just deleted
Some callbacks could try to access a domain that was just deleted and not accessible anymore. Detect these cases and don't propagate the exception. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
90d5748e09
commit
c1fa43ebb9
|
@ -2637,8 +2637,14 @@ class vmmDetails(vmmGObjectUI):
|
|||
|
||||
# If the dialog is visible, we want to make sure the XML is always
|
||||
# up to date
|
||||
if self.is_visible():
|
||||
self.vm.refresh_xml()
|
||||
try:
|
||||
if self.is_visible():
|
||||
self.vm.refresh_xml()
|
||||
except libvirt.libvirtError, e:
|
||||
if uihelpers.exception_is_libvirt_error(e, "VIR_ERR_NO_DOMAIN"):
|
||||
self.close()
|
||||
return
|
||||
raise
|
||||
|
||||
# Stats page needs to be refreshed every tick
|
||||
if (page == PAGE_DETAILS and
|
||||
|
|
|
@ -411,7 +411,12 @@ class vmmDomain(vmmLibvirtObject):
|
|||
parsexml=xml)
|
||||
|
||||
def _reparse_xml(self, ignore=None):
|
||||
self._guest = self._build_guest(self._get_domain_xml())
|
||||
try:
|
||||
self._guest = self._build_guest(self._get_domain_xml())
|
||||
except libvirt.libvirtError, e:
|
||||
if uihelpers.exception_is_libvirt_error(e, "VIR_ERR_NO_DOMAIN"):
|
||||
return
|
||||
raise
|
||||
|
||||
|
||||
##############################
|
||||
|
@ -1561,14 +1566,12 @@ class vmmDomain(vmmLibvirtObject):
|
|||
"""
|
||||
try:
|
||||
info = self._backend.info()
|
||||
self._update_status(info[0])
|
||||
except libvirt.libvirtError, e:
|
||||
if (hasattr(libvirt, "VIR_ERR_NO_DOMAIN") and
|
||||
e.get_error_code() == getattr(libvirt, "VIR_ERR_NO_DOMAIN")):
|
||||
# Possibly a transient domain that was removed on shutdown
|
||||
if uihelpers.exception_is_libvirt_error(e, "VIR_ERR_NO_DOMAIN"):
|
||||
return
|
||||
raise
|
||||
|
||||
self._update_status(info[0])
|
||||
|
||||
def _update_status(self, status):
|
||||
"""
|
||||
|
|
|
@ -34,6 +34,7 @@ from virtManager.connection import vmmConnection
|
|||
from virtManager.baseclass import vmmGObjectUI
|
||||
from virtManager.graphwidgets import CellRendererSparkline
|
||||
|
||||
import libvirt
|
||||
|
||||
# Number of data points for performance graphs
|
||||
GRAPH_LEN = 40
|
||||
|
@ -891,18 +892,24 @@ class vmmManager(vmmGObjectUI):
|
|||
if self.vm_row_key(vm) not in self.rows:
|
||||
return
|
||||
|
||||
row = self.rows[self.vm_row_key(vm)]
|
||||
row[ROW_NAME] = vm.get_name()
|
||||
row[ROW_STATUS] = vm.run_status()
|
||||
row[ROW_STATUS_ICON] = vm.run_status_icon_name()
|
||||
row[ROW_IS_VM_RUNNING] = vm.is_active()
|
||||
row[ROW_MARKUP] = self._build_vm_markup(row)
|
||||
|
||||
if config_changed:
|
||||
desc = vm.get_description()
|
||||
if not can_set_row_none:
|
||||
desc = desc or ""
|
||||
row[ROW_HINT] = util.xml_escape(desc)
|
||||
try:
|
||||
row = self.rows[self.vm_row_key(vm)]
|
||||
row[ROW_NAME] = vm.get_name()
|
||||
row[ROW_STATUS] = vm.run_status()
|
||||
row[ROW_STATUS_ICON] = vm.run_status_icon_name()
|
||||
row[ROW_IS_VM_RUNNING] = vm.is_active()
|
||||
row[ROW_MARKUP] = self._build_vm_markup(row)
|
||||
|
||||
if config_changed:
|
||||
desc = vm.get_description()
|
||||
if not can_set_row_none:
|
||||
desc = desc or ""
|
||||
row[ROW_HINT] = util.xml_escape(desc)
|
||||
except libvirt.libvirtError, e:
|
||||
if uihelpers.exception_is_libvirt_error(e, "VIR_ERR_NO_DOMAIN"):
|
||||
return
|
||||
raise
|
||||
|
||||
model.row_changed(row.path, row.iter)
|
||||
|
||||
|
|
|
@ -1345,3 +1345,7 @@ def default_uri(always_system=False):
|
|||
else:
|
||||
return "qemu:///session"
|
||||
return None
|
||||
|
||||
def exception_is_libvirt_error(e, error):
|
||||
return (hasattr(libvirt, error) and
|
||||
e.get_error_code() == getattr(libvirt, error))
|
||||
|
|
Loading…
Reference in New Issue