Avoid crashing VM stats thread if domain migrated

This commit is contained in:
Joshua Boniface 2020-06-10 17:10:46 -04:00
parent 2967c97f1a
commit 5871380e1b
1 changed files with 16 additions and 11 deletions

View File

@ -1326,22 +1326,27 @@ def collect_vm_stats(queue):
# Get statistics from any running VMs
for domain in running_domains:
# Get basic information about the VM
tree = ElementTree.fromstring(domain.XMLDesc())
domain_uuid = domain.UUIDString()
domain_name = domain.name()
try:
# Get basic information about the VM
tree = ElementTree.fromstring(domain.XMLDesc())
domain_uuid = domain.UUIDString()
domain_name = domain.name()
# Get all the raw information about the VM
if debug:
print("Getting general statistics for VM {}".format(domain_name))
domain_state, domain_maxmem, domain_mem, domain_vcpus, domain_cputime = domain.info()
domain_memory_stats = domain.memoryStats()
domain_cpu_stats = domain.getCPUStats(True)[0]
except Exception as e:
if debug:
print("Failed getting VM information for {}: {}".format(domain_name, e))
continue
# Ensure VM is present in the domain_list
if domain_uuid not in this_node.domain_list:
this_node.domain_list.append(domain_uuid)
# Get all the raw information about the VM
if debug:
print("Getting general statistics for VM {}".format(domain_name))
domain_state, domain_maxmem, domain_mem, domain_vcpus, domain_cputime = domain.info()
domain_memory_stats = domain.memoryStats()
domain_cpu_stats = domain.getCPUStats(True)[0]
if debug:
print("Getting disk statistics for VM {}".format(domain_name))
domain_disk_stats = []