B #5041: Avoid gathering KVM I/O statistics for saving VMs (#160)

Note: Branch 5.12 didn't really suffer from the similar problem in 5.10,
as here "saving" reason is considered as UNKNOWN state for which we
don't collect the I/O statistics. This change only aligns with previous
behaviour to consider "saving" as RUNNING state, and explicitly lists
few RUNNING reasons (including new "saving") to skip monitoring for.

It's more a polishment, than a real bugfix.

(cherry picked from commit 5b25744ca3)
This commit is contained in:
Vlastimil Holer authored and Ruben S. Montero committed 2020-08-20 11:26:39 +02:00
1 parent 058ab946f2
commit ddb4067fbd
1 file changed
+6 -1
+6 -1
View File
@@ -261,6 +261,7 @@ class Domain < BaseDomain
'pmsuspended' => 'SUSPENDED',
'paused' => {
'migrating' => 'RUNNING',
'saving' => 'RUNNING',
'starting up' => 'RUNNING',
'booted' => 'RUNNING',
'I/O error' => 'FAILURE',
@@ -272,6 +273,9 @@ class Domain < BaseDomain
}
}
# List of domain state reasons (for RUNNING) when to skip I/O monitoring
REASONS_SKIP_IO = ['migrating', 'starting up', 'saving']
# Get the I/O stats of the domain as provided by Libvirt command domstats
# The metrics are aggregated for all DIKS and NIC
def io_stats
@@ -282,7 +286,8 @@ class Domain < BaseDomain
@vm[:diskrdiops] = 0
@vm[:diskwriops] = 0
return if @vm[:state] != 'RUNNING' || @vm[:reason] == 'migrating'
return if @vm[:state] != 'RUNNING' ||
REASONS_SKIP_IO.include?(@vm[:reason])
vm_stats, _e, s = KVM.virsh(:domstats, @name)