VIRT-WHAT(1) | Virtualization Support | VIRT-WHAT(1) |
virt-what - detect if we are running in a virtual machine
virt-what [options]
"virt-what" is a shell script which can be used to detect if the program is running in a virtual machine.
The program prints out a list of "facts" about the virtual machine, derived from heuristics. One fact is printed per line.
If nothing is printed and the script exits with code 0 (no error), then it can mean either that the program is running on bare-metal or the program is running inside a type of virtual machine which we don't know about or cannot detect.
Status: contributed by Weisson.
Note that virt-what will print this fact for baremetal AWS instances, which you might not consider to be true virtualization. In this case other facts (eg. "kvm" or "xen") would not be present.
Status: contributed by Qi Guo, Vitaly Kuznetsov, confirmed by RWMJ.
Status: contributed by Leonardo Brondani Schenkel.
Status: confirmed by Charles Nguyen
Status: confirmed by RWMJ
Status: confirmed by RWMJ
Status: contributed by Adrian Likins.
Status: contributed by Adrian Likins.
This is expected to be a highly unusual configuration - if you see this result you should treat it with suspicion.
Status: not confirmed
Status: confirmed by Thomas Huth
Status: confirmed by RWMJ using a Fedora guest running in z/VM
Status: contributed by Thomas Huth
Status: contributed by Steve Mokris
Status: contributed by Darren Kenny
Status: contributed by Darren Kenny
Status: contributed by Darren Kenny
Status: contributed by Darren Kenny
Status: contributed by Darren Kenny
Status: contributed by BarXX Metin
Status: contributed by BarXX Metin and Elan Ruusamaee
Status: contributed by Marc Fournier
Note that if the hypervisor is using software acceleration you should not see this, but should see the "qemu" fact instead.
Status: confirmed by RWMJ.
Status: contributed by Andrew Jones
Status: confirmed by RWMJ.
Status: contributed by Evgeniy Sokolov
Status: contributed by RWMJ, not confirmed
Status: contributed by Justin Clift
Status: contributed by Jordan Webb
Status: data originally supplied by Jeffrey Scheel, confirmed by Yufang Zhang and RWMJ
Note that for KVM (hardware accelerated) guests you should not see this.
Status: confirmed by RWMJ.
Status: confirmed by RWMJ
Status: confirmed by RWMJ
Status: contributed by Laurent Leonard
Status: data supplied by Bhavna Sarathy, not confirmed
Status: contributed by Laurent Leonard
Status: not confirmed
Status: contributed by Jasper Lievisse Adriaanse.
Status: confirmed by RWMJ
Status: confirmed by RWMJ
Status: confirmed by RWMJ
Status: confirmed by RWMJ
Status: confirmed by RWMJ
Programs that use or wrap "virt-what" should check that the exit status is 0 before they attempt to parse the output of the command.
A non-zero exit status indicates some error, for example, an unrecognized command line argument. If the exit status is non-zero then the output "facts" (if any were printed) cannot be guaranteed and should be ignored.
The exit status does not have anything to do with whether the program is running on baremetal or under virtualization, nor with whether "virt-what" managed detection "correctly" (which is basically unknowable given the large variety of virtualization systems out there and that some systems deliberately emulate others).
"virt-what" is designed so that you can easily run it from other programs or wrap it up in a library.
Your program should check the exit status (see the section above).
Some programming languages (notably Python: issue 1652) erroneously mask the "SIGPIPE" signal and do not restore it when executing subprocesses. "virt-what" is a shell script and some shell commands do not work correctly when you do this. You may see warnings from "virt-what" similar to this:
echo: write error: Broken pipe
The solution is to set the "SIGPIPE" signal handler back to "SIG_DFL" before running "virt-what".
Most of the time, using this program is the wrong thing to do. Instead you should detect the specific features you actually want to use. (As an example, if you wanted to issue Xen hypervisor commands you would look for the "/proc/xen/privcmd" file).
However people keep asking for this, so we provide it. There are a few legitimate uses:
<http://people.redhat.com/~rjones/virt-what/>, <http://www.vmware.com/>, <http://www.microsoft.com/windows/products/winfamily/virtualpc>, <http://xensource.com/>, <http://bellard.org/qemu/>, <http://kvm.qumranet.com/>, <http://openvz.org/>
Richard W.M. Jones <rjones @ redhat . com>
(C) Copyright 2008-2022 Red Hat Inc., <http://people.redhat.com/~rjones/virt-what/>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Bugs can be viewed on the Red Hat Bugzilla page: <https://bugzilla.redhat.com/>.
If you find a bug in virt-what, please follow these steps to report it:
virt-what > virt-what.log 2>&1
and keep virt-what.log. It may contain error messages which you should submit with your bug report.
virt-what --version
Remember to include the version numbers (step 3) and the debug messages file (step 2) and as much other detail as possible.
2022-10-12 | virt-what-1.25 |