diff -u facter-1.5.7/debian/changelog facter-1.5.7/debian/changelog --- facter-1.5.7/debian/changelog +++ facter-1.5.7/debian/changelog @@ -1,3 +1,10 @@ +facter (1.5.7-1ubuntu1.1) maverick-proposed; urgency=low + + * Cherry-picked KVM detection for 'virtual' fact from upstream commit + 62b6773a63bb96273fbc. (LP: #708080). + + -- Oliver Brakmann Thu, 27 Jan 2011 19:03:10 +0100 + facter (1.5.7-1ubuntu1) maverick; urgency=low * Merge from debian testing. Remaining changes: only in patch2: unchanged: --- facter-1.5.7.orig/lib/facter/virtual.rb +++ facter-1.5.7/lib/facter/virtual.rb @@ -34,6 +34,10 @@ end end + if Facter::Util::Virtual.kvm? + result = Facter::Util::Virtual.kvm_type() + end + if result == "physical" output = Facter::Util::Resolution.exec('lspci') if not output.nil? @@ -72,7 +76,7 @@ setcode do case Facter.value(:virtual) - when "xenu", "openvzve", "vmware" + when "xenu", "openvzve", "vmware", "kvm" true else false only in patch2: unchanged: --- facter-1.5.7.orig/lib/facter/util/virtual.rb +++ facter-1.5.7/lib/facter/util/virtual.rb @@ -40,4 +40,21 @@ FileTest.exists?(f) end end + + def self.kvm? + if FileTest.exists?("/proc/cpuinfo") + txt = File.read("/proc/cpuinfo") + return true if txt =~ /QEMU Virtual CPU/ + end + return false + end + + def self.kvm_type + # TODO Tell the difference between kvm and qemu + # Can't work out a way to do this at the moment that doesn't + # require a special binary + "kvm" + end + + end only in patch2: unchanged: --- facter-1.5.7.orig/spec/unit/virtual.rb +++ facter-1.5.7/spec/unit/virtual.rb @@ -48,4 +48,10 @@ Facter.fact(:virtual).stubs(:value).returns("openvzve") Facter.fact(:is_virtual).value.should == true end + + it "should be true when running on kvm" do + Facter.fact(:virtual).stubs(:value).returns("kvm") + Facter.fact(:is_virtual).value.should == true + end + end only in patch2: unchanged: --- facter-1.5.7.orig/spec/unit/util/virtual.rb +++ facter-1.5.7/spec/unit/util/virtual.rb @@ -93,4 +93,11 @@ FileTest.expects(:exists?).with("/proc/xen").returns(false) Facter::Util::Virtual.should_not be_xen end + + it "should detect kvm" do + FileTest.stubs(:exists?).with("/proc/cpuinfo").returns(true) + File.stubs(:read).with("/proc/cpuinfo").returns("model name : QEMU Virtual CPU version 0.9.1\n") + Facter::Util::Virtual.should be_kvm + end + end