From 5b25744ca373f1c16db1a9a74860227c471173b1 Mon Sep 17 00:00:00 2001 From: Vlastimil Holer Date: Thu, 20 Aug 2020 11:25:43 +0200 Subject: [PATCH] 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. --- src/im_mad/remotes/lib/kvm.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/im_mad/remotes/lib/kvm.rb b/src/im_mad/remotes/lib/kvm.rb index 536c7402a7..0402ececd2 100644 --- a/src/im_mad/remotes/lib/kvm.rb +++ b/src/im_mad/remotes/lib/kvm.rb @@ -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)