Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm writing procedures for configuring VirtualBox support for 64-bit SMP guests, which requires hardware virtualization suppot (VTx/Intel, AMD-V/AMD). I have successfully configured this myself, however I'd like the procedure to be clear.

sed -ne '/^flags/s/^.*: //p' /proc/cpuinfo  |                               
    egrep -q '(vmx|svm)' && echo Has hardware virt || echo No HW virt

... shows if the CPU is capable.

I've still got to go enable the feature in BIOS.

Any way to test from within Linux to see that this is no or not?

Thanks.

(Edit: s/xvm/svm/ in title)

share|improve this question
    
IMHO if you disable the feature in BIOS it should not show up in /proc/cpuinfo –  Nils Jun 21 '12 at 20:06
1  
Provisionally: checking for / attempting to load the kvm and either kvm_intel or kvm_amd kernel modules (as appropriate) should give a pretty clear indication of kernel-level support for hardware virtualization support, though I'd appreciate confirmation of this. –  Dr. Edward Morbius Jun 21 '12 at 22:48
    
No, the CPU flags show up regardless of whether or not they're enabled in the BIOS, it's a chip capability that's accessible by the kernel regardless of BIOS settings. My first time through I verified this. Happened to have an old system config dump that confirmed the kvm modules weren't loaded previously. And I did specifically change the BIOS config from VTx disabled to enabled. –  Dr. Edward Morbius Jun 22 '12 at 6:35
    
I would suggest playing around with dmidecode utility and comparing the output with the setting enabled in the BIOS and also disabled. Unfortunately this method is probably pretty machine specific (e.g. isn't likely to be portable) but may still work for your needs. –  Goyuix Aug 17 '12 at 19:56
    
dmidecode, if it works, isn't going to provide anything that the /proc/cpuinfo files don't have. Given that dmidecode is reading hardware capabilities, not selected BIOS settings or kernel capabilities (inclusive of loaded mondules), it only partially answers the question. The CPU section does include an indicator on my box for "VME" (virtual mode extensions). The BIOS field does NOT contain an indication of present mode (enabled/disabled). Thanks though. –  Dr. Edward Morbius Aug 21 '12 at 18:06

3 Answers 3

It is actually even easier than installing an additional utility - just try to load the relevant kvm module, or check if it is loaded with lsmod. If kvm loads, you're all set, if not - you need to edit the BIOS settings, and perform a cold restart,

share|improve this answer
    
You'll need root access to either load modules or install utilities. And it's possible CPU doesn't support KVM. The utility in question does a nice job of identifying all the bits you need to have things working right, and hinting if you're missing specific ones. I also looked at the MSR tools, but you've got to have documentation for which specific BIOS registers correspond to what features. kvm-ok seems like a least-pain, most-complete, reasonably idiot-proof way to proceed. And if it doesn't work, there's enough detail to sort what you actually do need based on its checks. –  Dr. Edward Morbius Aug 29 '12 at 22:49
    
I can't image how you would manage a hypervisor without root access anyway. Moreover, once you verify the system is in fact VT-enabled, how do you activate the right bits without root? If your CPU doesn't support KVM, you can see that in the cpu flags, and the KVM modules will not load either. What I'm saying is that my solution is simple, available on every distribution and doesn't require anything but the normal prerequisites for a KVM hypervisor –  dyasny Aug 30 '12 at 6:16
    
We're talking past each other. Yes, root is required. If you're at the point of requiring root anyway, and it's trivially easy to install the diagnostic package, and the diagnostic package can point out to you any of the several ways in which your system isn't KVM-capable (some of them fixable without rebooting, some requiring reboot, some not possible at all -- if your CPU lacks the capability), then it makes sense to use kvm-ok. The BIOS settings are the specific bit that kvm-ok is most helpful with. –  Dr. Edward Morbius Aug 30 '12 at 19:25
up vote 1 down vote accepted

The answer comes from the similar question brian99 pointed at.

Install kvm-ok for your distro (from cpu-checker under Debian/Ubuntu). Run kvm-ok which will then check the various prerequisites for hardware virtualization are present:

  • CPU flags
  • BIOS enabled
  • kvm/svm modules present.
  • /dev/kvm present

The output should indicate whether your system is capable, or what capabilities are missing to make so. Exit status should (I haven't confirmed) also be testable (shown below).

Sample run:

$ sudo kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
$ echo $?
0
share|improve this answer

A very similar question was asked a few months ago on askubuntu, and has some possible answers.

share|improve this answer
    
Thanks. Looks like kvm-ok does what I'd like it to. I'm checking the msr-tools method as well. Note that kvm-ok checks BIOS flags, then for the existence of /dev/kvm. MSRs (machine-specific registers) can be used to read BIOS states (TIL ...), including the VT settings. Nice, and thanks. –  Dr. Edward Morbius Aug 28 '12 at 19:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.