domain: _update_status: Only fetch info if required

This commit is contained in:
Cole Robinson 2011-04-09 22:39:34 -04:00
parent aa15d2d4a0
commit 27dcb860eb
1 changed files with 11 additions and 9 deletions

View File

@ -1351,17 +1351,19 @@ class vmmDomain(vmmDomainBase):
self.vcpu_max_count()
def _update_status(self, status=None):
try:
info = self.get_info()
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
return
raise
if status == None:
try:
info = self.get_info()
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
return
raise
status = info[0]
status = self._normalize_status(status)
if status != self.lastStatus: