Skip to content

Commit d0bec00

Browse files
committed
Merge pull request #846 from ScottGarman/kvmfix-stable
(FACT-797) Fix KVM detection on Linux
2 parents 111798c + ac10fd1 commit d0bec00

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Diff for: lib/facter/virtual.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
next "xenhvm" if lines.any? {|l| l =~ /XenSource/ }
150150
next "hyperv" if lines.any? {|l| l =~ /Microsoft Corporation Hyper-V/ }
151151
next "gce" if lines.any? {|l| l =~ /Class 8007: Google, Inc/ }
152-
next "kvm" if lines.any? {|l| l =~ /virtio/ }
152+
next "kvm" if lines.any? {|l| l =~ /virtio/i }
153153
end
154154

155155
# Parse dmidecode

Diff for: spec/unit/virtual_spec.rb

+5
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@
210210
Facter.fact(:virtual).value.should == "hyperv"
211211
end
212212

213+
it "should be kvm with virtio device lspci 2>/dev/null" do
214+
Facter::Util::Virtual.expects(:lspci).returns("00:03.0 Ethernet controller: Red Hat, Inc Virtio network device")
215+
Facter.fact(:virtual).value.should == "kvm"
216+
end
217+
213218
context "In a Linux Container (LXC)" do
214219
before :each do
215220
Facter.fact(:kernel).stubs(:value).returns("Linux")

0 commit comments

Comments
 (0)