Skip to content

Commit b8330a0

Browse files
authored
B #7081: fix CPU_MODELS on host monitoring (#3723)
1 parent 0baaa4a commit b8330a0

File tree

1 file changed

+7
-24
lines changed

1 file changed

+7
-24
lines changed

src/im_mad/remotes/kvm-probes.d/host/system/machines_models.rb

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
ENV['LANG'] = 'C'
4141
ENV['LC_ALL'] = 'C'
4242

43-
GUEST_ARCHS = ['i686', 'x86_64']
43+
GUEST_ARCHS = ['i686', 'x86_64', 'aarch64']
4444

4545
begin
4646
machines = []
@@ -105,33 +105,16 @@
105105
end
106106
end
107107

108-
cmd = "virsh -r -c qemu:///system cpu-models #{a}"
109-
cpu_models, _e, s = Open3.capture3(cmd)
108+
cmd = "virsh -c qemu:///system domcapabilities --arch #{a}"
109+
domcapabilities, _e, s = Open3.capture3(cmd)
110+
next unless s.success?
110111

111-
break unless s.success?
112-
113-
cpu_models.each_line do |l|
114-
l.chomp!
115-
next if l.empty? || l =~ /all CPU models are accepted/i
116-
117-
models << l
118-
end
119-
end
120-
121-
# Filter out the unsupported CPU models
122-
cmd = 'virsh -c qemu:///system domcapabilities kvm'
123-
domcapabilities, _e, s = Open3.capture3(cmd)
124-
125-
if s.success?
126112
domcap_xml = REXML::Document.new(domcapabilities)
127113
domcap_xml = domcap_xml.root
128114

129-
cpu_mode_xpath = "cpu/mode[@name='custom',@supported='yes']"
130-
cpu_mode_custom_elem = domcap_xml.elements[cpu_mode_xpath]
131-
132-
cpu_mode_custom_elem.elements.each("model[@usable='no']") do |m|
133-
models.delete(m.text)
134-
end if cpu_mode_custom_elem
115+
models = domcap_xml.elements.to_a(
116+
"cpu/mode[@name='custom' and @supported='yes']/model[@usable!='no']"
117+
).map(&:text)
135118
end
136119

137120
machines.uniq!

0 commit comments

Comments
 (0)