*~
+*.o
+virt-what-*.tar.gz
+.deps
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache
+compile
+config.h
+config.h.in
+config.log
+config.status
+configure
+depcomp
+install-sh
+missing
+stamp-h1
virt-what
-virt-what.1
-virt-what.txt
-*.tar.gz
+virt-what-cpuid-helper
+virt-what.1
\ No newline at end of file
+++ /dev/null
-.cvsignore
-COPYING
-Makefile
-MANIFEST
-README
-virt-what.pod
-virt-what.sh
+++ /dev/null
-# Makefile for virt-what
-#
-# Copyright (C) 2008-2009 Red Hat Inc.
-#
-# 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.
-
-PACKAGE = virt-what
-VERSION = 1.0
-
-prefix = /usr/local
-bindir = $(prefix)/bin
-mandir = $(prefix)/share/man
-
-all: virt-what.1 virt-what.txt virt-what
-
-virt-what: virt-what.sh
- sed -e 's/@VERSION@/$(VERSION)/g' < $< > $@
- chmod 0755 $@
-
-virt-what.1: virt-what.pod
- pod2man -c "Virtualization Support" --release "$(PACKAGE)-$(VERSION)" \
- $< > $@
-
-virt-what.txt: virt-what.pod
- pod2text $< > $@
-
-clean:
- rm -f virt-what virt-what.1 virt-what.txt
- rm -f *~
-
-# Install.
-
-install:
- mkdir -p $(DESTDIR)$(bindir)
- mkdir -p $(DESTDIR)$(mandir)/man1
- install -m 0755 virt-what $(DESTDIR)$(bindir)/
- install -m 0644 virt-what.1 $(DESTDIR)$(mandir)/man1/
-
-# Distribution.
-
-dist:
- $(MAKE) check-manifest
- rm -rf $(PACKAGE)-$(VERSION)
- mkdir $(PACKAGE)-$(VERSION)
- tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
- tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
- rm -rf $(PACKAGE)-$(VERSION)
- ls -l $(PACKAGE)-$(VERSION).tar.gz
-
-check-manifest:
- @for d in `find -type d -name CVS | grep -v '^\./debian/'`; \
- do \
- b=`dirname $$d`/; \
- awk -F/ '$$1 != "D" {print $$2}' $$d/Entries | \
- sed -e "s|^|$$b|" -e "s|^\./||"; \
- done | sort > .check-manifest; \
- sort MANIFEST > .orig-manifest; \
- diff -u .orig-manifest .check-manifest; rv=$$?; \
- rm -f .orig-manifest .check-manifest; \
- exit $$rv
--- /dev/null
+# Makefile for virt-what
+# Copyright (C) 2008-2009 Red Hat Inc.
+#
+# 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.
+
+EXTRA_DIST = virt-what.in virt-what.pod
+
+AM_CPPFLAGS = -Wall
+
+bin_SCRIPTS = virt-what
+bin_PROGRAMS = virt-what-cpuid-helper
+
+man_MANS = virt-what.1
+
+virt-what.1: virt-what.pod
+ pod2man -c "Virtualization Support" --release "$(PACKAGE)-$(VERSION)" \
+ $< > $@
+
+virt-what.txt: virt-what.pod
+ pod2text $< > $@
virt-what
-Copyright (C) 2008 Red Hat Inc.
+Copyright (C) 2008-2009 Red Hat Inc.
+----------------------------------------------------------------------
+
+This is a collection of scripts which you can use to work out what
+sort of virtualization you are running inside.
Build:
+ ./configure
make
+If you want to run it from the local directory, then you have to set
+the PATH:
+
+ PATH=.:$PATH ./virt-what
+
To install (usually as root):
make install
--- /dev/null
+# virt-what
+# Copyright (C) 2008-2009 Red Hat Inc.
+#
+# 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.
+
+AC_INIT([virt-what],1.1)
+AM_INIT_AUTOMAKE([foreign])
+
+dnl Check for basic C environment.
+AC_PROG_CC_STDC
+AC_PROG_INSTALL
+AC_PROG_CPP
+
+AC_C_PROTOTYPES
+test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
+
+AM_PROG_CC_C_O
+
+dnl Produce output files.
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_FILES([virt-what],[chmod +x virt-what])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
--- /dev/null
+/* virt-what-cpuid-helper: Are we running inside KVM or Xen HVM?
+ * Copyright (C) 2008 Red Hat Inc.
+ *
+ * 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.
+ */
+
+/* This program was suggested by Gleb Natapov and written by Paolo
+ * Bonzini, with a few modifications by Richard W.M. Jones.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#if defined(__i386__) || defined(__x86_64__)
+void
+cpu_sig (char *sig)
+{
+ unsigned int eax = 0x40000000;
+ unsigned int *sig32 = (unsigned int *)sig;
+ asm volatile (
+ "xor %%ebx, %%ebx; cpuid"
+ : "=a" (eax), "=b" (sig32[0]), "=c" (sig32[1]), "=d" (sig32[2])
+ : "0" (eax));
+ sig[12] = 0;
+}
+#else
+void
+cpu_sig (char *sig)
+{
+ /* nothing for other architectures */
+}
+#endif
+
+int
+main()
+{
+ char sig[13];
+
+ memset (sig, 0, sizeof sig);
+
+ cpu_sig (sig);
+
+ puts (sig);
+ /* Possible values:
+ * KVMKVMKVM KVM guest
+ * XenVMMXenVMM Xen HVM guest
+ */
+
+ return 0;
+}
#!/bin/bash -
-#
-# Copyright (C) 2008 Red Hat Inc.
+# @configure_input@
+# Copyright (C) 2008-2009 Red Hat Inc.
#
# 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
echo openvz
fi
+# To tell if it is Xen and KVM HVM (fully virtualized) we can use this
+# helper C program.
+
+cpuid=`virt-what-cpuid-helper`
+
# Check for Xen.
-if [ -f /proc/xen/privcmd ]; then
+if [ "$cpuid" = "XenVMMXenVMM" ]; then
+ echo xen; echo xen-hvm
+ is_xen=1
+elif [ -f /proc/xen/privcmd ]; then
echo xen; echo xen-dom0
is_xen=1
elif [ -f /proc/xen/capabilities ]; then
# uses QEMU for its device model.
if grep -q 'QEMU' /proc/cpuinfo; then
- # XXX How to distinguish between QEMU & KVM?
- echo qemu
+ if [ "$cpuid" = "KVMKVMKVM" ]; then
+ echo kvm
+ else
+ echo qemu
+ fi
fi
fi
=over 4
-=item openvz
+=item B<openvz>
The guest appears to be running inside an OpenVZ or Virtuozzo
container.
Status: contributed by Evgeniy Sokolov
-=item qemu
+=item B<kvm>
-This is QEMU or KVM.
+This is KVM.
-Status: confirmed by RWMJ. Currently we have no way to
-tell the difference between QEMU and KVM guests.
+Status: confirmed by RWMJ.
-=item virtualpc
+=item B<qemu>
+
+This is QEMU.
+
+Status: confirmed by RWMJ.
+
+=item B<virtualpc>
The guest appears to be running on Microsoft VirtualPC.
Status: not confirmed
-=item vmware
+=item B<vmware>
The guest appears to be running on VMware.
Status: not confirmed
-=item xen
+=item B<xen>
The guest appears to be running on Xen.
Status: confirmed by RWMJ
-=item xen-dom0
+=item B<xen-dom0>
This is the Xen dom0 (privileged domain).
Status: confirmed by RWMJ
-=item xen-domU
+=item B<xen-domU>
+
+This is a Xen domU (paravirtualized guest domain).
+
+Status: confirmed by RWMJ
+
+=item B<xen-hvm>
-This is a Xen domU (normal guest domain).
+This is a Xen guest fully virtualized (HVM).
Status: confirmed by RWMJ