summaryrefslogtreecommitdiffstats
path: root/lib/facter
diff options
context:
space:
mode:
authorJiri Kubicek <jiri.kubicek@kraxnet.cz>2010-07-26 00:08:16 +0200
committerJiri Kubicek <jiri.kubicek@kraxnet.cz>2010-07-26 00:36:28 +0200
commitfaaa169d73e5132b7f2ea491461690324c1133ab (patch)
tree3b37feb83a8c12fe268a2a6c1f7441ca78ea6c3d /lib/facter
parent82286e44cf91e2e8305ba03e7e183ff98593099f (diff)
downloadfacter-faaa169d73e5132b7f2ea491461690324c1133ab.tar.gz
facter-faaa169d73e5132b7f2ea491461690324c1133ab.tar.xz
facter-faaa169d73e5132b7f2ea491461690324c1133ab.zip
Fix #4352 - Support for detecting KVM virtuals on FreeBSD
There was no support for detecting FreeBSD running in KVM as a virtual in facter. This patch detects KVM by getting "hw.model" kernel state via sysctl. Jails running in KVM are also correctly detected as "jail" not "kvm". Signed-off-by: Jiri Kubicek <jiri.kubicek@kraxnet.cz>
Diffstat (limited to 'lib/facter')
-rw-r--r--lib/facter/util/virtual.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/facter/util/virtual.rb b/lib/facter/util/virtual.rb
index 900375f..2d18c33 100644
--- a/lib/facter/util/virtual.rb
+++ b/lib/facter/util/virtual.rb
@@ -43,11 +43,12 @@ module Facter::Util::Virtual
end
def self.kvm?
- if FileTest.exists?("/proc/cpuinfo")
- txt = File.read("/proc/cpuinfo")
- return true if txt =~ /QEMU Virtual CPU/
+ txt = if FileTest.exists?("/proc/cpuinfo")
+ File.read("/proc/cpuinfo")
+ elsif Facter.value(:kernel)=="FreeBSD"
+ Facter::Util::Resolution.exec("/sbin/sysctl -n hw.model")
end
- return false
+ (txt =~ /QEMU Virtual CPU/) ? true : false
end
def self.kvm_type