Avoid crashing VM stats thread if domain migrated
This commit is contained in:
parent
2967c97f1a
commit
5871380e1b
|
@ -1326,21 +1326,26 @@ def collect_vm_stats(queue):
|
||||||
|
|
||||||
# Get statistics from any running VMs
|
# Get statistics from any running VMs
|
||||||
for domain in running_domains:
|
for domain in running_domains:
|
||||||
|
try:
|
||||||
# Get basic information about the VM
|
# Get basic information about the VM
|
||||||
tree = ElementTree.fromstring(domain.XMLDesc())
|
tree = ElementTree.fromstring(domain.XMLDesc())
|
||||||
domain_uuid = domain.UUIDString()
|
domain_uuid = domain.UUIDString()
|
||||||
domain_name = domain.name()
|
domain_name = domain.name()
|
||||||
|
|
||||||
# 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
|
# Get all the raw information about the VM
|
||||||
if debug:
|
if debug:
|
||||||
print("Getting general statistics for VM {}".format(domain_name))
|
print("Getting general statistics for VM {}".format(domain_name))
|
||||||
domain_state, domain_maxmem, domain_mem, domain_vcpus, domain_cputime = domain.info()
|
domain_state, domain_maxmem, domain_mem, domain_vcpus, domain_cputime = domain.info()
|
||||||
domain_memory_stats = domain.memoryStats()
|
domain_memory_stats = domain.memoryStats()
|
||||||
domain_cpu_stats = domain.getCPUStats(True)[0]
|
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)
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
print("Getting disk statistics for VM {}".format(domain_name))
|
print("Getting disk statistics for VM {}".format(domain_name))
|
||||||
|
|
Loading…
Reference in New Issue