From d61d8c0cd8c10aef2bd7c385ea8587d2d0ca6454 Mon Sep 17 00:00:00 2001 From: Anton Todorov Date: Wed, 8 Jun 2022 15:45:09 +0300 Subject: [PATCH] B #5869: Filter out unsupported CPU models Decided to format it as a patch than an entire rewrite of the probe script. This could be rewritten to populate the models array with the supported only. (cherry picked from commit 7961ae2416814fda0bacf93f5fc52cdc0e779643) --- .../host/system/machines_models.rb | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/im_mad/remotes/kvm-probes.d/host/system/machines_models.rb b/src/im_mad/remotes/kvm-probes.d/host/system/machines_models.rb index 2ce7d523eb..740adf681d 100755 --- a/src/im_mad/remotes/kvm-probes.d/host/system/machines_models.rb +++ b/src/im_mad/remotes/kvm-probes.d/host/system/machines_models.rb @@ -28,7 +28,7 @@ begin models = [] cmd = 'virsh -r -c qemu:///system capabilities' - capabilities, e, s = Open3.capture3(cmd) + capabilities, _e, s = Open3.capture3(cmd) exit(-1) unless s.success? cap_xml = REXML::Document.new(capabilities) @@ -87,7 +87,8 @@ begin end cmd = "virsh -r -c qemu:///system cpu-models #{a}" - cpu_models, e, s = Open3.capture3(cmd) + cpu_models, _e, s = Open3.capture3(cmd) + break unless s.success? cpu_models.each_line do |l| @@ -98,6 +99,21 @@ begin end end + # Filter out the unsupported CPU models + cmd = 'virsh -c qemu:///system domcapabilities kvm' + domcapabilities, _e, s = Open3.capture3(cmd) + + if s.success? + domcap_xml = REXML::Document.new(domcapabilities) + domcap_xml = domcap_xml.root + + cpu_mode_custom_elem = domcap_xml.elements["cpu/mode[@name='custom',@supported='yes']"] + + cpu_mode_custom_elem.elements.each("model[@usable='no']") do |m| + models.delete(m.text) + end if cpu_mode_custom_elem + end + machines.uniq! models.uniq!