5 virt-what - detect if we are running in a virtual machine
13 C<virt-what> is a shell script which can be used to detect if the
14 program is running in a virtual machine.
16 The program prints out a list of "facts" about the virtual machine,
17 derived from heuristics. One fact is printed per line.
19 If nothing is printed and the script exits with code 0 (no error),
20 then it can mean I<either> that the program is running on bare-metal
21 I<or> the program is running inside a type of virtual machine which we
22 don't know about or cannot detect.
30 This is a Docker container.
32 Status: confirmed by Charles Nguyen
36 This is Microsoft Hyper-V hypervisor.
38 Status: confirmed by RWMJ
42 This is an IBM SystemZ (or other S/390) hardware partitioning system.
43 Additional facts listed below may also be printed.
45 =item B<ibm_systemz-direct>
47 This is Linux running directly on a IBM SystemZ hardware partitioning
50 This is expected to be a highly unusual configuration - if
51 you see this result you should treat it with suspicion.
55 =item B<ibm_systemz-lpar>
57 This is Linux running directly on an LPAR on an IBM SystemZ
58 hardware partitioning system.
62 =item B<ibm_systemz-zvm>
64 This is a z/VM guest running in an LPAR on an IBM SystemZ
65 hardware partitioning system.
67 Status: confirmed by RWMJ using a Fedora guest running in z/VM
69 =item B<linux_vserver>
71 This is printed for backwards compatibility with older virt-what which
72 could not distinguish between a Linux VServer container guest and
75 =item B<linux_vserver-guest>
77 This process is running in a Linux VServer container.
79 Status: contributed by Barış Metin
81 =item B<linux_vserver-host>
83 This process is running as the Linux VServer host (VxID 0).
85 Status: contributed by Barış Metin and Elan Ruusamäe
89 This process is running in a Linux LXC container.
91 Status: contributed by Marc Fournier
95 This guest is running on the KVM hypervisor using hardware
98 Note that if the hypervisor is using software acceleration
99 you should I<not> see this, but should see the C<qemu> fact
102 Status: confirmed by RWMJ.
106 This guest is running on the KVM hypervisor using hardware
107 acceleration, and the userspace component of the hypervisor
108 is lkvm (a.k.a kvmtool).
110 Status: contributed by Andrew Jones
114 The guest appears to be running inside an OpenVZ or Virtuozzo
117 Status: contributed by Evgeniy Sokolov
121 The guest is running inside Parallels Virtual Platform
122 (Parallels Desktop, Parallels Server).
124 Status: contributed by Justin Clift
126 =item B<powervm_lx86>
128 The guest is running inside IBM PowerVM Lx86 Linux/x86 emulator.
130 Status: data originally supplied by Jeffrey Scheel, confirmed by
131 Yufang Zhang and RWMJ
135 This is QEMU hypervisor using software emulation.
137 Note that for KVM (hardware accelerated) guests you should I<not> see
140 Status: confirmed by RWMJ.
144 This is a User-Mode Linux (UML) guest.
146 Status: contributed by Laurent Léonard
150 Some sort of virtualization appears to be present, but we are not sure
151 what it is. In some very rare corner cases where we know that
152 virtualization is hard to detect, we will try a timing attack to see
153 if certain machine instructions are running much more slowly than they
154 should be, which would indicate virtualization. In this case, the
155 generic fact C<virt> is printed.
159 This is Hitachi Virtualization Manager (HVM) Virtage
160 hardware partitioning system.
162 Status: data supplied by Bhavna Sarathy, not confirmed
166 This is a VirtualBox guest.
168 Status: contributed by Laurent Léonard
172 The guest appears to be running on Microsoft VirtualPC.
174 Status: not confirmed
178 The guest appears to be running on VMware hypervisor.
180 Status: confirmed by RWMJ
184 The guest appears to be running on Xen hypervisor.
186 Status: confirmed by RWMJ
190 This is the Xen dom0 (privileged domain).
192 Status: confirmed by RWMJ
196 This is a Xen domU (paravirtualized guest domain).
198 Status: confirmed by RWMJ
202 This is a Xen guest fully virtualized (HVM).
204 Status: confirmed by RWMJ
210 Programs that use or wrap C<virt-what> should check that the exit
211 status is 0 before they attempt to parse the output of the command.
213 A non-zero exit status indicates some error, for example, an
214 unrecognized command line argument. If the exit status is non-zero
215 then the output "facts" (if any were printed) cannot be guaranteed and
218 The exit status does I<not> have anything to do with whether the
219 program is running on baremetal or under virtualization, nor with
220 whether C<virt-what> managed detection "correctly" (which is basically
221 unknowable given the large variety of virtualization systems out there
222 and that some systems deliberately emulate others).
224 =head1 RUNNING VIRT-WHAT FROM OTHER PROGRAMS
226 C<virt-what> is designed so that you can easily run it from
227 other programs or wrap it up in a library.
229 Your program should check the exit status (see the section above).
231 Some programming languages (notably Python: issue 1652) erroneously
232 mask the C<SIGPIPE> signal and do not restore it when executing
233 subprocesses. C<virt-what> is a shell script and some shell commands
234 do not work correctly when you do this. You may see warnings from
235 C<virt-what> similar to this:
237 echo: write error: Broken pipe
239 The solution is to set the C<SIGPIPE> signal handler back to C<SIG_DFL>
240 before running C<virt-what>.
242 =head1 IMPORTANT NOTE
244 Most of the time, using this program is the I<wrong> thing to do.
245 Instead you should detect the specific features you actually want to
246 use. (As an example, if you wanted to issue Xen hypervisor commands
247 you would look for the C</proc/xen/privcmd> file).
249 However people keep asking for this, so we provide it. There are a
254 =item Bug reporting tool
256 If you think that virtualization could affect how your program runs,
257 then you might use C<virt-what> to report this in a bug reporting
260 =item Status display and monitoring tools
262 You might include this information in status and monitoring programs.
264 =item System tuning (sometimes)
266 You might use this program to tune an operating system so it runs
267 better as a virtual machine of a particular hypervisor. However if
268 installing paravirtualized drivers, it's better to check for the
269 specific features your drivers need (eg. for the presence of PCI devices).
275 L<http://people.redhat.com/~rjones/virt-what/>,
276 L<http://www.vmware.com/>,
277 L<http://www.microsoft.com/windows/products/winfamily/virtualpc>,
278 L<http://xensource.com/>,
279 L<http://bellard.org/qemu/>,
280 L<http://kvm.qumranet.com/>,
281 L<http://openvz.org/>
285 Richard W.M. Jones <rjones @ redhat . com>
289 (C) Copyright 2008-2015 Red Hat Inc.,
290 L<http://people.redhat.com/~rjones/virt-what/>
292 This program is free software; you can redistribute it and/or modify
293 it under the terms of the GNU General Public License as published by
294 the Free Software Foundation; either version 2 of the License, or
295 (at your option) any later version.
297 This program is distributed in the hope that it will be useful,
298 but WITHOUT ANY WARRANTY; without even the implied warranty of
299 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
300 GNU General Public License for more details.
302 You should have received a copy of the GNU General Public License
303 along with this program; if not, write to the Free Software
304 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
306 =head1 REPORTING BUGS
308 Bugs can be viewed on the Red Hat Bugzilla page:
309 L<https://bugzilla.redhat.com/>.
311 If you find a bug in virt-what, please follow these steps to report it:
315 =item 1. Check for existing bug reports
317 Go to L<https://bugzilla.redhat.com/> and search for similar bugs.
318 Someone may already have reported the same bug, and they may even
321 =item 2. Capture debug and error messages
325 virt-what > virt-what.log 2>&1
327 and keep I<virt-what.log>. It may contain error messages which you
328 should submit with your bug report.
330 =item 3. Get version of virt-what.
336 =item 4. Submit a bug report.
338 Go to L<https://bugzilla.redhat.com/> and enter a new bug.
339 Please describe the problem in as much detail as possible.
341 Remember to include the version numbers (step 3) and the debug
342 messages file (step 2) and as much other detail as possible.
344 =item 5. Assign the bug to rjones @ redhat.com
346 Assign or reassign the bug to B<rjones @ redhat.com> (without the
347 spaces). You can also send me an email with the bug number if you
348 want a faster response.