Path: | lib/facter/virtual.rb |
Last Update: | Sat Feb 23 07:17:42 +0000 2019 |
Fact: virtual
Purpose: Determine if the system‘s hardware is real or virtualized.
Resolution:
Assumes physical unless proven otherwise. On Darwin, use the macosx util module to acquire the SPHardwareDataType and SPEthernetDataType, from which it is possible to determine if the host is a VMware, Parallels, or VirtualBox. This previously used SPDisplaysDataType, which was not reliable if running headless, and also caused lagging issues on actual Macs. On Linux, BSD, Solaris and HPUX: Much of the logic here is obscured behind `util/virtual.rb`, which you can consult directly for more detailed resolution information. The Xen tests in here rely on `/sys` and `/proc,` and check for the presence and contents of files in there. If after all the other tests it's still seen as physical, then it tries to parse the output of the `lspci`, `dmidecode`, and `prtdiag` and parses them for obvious signs of being under VMware, Parallels or VirtualBox. Finally, it checks for the existence of `vmware-vmx`, which would hint that it's VMware.
Caveats:
Many checks rely purely on existence of files.