├── .gitignore ├── .travis.yml ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── Makefile.in ├── NEWS ├── PORTABLE.md ├── README ├── README.md ├── aclocal.m4 ├── compile ├── configure ├── configure.in ├── depcomp ├── dist ├── Makefile.am └── Makefile.in ├── helper ├── Makefile.am ├── Makefile.in ├── config.h.in ├── detect.c ├── detect.h ├── hvm.c ├── hyperv.c ├── pillbox.c ├── vmware.c └── xen.c ├── imvirt ├── imvirt-report ├── imvirt.spec.in ├── install-sh ├── logo └── imvirt.svg ├── man ├── Makefile.am ├── Makefile.in ├── imvirt-report.1 └── imvirt.1 ├── missing └── perl ├── Makefile.PL └── lib ├── ImVirt.pm.in └── ImVirt ├── Utils ├── blkdev.pm ├── cpuinfo.pm ├── dmesg.pm ├── dmidecode.pm ├── dmidecode │ ├── kernel.pm │ └── pipe.pm ├── helper.pm ├── jiffies.pm ├── kmods.pm ├── ksyms.pm ├── pcidevs.pm ├── procfs.pm ├── run.pm ├── sysfs.pm └── uname.pm ├── VCD ├── LXC.pm ├── OpenVZ.pm ├── UML.pm └── systemd_nspawn.pm └── VMD ├── ARAnyM.pm ├── Generic.pm ├── KVM.pm ├── Microsoft.pm ├── Parallels.pm ├── PillBox.pm ├── QEMU.pm ├── VMware.pm ├── VirtualBox.pm ├── Xen.pm └── lguest.pm /.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | config.log 3 | config.status 4 | config.h 5 | imvirt.spec 6 | autom4te.cache/ 7 | dist/ 8 | helper/* 9 | !helper/*.c 10 | perl/blib/ 11 | perl/lib/ImVirt.pm 12 | perl/MYMETA.* 13 | perl/pm_to_blib 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | env: 4 | - debug="" 5 | - debug="-d" 6 | 7 | before_install: 8 | - sudo apt-get update -qq 9 | - sudo apt-get install -qq libmodule-find-perl libfile-slurp-perl libfile-which-perl libmime-lite-perl 10 | 11 | install: 12 | - ./configure --prefix=$(pwd)/build 13 | - make && make install 14 | 15 | script: 16 | - perl -Iperl/lib imvirt $debug 17 | - sudo perl -Iperl/lib imvirt $debug 18 | - test "$debug" = "-d" && sudo perl -Iperl/lib imvirt-report -s /dev/stdout || true 19 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | imvirt 2 | ====== 3 | 4 | Thomas Liske 5 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | imvirt (1.0.0) unstable; urgency=low 2 | 3 | * Handle non-existing /proc/scsi/scsi gracefully. 4 | * Fix: Allow escaped quotes in lspci output. 5 | (Debian Bug #732460 by Martin von Wittich ) 6 | * Distinguish between virtual machine and virtualization container 7 | detection. 8 | * Fix broken sort function resulting in alternating results of imvirt. 9 | (Github Issue #14 by @pencil; Github Issue #15 by @alexbarton) 10 | 11 | -- Thomas Liske 12 | 13 | imvirt (0.9.6) unstable; urgency=low 14 | 15 | * Do not die if /proc/cpuinfo is unavailable 16 | (Debian Bug #693278 by Dmitry Smirnov ). 17 | * Split ImVirt Portable into core and bundle (w/ PAR stuff) build. 18 | * Add Parallels detection support. 19 | * Handle undefined %cpuinfo entries gracefully. 20 | (Debian Bug #69791 by Axel Beckert ). 21 | * Handle missing procfs entries used for jiffies calculation 22 | gracefully (OpenVZ). 23 | * Count CPU flag points only once. 24 | * Improve OpenVZ detection. 25 | 26 | -- Thomas Liske Fri, 23 Aug 2013 21:34:15 +0200 27 | 28 | imvirt (0.9.5) unstable; urgency=low 29 | 30 | * Add imvirt-report manpage from Debian, 31 | thanks to Patrick Matthäi . 32 | * Move source from SourceForge SVN to github, 33 | cleanup svn:keywords usage. 34 | * Update perl/Makefile.PL (require File::Which). 35 | * KVM: Don't count dmesg line twice 36 | (reported by Torsten Lüttgert ). 37 | * LXC: Remove inapplicable /proc from procfs_read() parameter 38 | (reported by Torsten Lüttgert ). 39 | * LXC: Use starttime jiffies from /proc/1/stat to detect LXC 40 | (suggested by Torsten Lüttgert ). 41 | * LXC: Fix false positive (regex typo). 42 | * Provide ImVirt Portable download. 43 | * Revised Microsoft Virtual PC / Hyper-V detection. 44 | 45 | -- Thomas Liske Fri, 14 Sep 2012 23:30:36 +0200 46 | 47 | imvirt (0.9.4) unstable; urgency=low 48 | 49 | * Fix some FTBFS due gcc 4.7 50 | (reported by Patrick Matthäi ). 51 | * Fix pod2man error (ImVirt.pm) 52 | (reported by Patrick Matthäi ). 53 | * Fix wrong use statement in LXC.pm 54 | (reported by Miroslav Suchý ). 55 | * Fix /proc/modules interpretation 56 | (reported by Miroslav Suchý ). 57 | * Use mktemp instead of tempfile (debianutils) in imvirt-report 58 | (reported by Miroslav Suchý ). 59 | 60 | -- Thomas Liske Thu, 17 May 2012 20:32:04 +0200 61 | 62 | imvirt (0.9.3) unstable; urgency=low 63 | 64 | * Add ARAnyM detection support. 65 | * Add LXC detection support. 66 | * Reduce perl warnings. 67 | * Use File::Which if available (no shell used to execute binaries). 68 | * Take only used virtio kernel modules into account. 69 | * Improve imvirt.spec.in (thanks to Miroslav Suchý ). 70 | * Don't call lspci unless /proc/bus/pci is available. 71 | * Add imvirt-report binary. 72 | 73 | -- Thomas Liske Mon, 14 May 2012 19:16:57 +0200 74 | 75 | imvirt (0.9.2) unstable; urgency=low 76 | 77 | * Improve overall detection. 78 | * Improve debug output. 79 | * Add INSTALLDIRS=vendor to be conform to the Debian perl policy. 80 | (Debian Bug #578798 by Niko Tyni ) 81 | * Update to automake 1.11.1. 82 | 83 | -- Thomas Liske Sat, 04 Feb 2012 17:52:45 +0100 84 | 85 | imvirt (0.9.1) unstable; urgency=low 86 | 87 | * Output possible result lines on help output. 88 | * Don't die in Utils/pcidevs.pm if lspci is not available. 89 | (Closes Debian Bug#612735 by Stefan Bühler) 90 | * Parse new kernel paravirtualization lines (KVM, VMware). 91 | * Improve KVM w/ virtio detection. 92 | * Improve KVM/QUEMU detection. 93 | (Contributed by Mike Gerber ) 94 | * Add basic lguest detection support. 95 | * Improve debugging of legacy imvirt script. 96 | 97 | -- Thomas Liske Thu, 02 Jun 2011 21:50:55 +0200 98 | 99 | imvirt (0.9.0) unstable; urgency=low 100 | 101 | * Rewrite imvirt as a perl module framework. 102 | * Detection changed from "first best match" to a weighted 103 | characteristics aproach. 104 | * Add legacy replacement script 'imvirt' as a replacement 105 | for the old monolitic script. 106 | 107 | -- Thomas Liske Mon, 29 Mar 2010 19:55:14 +0200 108 | 109 | imvirt (0.3.3) unstable; urgency=low 110 | 111 | * Make modern GCC versions stop warning about breaking 112 | strict-aliasing checking. 113 | * Add imvirt.spec.in. 114 | 115 | -- Thomas Liske Sat, 13 Feb 2010 00:26:54 +0100 116 | 117 | imvirt (0.3.2) unstable; urgency=low 118 | 119 | * Handle SIGILL on amd64 for Xen PV detection gracefully. 120 | reported by Patrick Matthäi 121 | * Fix false positive CPUID results interpreted as HVM 122 | virtualization on P4. 123 | (Closes Debian Bug#566656 by Stephan Sürken) 124 | * Add CPUID debug code (-c). 125 | * Add missing stdlib.h to detect.c (compile warning). 126 | 127 | -- Thomas Liske Mon, 01 Feb 2010 14:56:15 +0100 128 | 129 | imvirt (0.3.1) unstable; urgency=low 130 | 131 | * Add missing manpage (svn was somewhat confused). 132 | 133 | * Fix build system. 134 | 135 | -- Thomas Liske Sat, 12 Sep 2009 21:09:22 +0200 136 | 137 | imvirt (0.3) unstable; urgency=low 138 | 139 | * Add manpage from Debian, 140 | thanks to Patrick Matthäi 141 | 142 | * Add OpenVZ/Virtuozzo detection 143 | taken from virt-what 1.1 (Evgeniy Sokolov) 144 | 145 | * Add UML detection 146 | 147 | * Add binary helper to detect 148 | - Virtual PC/Server 149 | - VMware 150 | - Xen 151 | HVM using cpuid calls. 152 | 153 | * Improvements/fixes: 154 | - fix dmesg call 155 | - scan /proc/ide/hd*/model for well known signatures 156 | 157 | -- Thomas Liske Sat Sep 5 12:36:18 CEST 2009 158 | 159 | imvirt (0.2.1) unstable; urgency=low 160 | 161 | * Fix Xen detection on new kernels (i.e. Debian Lenny). 162 | 163 | -- Thomas Liske Thu, 12 Mar 2009 10:19:00 +0100 164 | 165 | imvirt (0.2) unstable; urgency=low 166 | 167 | * Move to SF project apt-dater. 168 | * Add copyright stuff and ChangeLog. 169 | 170 | -- Thomas Liske Wed, 26 Nov 2008 13:19:24 +0100 171 | 172 | imvirt (0.1-r10) unstable; urgency=low 173 | 174 | * Use /bin/dmesg (/var/log/dmesg not always accessible). 175 | * Improve rules to detect VMware server 2.0. 176 | 177 | -- Thomas Liske Tue, 25 Nov 2008 13:10:50 +0100 178 | 179 | imvirt (0.1-r9) unstable; urgency=low 180 | 181 | * Minor bugfix release. 182 | 183 | -- Thomas Liske Thu, 20 Nov 2008 07:52:53 +0100 184 | 185 | imvirt (0.1-r5) unstable; urgency=low 186 | 187 | * Fixed regex syntax error. 188 | 189 | -- Thomas Liske Tue, 18 Nov 2008 08:04:50 +0100 190 | 191 | imvirt (0.1-r3) unstable; urgency=low 192 | 193 | * Improve QEMU detection. 194 | * Add VirtualBox detection. 195 | 196 | -- Thomas Liske Mon, 17 Nov 2008 16:55:40 +0100 197 | 198 | imvirt (0.1-r2) unstable; urgency=low 199 | 200 | * Initial Release. 201 | 202 | -- Thomas Liske Mon, 17 Nov 2008 13:43:06 +0100 203 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Installation Instructions 2 | ************************* 3 | 4 | Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free 5 | Software Foundation, Inc. 6 | 7 | This file is free documentation; the Free Software Foundation gives 8 | unlimited permission to copy, distribute and modify it. 9 | 10 | Basic Installation 11 | ================== 12 | 13 | These are generic installation instructions. 14 | 15 | The `configure' shell script attempts to guess correct values for 16 | various system-dependent variables used during compilation. It uses 17 | those values to create a `Makefile' in each directory of the package. 18 | It may also create one or more `.h' files containing system-dependent 19 | definitions. Finally, it creates a shell script `config.status' that 20 | you can run in the future to recreate the current configuration, and a 21 | file `config.log' containing compiler output (useful mainly for 22 | debugging `configure'). 23 | 24 | It can also use an optional file (typically called `config.cache' 25 | and enabled with `--cache-file=config.cache' or simply `-C') that saves 26 | the results of its tests to speed up reconfiguring. (Caching is 27 | disabled by default to prevent problems with accidental use of stale 28 | cache files.) 29 | 30 | If you need to do unusual things to compile the package, please try 31 | to figure out how `configure' could check whether to do them, and mail 32 | diffs or instructions to the address given in the `README' so they can 33 | be considered for the next release. If you are using the cache, and at 34 | some point `config.cache' contains results you don't want to keep, you 35 | may remove or edit it. 36 | 37 | The file `configure.ac' (or `configure.in') is used to create 38 | `configure' by a program called `autoconf'. You only need 39 | `configure.ac' if you want to change it or regenerate `configure' using 40 | a newer version of `autoconf'. 41 | 42 | The simplest way to compile this package is: 43 | 44 | 1. `cd' to the directory containing the package's source code and type 45 | `./configure' to configure the package for your system. If you're 46 | using `csh' on an old version of System V, you might need to type 47 | `sh ./configure' instead to prevent `csh' from trying to execute 48 | `configure' itself. 49 | 50 | Running `configure' takes awhile. While running, it prints some 51 | messages telling which features it is checking for. 52 | 53 | 2. Type `make' to compile the package. 54 | 55 | 3. Optionally, type `make check' to run any self-tests that come with 56 | the package. 57 | 58 | 4. Type `make install' to install the programs and any data files and 59 | documentation. 60 | 61 | 5. You can remove the program binaries and object files from the 62 | source code directory by typing `make clean'. To also remove the 63 | files that `configure' created (so you can compile the package for 64 | a different kind of computer), type `make distclean'. There is 65 | also a `make maintainer-clean' target, but that is intended mainly 66 | for the package's developers. If you use it, you may have to get 67 | all sorts of other programs in order to regenerate files that came 68 | with the distribution. 69 | 70 | Compilers and Options 71 | ===================== 72 | 73 | Some systems require unusual options for compilation or linking that the 74 | `configure' script does not know about. Run `./configure --help' for 75 | details on some of the pertinent environment variables. 76 | 77 | You can give `configure' initial values for configuration parameters 78 | by setting variables in the command line or in the environment. Here 79 | is an example: 80 | 81 | ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix 82 | 83 | *Note Defining Variables::, for more details. 84 | 85 | Compiling For Multiple Architectures 86 | ==================================== 87 | 88 | You can compile the package for more than one kind of computer at the 89 | same time, by placing the object files for each architecture in their 90 | own directory. To do this, you must use a version of `make' that 91 | supports the `VPATH' variable, such as GNU `make'. `cd' to the 92 | directory where you want the object files and executables to go and run 93 | the `configure' script. `configure' automatically checks for the 94 | source code in the directory that `configure' is in and in `..'. 95 | 96 | If you have to use a `make' that does not support the `VPATH' 97 | variable, you have to compile the package for one architecture at a 98 | time in the source code directory. After you have installed the 99 | package for one architecture, use `make distclean' before reconfiguring 100 | for another architecture. 101 | 102 | Installation Names 103 | ================== 104 | 105 | By default, `make install' installs the package's commands under 106 | `/usr/local/bin', include files under `/usr/local/include', etc. You 107 | can specify an installation prefix other than `/usr/local' by giving 108 | `configure' the option `--prefix=PREFIX'. 109 | 110 | You can specify separate installation prefixes for 111 | architecture-specific files and architecture-independent files. If you 112 | pass the option `--exec-prefix=PREFIX' to `configure', the package uses 113 | PREFIX as the prefix for installing programs and libraries. 114 | Documentation and other data files still use the regular prefix. 115 | 116 | In addition, if you use an unusual directory layout you can give 117 | options like `--bindir=DIR' to specify different values for particular 118 | kinds of files. Run `configure --help' for a list of the directories 119 | you can set and what kinds of files go in them. 120 | 121 | If the package supports it, you can cause programs to be installed 122 | with an extra prefix or suffix on their names by giving `configure' the 123 | option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. 124 | 125 | Optional Features 126 | ================= 127 | 128 | Some packages pay attention to `--enable-FEATURE' options to 129 | `configure', where FEATURE indicates an optional part of the package. 130 | They may also pay attention to `--with-PACKAGE' options, where PACKAGE 131 | is something like `gnu-as' or `x' (for the X Window System). The 132 | `README' should mention any `--enable-' and `--with-' options that the 133 | package recognizes. 134 | 135 | For packages that use the X Window System, `configure' can usually 136 | find the X include and library files automatically, but if it doesn't, 137 | you can use the `configure' options `--x-includes=DIR' and 138 | `--x-libraries=DIR' to specify their locations. 139 | 140 | Specifying the System Type 141 | ========================== 142 | 143 | There may be some features `configure' cannot figure out automatically, 144 | but needs to determine by the type of machine the package will run on. 145 | Usually, assuming the package is built to be run on the _same_ 146 | architectures, `configure' can figure that out, but if it prints a 147 | message saying it cannot guess the machine type, give it the 148 | `--build=TYPE' option. TYPE can either be a short name for the system 149 | type, such as `sun4', or a canonical name which has the form: 150 | 151 | CPU-COMPANY-SYSTEM 152 | 153 | where SYSTEM can have one of these forms: 154 | 155 | OS KERNEL-OS 156 | 157 | See the file `config.sub' for the possible values of each field. If 158 | `config.sub' isn't included in this package, then this package doesn't 159 | need to know the machine type. 160 | 161 | If you are _building_ compiler tools for cross-compiling, you should 162 | use the option `--target=TYPE' to select the type of system they will 163 | produce code for. 164 | 165 | If you want to _use_ a cross compiler, that generates code for a 166 | platform different from the build platform, you should specify the 167 | "host" platform (i.e., that on which the generated programs will 168 | eventually be run) with `--host=TYPE'. 169 | 170 | Sharing Defaults 171 | ================ 172 | 173 | If you want to set default values for `configure' scripts to share, you 174 | can create a site shell script called `config.site' that gives default 175 | values for variables like `CC', `cache_file', and `prefix'. 176 | `configure' looks for `PREFIX/share/config.site' if it exists, then 177 | `PREFIX/etc/config.site' if it exists. Or, you can set the 178 | `CONFIG_SITE' environment variable to the location of the site script. 179 | A warning: not all `configure' scripts look for a site script. 180 | 181 | Defining Variables 182 | ================== 183 | 184 | Variables not defined in a site shell script can be set in the 185 | environment passed to `configure'. However, some packages may run 186 | configure again during the build, and the customized values of these 187 | variables may be lost. In order to avoid this problem, you should set 188 | them in the `configure' command line, using `VAR=value'. For example: 189 | 190 | ./configure CC=/usr/local2/bin/gcc 191 | 192 | causes the specified `gcc' to be used as the C compiler (unless it is 193 | overridden in the site shell script). Here is a another example: 194 | 195 | /bin/bash ./configure CONFIG_SHELL=/bin/bash 196 | 197 | Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent 198 | configuration-related scripts to be executed by `/bin/bash'. 199 | 200 | `configure' Invocation 201 | ====================== 202 | 203 | `configure' recognizes the following options to control how it operates. 204 | 205 | `--help' 206 | `-h' 207 | Print a summary of the options to `configure', and exit. 208 | 209 | `--version' 210 | `-V' 211 | Print the version of Autoconf used to generate the `configure' 212 | script, and exit. 213 | 214 | `--cache-file=FILE' 215 | Enable the cache: use and save the results of the tests in FILE, 216 | traditionally `config.cache'. FILE defaults to `/dev/null' to 217 | disable caching. 218 | 219 | `--config-cache' 220 | `-C' 221 | Alias for `--cache-file=config.cache'. 222 | 223 | `--quiet' 224 | `--silent' 225 | `-q' 226 | Do not print messages saying which checks are being made. To 227 | suppress all normal output, redirect it to `/dev/null' (any error 228 | messages will still be shown). 229 | 230 | `--srcdir=DIR' 231 | Look for the package's source code in directory DIR. Usually 232 | `configure' can determine that directory automatically. 233 | 234 | `configure' also accepts some other, not widely useful, options. Run 235 | `configure --help' for more details. 236 | 237 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = helper man perl dist 2 | 3 | AUTOMAKE_OPTIONS = 4 | 1.9 5 | dist-bzip2 6 | 7 | BUILT_SOURCES = perl 8 | 9 | bin_SCRIPTS = imvirt 10 | sbin_SCRIPTS = imvirt-report 11 | 12 | install-exec-local: 13 | [ ! -f perl/Makefile ] || ( cd perl && $(MAKE) install ) 14 | 15 | clean-local: 16 | [ ! -f perl/Makefile ] || ( cd perl && $(MAKE) realclean ) 17 | 18 | perl: perl/Makefile 19 | cd perl && $(MAKE) 20 | 21 | perl/Makefile: perl/Makefile.PL 22 | cd perl && perl Makefile.PL PREFIX=$(prefix) INSTALLDIRS=vendor 23 | 24 | .PHONY: perl 25 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | Changes in 0.9.5 2 | ================ 3 | 4 | The detection of Microsoft Windows OS based hypervisors has been revised. 5 | Please be aware of the changed output format. 6 | 7 | 8 | Changes in 0.9.0 9 | ================ 10 | 11 | The previous imvirt script has been ported into a perl package framework. 12 | 13 | package tree: 14 | 15 | ImVirt.pm - generic interface to use the imvirt framework 16 | ImVirt::Utils::... - common helper modules used by ImVirt::VMD::* packages 17 | ImVirt::VMD::... - Virtual Machine Detection packages 18 | 19 | New VMD packages can ne added by putting them into perl's search path. 20 | ImVirt.pm uses Module::Find to load any ImVirt::VMD::* package. 21 | 22 | The new imvirt script can be used as a dropin replacement for the old 23 | legacy imvirt script. 24 | -------------------------------------------------------------------------------- /PORTABLE.md: -------------------------------------------------------------------------------- 1 | ImVirt Portable 2 | =============== 3 | 4 | `ImVirt Portable` is a portable version of `ImVirt` 5 | using the `PAR Packager` (`pp`). It is a self contained perl script but lags 6 | the binary helper stuff. This might result in a more inaccurate detection. 7 | 8 | There is a `core` and a `bundle` build of `ImVirt Portable`. The latter 9 | contains all the `PAR Packager` glue and has no additional dependency. 10 | 11 | Download: https://github.com/DE-IBH/imvirt/releases/ 12 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | imvirt - I'm virtualized? 2 | ========================= 3 | 4 | This script tries to detect if it is run under a (para)virtualization. 5 | This is done by looking for wellknown boot messages, device names, 6 | installed tools etc. 7 | 8 | Detected virtualizations: 9 | - ARAnyM 10 | - KVM 11 | - lguest 12 | - LXC 13 | - Microsoft Virtual PC / Hyper-V 14 | - OpenVZ/Virtuozzo 15 | - Parallels Workstation 16 | - QEMU 17 | - UML 18 | - VMware GSX, ESX, Workstation 19 | - VirtualBox 20 | - Xen (para and non-para virtualized) 21 | - any HVM providing CPUID 0x40000000 detection 22 | 23 | imvirt is comparable with virt-what [1]. imvirt was written to run as 24 | non-root - virt-what requires to be run as root but had some more 25 | details on Xen (Dom0/DomU/HVM) in the past. 26 | 27 | There is a portable version available: [ImVirt Portable](imvirt/tree/master/PORTABLE.md) 28 | 29 | Some random links taken as suggestions: 30 | 31 | 1. http://et.redhat.com/~rjones/virt-what/ 32 | 2. http://www.dmo.ca/blog/detecting-virtualization-on-linux/ 33 | 3. http://my.opera.com/jaelanicu/blog/2008/04/02/a-better-red-pill-scooby-for-vmware 34 | 4. http://my.opera.com/jaelanicu/blog/show.dml/4257341 35 | 5. http://www.codegurus.be/codegurus/Programming/virtualpc&vmware_en.htm 36 | 6. http://flierlu.blogspot.com/2008/04/virtualization-detection.html 37 | 7. http://www.microsoft.com/downloads/details.aspx?FamilyId=91E2E518-C62C-4FF2-8E50-3A37EA4100F5&displaylang=en 38 | 8. http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458 39 | 9. http://invisiblethings.org/papers/redpill.html 40 | 10. http://www.offensivecomputing.net/files/active/0/vm.pdf 41 | 11. http://www.s21sec.com/descargas/vmware-eng.pdf 42 | 12. http://www.trapkit.de/research/vmm/scoopyng/index.html 43 | 44 | -- Thomas Liske Thu, 31 Aug 2012 22:36:09 +0200 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | README -------------------------------------------------------------------------------- /compile: -------------------------------------------------------------------------------- 1 | /usr/share/automake-1.14/compile -------------------------------------------------------------------------------- /configure.in: -------------------------------------------------------------------------------- 1 | # -*- Autoconf -*- 2 | # Process this file with autoconf to produce a configure script. 3 | 4 | AC_REVISION($Revision$) 5 | 6 | AC_PREREQ(2.61) 7 | AC_INIT(imvirt, 1.0.0, liske@ibh.de) 8 | AM_INIT_AUTOMAKE 9 | AC_CONFIG_SRCDIR([helper/detect.c]) 10 | AC_CONFIG_HEADER([helper/config.h]) 11 | 12 | # Checks for programs. 13 | AC_PROG_CC 14 | 15 | # Checks for libraries. 16 | 17 | # Checks for header files. 18 | AC_HEADER_STDC 19 | AC_HEADER_SYS_WAIT 20 | AC_CHECK_HEADERS([stdint.h stdlib.h string.h unistd.h]) 21 | 22 | # Checks for typedefs, structures, and compiler characteristics. 23 | AC_TYPE_PID_T 24 | AC_TYPE_UINT16_T 25 | AC_TYPE_UINT32_T 26 | 27 | # Checks for library functions. 28 | AC_FUNC_FORK 29 | AC_TYPE_SIGNAL 30 | 31 | # Check architecture 32 | AC_MSG_CHECKING(x86 platform) 33 | case `uname -m` in 34 | x86_64) x86arch=true ;; 35 | i686) x86arch=true ;; 36 | *) x86arch=false ;; 37 | esac 38 | AC_MSG_RESULT($x86arch) 39 | AM_CONDITIONAL([X86ARCH], [test x$x86arch = xtrue ]) 40 | 41 | MYDIR=$libexecdir 42 | AC_SUBST(MYDIR) 43 | 44 | AC_CONFIG_FILES([ 45 | Makefile 46 | dist/Makefile 47 | helper/Makefile 48 | man/Makefile 49 | imvirt.spec 50 | perl/lib/ImVirt.pm 51 | ]) 52 | 53 | AC_OUTPUT 54 | -------------------------------------------------------------------------------- /depcomp: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # depcomp - compile a program generating dependencies as side-effects 3 | 4 | scriptversion=2005-07-09.11 5 | 6 | # Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 7 | 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2, or (at your option) 11 | # any later version. 12 | 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21 | # 02110-1301, USA. 22 | 23 | # As a special exception to the GNU General Public License, if you 24 | # distribute this file as part of a program that contains a 25 | # configuration script generated by Autoconf, you may include it under 26 | # the same distribution terms that you use for the rest of that program. 27 | 28 | # Originally written by Alexandre Oliva . 29 | 30 | case $1 in 31 | '') 32 | echo "$0: No command. Try \`$0 --help' for more information." 1>&2 33 | exit 1; 34 | ;; 35 | -h | --h*) 36 | cat <<\EOF 37 | Usage: depcomp [--help] [--version] PROGRAM [ARGS] 38 | 39 | Run PROGRAMS ARGS to compile a file, generating dependencies 40 | as side-effects. 41 | 42 | Environment variables: 43 | depmode Dependency tracking mode. 44 | source Source file read by `PROGRAMS ARGS'. 45 | object Object file output by `PROGRAMS ARGS'. 46 | DEPDIR directory where to store dependencies. 47 | depfile Dependency file to output. 48 | tmpdepfile Temporary file to use when outputing dependencies. 49 | libtool Whether libtool is used (yes/no). 50 | 51 | Report bugs to . 52 | EOF 53 | exit $? 54 | ;; 55 | -v | --v*) 56 | echo "depcomp $scriptversion" 57 | exit $? 58 | ;; 59 | esac 60 | 61 | if test -z "$depmode" || test -z "$source" || test -z "$object"; then 62 | echo "depcomp: Variables source, object and depmode must be set" 1>&2 63 | exit 1 64 | fi 65 | 66 | # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 67 | depfile=${depfile-`echo "$object" | 68 | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 69 | tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 70 | 71 | rm -f "$tmpdepfile" 72 | 73 | # Some modes work just like other modes, but use different flags. We 74 | # parameterize here, but still list the modes in the big case below, 75 | # to make depend.m4 easier to write. Note that we *cannot* use a case 76 | # here, because this file can only contain one case statement. 77 | if test "$depmode" = hp; then 78 | # HP compiler uses -M and no extra arg. 79 | gccflag=-M 80 | depmode=gcc 81 | fi 82 | 83 | if test "$depmode" = dashXmstdout; then 84 | # This is just like dashmstdout with a different argument. 85 | dashmflag=-xM 86 | depmode=dashmstdout 87 | fi 88 | 89 | case "$depmode" in 90 | gcc3) 91 | ## gcc 3 implements dependency tracking that does exactly what 92 | ## we want. Yay! Note: for some reason libtool 1.4 doesn't like 93 | ## it if -MD -MP comes after the -MF stuff. Hmm. 94 | "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" 95 | stat=$? 96 | if test $stat -eq 0; then : 97 | else 98 | rm -f "$tmpdepfile" 99 | exit $stat 100 | fi 101 | mv "$tmpdepfile" "$depfile" 102 | ;; 103 | 104 | gcc) 105 | ## There are various ways to get dependency output from gcc. Here's 106 | ## why we pick this rather obscure method: 107 | ## - Don't want to use -MD because we'd like the dependencies to end 108 | ## up in a subdir. Having to rename by hand is ugly. 109 | ## (We might end up doing this anyway to support other compilers.) 110 | ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 111 | ## -MM, not -M (despite what the docs say). 112 | ## - Using -M directly means running the compiler twice (even worse 113 | ## than renaming). 114 | if test -z "$gccflag"; then 115 | gccflag=-MD, 116 | fi 117 | "$@" -Wp,"$gccflag$tmpdepfile" 118 | stat=$? 119 | if test $stat -eq 0; then : 120 | else 121 | rm -f "$tmpdepfile" 122 | exit $stat 123 | fi 124 | rm -f "$depfile" 125 | echo "$object : \\" > "$depfile" 126 | alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 127 | ## The second -e expression handles DOS-style file names with drive letters. 128 | sed -e 's/^[^:]*: / /' \ 129 | -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 130 | ## This next piece of magic avoids the `deleted header file' problem. 131 | ## The problem is that when a header file which appears in a .P file 132 | ## is deleted, the dependency causes make to die (because there is 133 | ## typically no way to rebuild the header). We avoid this by adding 134 | ## dummy dependencies for each header file. Too bad gcc doesn't do 135 | ## this for us directly. 136 | tr ' ' ' 137 | ' < "$tmpdepfile" | 138 | ## Some versions of gcc put a space before the `:'. On the theory 139 | ## that the space means something, we add a space to the output as 140 | ## well. 141 | ## Some versions of the HPUX 10.20 sed can't process this invocation 142 | ## correctly. Breaking it into two sed invocations is a workaround. 143 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 144 | rm -f "$tmpdepfile" 145 | ;; 146 | 147 | hp) 148 | # This case exists only to let depend.m4 do its work. It works by 149 | # looking at the text of this script. This case will never be run, 150 | # since it is checked for above. 151 | exit 1 152 | ;; 153 | 154 | sgi) 155 | if test "$libtool" = yes; then 156 | "$@" "-Wp,-MDupdate,$tmpdepfile" 157 | else 158 | "$@" -MDupdate "$tmpdepfile" 159 | fi 160 | stat=$? 161 | if test $stat -eq 0; then : 162 | else 163 | rm -f "$tmpdepfile" 164 | exit $stat 165 | fi 166 | rm -f "$depfile" 167 | 168 | if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 169 | echo "$object : \\" > "$depfile" 170 | 171 | # Clip off the initial element (the dependent). Don't try to be 172 | # clever and replace this with sed code, as IRIX sed won't handle 173 | # lines with more than a fixed number of characters (4096 in 174 | # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 175 | # the IRIX cc adds comments like `#:fec' to the end of the 176 | # dependency line. 177 | tr ' ' ' 178 | ' < "$tmpdepfile" \ 179 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 180 | tr ' 181 | ' ' ' >> $depfile 182 | echo >> $depfile 183 | 184 | # The second pass generates a dummy entry for each header file. 185 | tr ' ' ' 186 | ' < "$tmpdepfile" \ 187 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 188 | >> $depfile 189 | else 190 | # The sourcefile does not contain any dependencies, so just 191 | # store a dummy comment line, to avoid errors with the Makefile 192 | # "include basename.Plo" scheme. 193 | echo "#dummy" > "$depfile" 194 | fi 195 | rm -f "$tmpdepfile" 196 | ;; 197 | 198 | aix) 199 | # The C for AIX Compiler uses -M and outputs the dependencies 200 | # in a .u file. In older versions, this file always lives in the 201 | # current directory. Also, the AIX compiler puts `$object:' at the 202 | # start of each line; $object doesn't have directory information. 203 | # Version 6 uses the directory in both cases. 204 | stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` 205 | tmpdepfile="$stripped.u" 206 | if test "$libtool" = yes; then 207 | "$@" -Wc,-M 208 | else 209 | "$@" -M 210 | fi 211 | stat=$? 212 | 213 | if test -f "$tmpdepfile"; then : 214 | else 215 | stripped=`echo "$stripped" | sed 's,^.*/,,'` 216 | tmpdepfile="$stripped.u" 217 | fi 218 | 219 | if test $stat -eq 0; then : 220 | else 221 | rm -f "$tmpdepfile" 222 | exit $stat 223 | fi 224 | 225 | if test -f "$tmpdepfile"; then 226 | outname="$stripped.o" 227 | # Each line is of the form `foo.o: dependent.h'. 228 | # Do two passes, one to just change these to 229 | # `$object: dependent.h' and one to simply `dependent.h:'. 230 | sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" 231 | sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" 232 | else 233 | # The sourcefile does not contain any dependencies, so just 234 | # store a dummy comment line, to avoid errors with the Makefile 235 | # "include basename.Plo" scheme. 236 | echo "#dummy" > "$depfile" 237 | fi 238 | rm -f "$tmpdepfile" 239 | ;; 240 | 241 | icc) 242 | # Intel's C compiler understands `-MD -MF file'. However on 243 | # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 244 | # ICC 7.0 will fill foo.d with something like 245 | # foo.o: sub/foo.c 246 | # foo.o: sub/foo.h 247 | # which is wrong. We want: 248 | # sub/foo.o: sub/foo.c 249 | # sub/foo.o: sub/foo.h 250 | # sub/foo.c: 251 | # sub/foo.h: 252 | # ICC 7.1 will output 253 | # foo.o: sub/foo.c sub/foo.h 254 | # and will wrap long lines using \ : 255 | # foo.o: sub/foo.c ... \ 256 | # sub/foo.h ... \ 257 | # ... 258 | 259 | "$@" -MD -MF "$tmpdepfile" 260 | stat=$? 261 | if test $stat -eq 0; then : 262 | else 263 | rm -f "$tmpdepfile" 264 | exit $stat 265 | fi 266 | rm -f "$depfile" 267 | # Each line is of the form `foo.o: dependent.h', 268 | # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 269 | # Do two passes, one to just change these to 270 | # `$object: dependent.h' and one to simply `dependent.h:'. 271 | sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 272 | # Some versions of the HPUX 10.20 sed can't process this invocation 273 | # correctly. Breaking it into two sed invocations is a workaround. 274 | sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 275 | sed -e 's/$/ :/' >> "$depfile" 276 | rm -f "$tmpdepfile" 277 | ;; 278 | 279 | tru64) 280 | # The Tru64 compiler uses -MD to generate dependencies as a side 281 | # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 282 | # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 283 | # dependencies in `foo.d' instead, so we check for that too. 284 | # Subdirectories are respected. 285 | dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 286 | test "x$dir" = "x$object" && dir= 287 | base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 288 | 289 | if test "$libtool" = yes; then 290 | # With Tru64 cc, shared objects can also be used to make a 291 | # static library. This mecanism is used in libtool 1.4 series to 292 | # handle both shared and static libraries in a single compilation. 293 | # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 294 | # 295 | # With libtool 1.5 this exception was removed, and libtool now 296 | # generates 2 separate objects for the 2 libraries. These two 297 | # compilations output dependencies in in $dir.libs/$base.o.d and 298 | # in $dir$base.o.d. We have to check for both files, because 299 | # one of the two compilations can be disabled. We should prefer 300 | # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 301 | # automatically cleaned when .libs/ is deleted, while ignoring 302 | # the former would cause a distcleancheck panic. 303 | tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 304 | tmpdepfile2=$dir$base.o.d # libtool 1.5 305 | tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 306 | tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 307 | "$@" -Wc,-MD 308 | else 309 | tmpdepfile1=$dir$base.o.d 310 | tmpdepfile2=$dir$base.d 311 | tmpdepfile3=$dir$base.d 312 | tmpdepfile4=$dir$base.d 313 | "$@" -MD 314 | fi 315 | 316 | stat=$? 317 | if test $stat -eq 0; then : 318 | else 319 | rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 320 | exit $stat 321 | fi 322 | 323 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 324 | do 325 | test -f "$tmpdepfile" && break 326 | done 327 | if test -f "$tmpdepfile"; then 328 | sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 329 | # That's a tab and a space in the []. 330 | sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 331 | else 332 | echo "#dummy" > "$depfile" 333 | fi 334 | rm -f "$tmpdepfile" 335 | ;; 336 | 337 | #nosideeffect) 338 | # This comment above is used by automake to tell side-effect 339 | # dependency tracking mechanisms from slower ones. 340 | 341 | dashmstdout) 342 | # Important note: in order to support this mode, a compiler *must* 343 | # always write the preprocessed file to stdout, regardless of -o. 344 | "$@" || exit $? 345 | 346 | # Remove the call to Libtool. 347 | if test "$libtool" = yes; then 348 | while test $1 != '--mode=compile'; do 349 | shift 350 | done 351 | shift 352 | fi 353 | 354 | # Remove `-o $object'. 355 | IFS=" " 356 | for arg 357 | do 358 | case $arg in 359 | -o) 360 | shift 361 | ;; 362 | $object) 363 | shift 364 | ;; 365 | *) 366 | set fnord "$@" "$arg" 367 | shift # fnord 368 | shift # $arg 369 | ;; 370 | esac 371 | done 372 | 373 | test -z "$dashmflag" && dashmflag=-M 374 | # Require at least two characters before searching for `:' 375 | # in the target name. This is to cope with DOS-style filenames: 376 | # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 377 | "$@" $dashmflag | 378 | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 379 | rm -f "$depfile" 380 | cat < "$tmpdepfile" > "$depfile" 381 | tr ' ' ' 382 | ' < "$tmpdepfile" | \ 383 | ## Some versions of the HPUX 10.20 sed can't process this invocation 384 | ## correctly. Breaking it into two sed invocations is a workaround. 385 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 386 | rm -f "$tmpdepfile" 387 | ;; 388 | 389 | dashXmstdout) 390 | # This case only exists to satisfy depend.m4. It is never actually 391 | # run, as this mode is specially recognized in the preamble. 392 | exit 1 393 | ;; 394 | 395 | makedepend) 396 | "$@" || exit $? 397 | # Remove any Libtool call 398 | if test "$libtool" = yes; then 399 | while test $1 != '--mode=compile'; do 400 | shift 401 | done 402 | shift 403 | fi 404 | # X makedepend 405 | shift 406 | cleared=no 407 | for arg in "$@"; do 408 | case $cleared in 409 | no) 410 | set ""; shift 411 | cleared=yes ;; 412 | esac 413 | case "$arg" in 414 | -D*|-I*) 415 | set fnord "$@" "$arg"; shift ;; 416 | # Strip any option that makedepend may not understand. Remove 417 | # the object too, otherwise makedepend will parse it as a source file. 418 | -*|$object) 419 | ;; 420 | *) 421 | set fnord "$@" "$arg"; shift ;; 422 | esac 423 | done 424 | obj_suffix="`echo $object | sed 's/^.*\././'`" 425 | touch "$tmpdepfile" 426 | ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 427 | rm -f "$depfile" 428 | cat < "$tmpdepfile" > "$depfile" 429 | sed '1,2d' "$tmpdepfile" | tr ' ' ' 430 | ' | \ 431 | ## Some versions of the HPUX 10.20 sed can't process this invocation 432 | ## correctly. Breaking it into two sed invocations is a workaround. 433 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 434 | rm -f "$tmpdepfile" "$tmpdepfile".bak 435 | ;; 436 | 437 | cpp) 438 | # Important note: in order to support this mode, a compiler *must* 439 | # always write the preprocessed file to stdout. 440 | "$@" || exit $? 441 | 442 | # Remove the call to Libtool. 443 | if test "$libtool" = yes; then 444 | while test $1 != '--mode=compile'; do 445 | shift 446 | done 447 | shift 448 | fi 449 | 450 | # Remove `-o $object'. 451 | IFS=" " 452 | for arg 453 | do 454 | case $arg in 455 | -o) 456 | shift 457 | ;; 458 | $object) 459 | shift 460 | ;; 461 | *) 462 | set fnord "$@" "$arg" 463 | shift # fnord 464 | shift # $arg 465 | ;; 466 | esac 467 | done 468 | 469 | "$@" -E | 470 | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 471 | -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 472 | sed '$ s: \\$::' > "$tmpdepfile" 473 | rm -f "$depfile" 474 | echo "$object : \\" > "$depfile" 475 | cat < "$tmpdepfile" >> "$depfile" 476 | sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 477 | rm -f "$tmpdepfile" 478 | ;; 479 | 480 | msvisualcpp) 481 | # Important note: in order to support this mode, a compiler *must* 482 | # always write the preprocessed file to stdout, regardless of -o, 483 | # because we must use -o when running libtool. 484 | "$@" || exit $? 485 | IFS=" " 486 | for arg 487 | do 488 | case "$arg" in 489 | "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 490 | set fnord "$@" 491 | shift 492 | shift 493 | ;; 494 | *) 495 | set fnord "$@" "$arg" 496 | shift 497 | shift 498 | ;; 499 | esac 500 | done 501 | "$@" -E | 502 | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 503 | rm -f "$depfile" 504 | echo "$object : \\" > "$depfile" 505 | . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 506 | echo " " >> "$depfile" 507 | . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 508 | rm -f "$tmpdepfile" 509 | ;; 510 | 511 | none) 512 | exec "$@" 513 | ;; 514 | 515 | *) 516 | echo "Unknown depmode $depmode" 1>&2 517 | exit 1 518 | ;; 519 | esac 520 | 521 | exit 0 522 | 523 | # Local Variables: 524 | # mode: shell-script 525 | # sh-indentation: 2 526 | # eval: (add-hook 'write-file-hooks 'time-stamp) 527 | # time-stamp-start: "scriptversion=" 528 | # time-stamp-format: "%:y-%02m-%02d.%02H" 529 | # time-stamp-end: "$" 530 | # End: 531 | -------------------------------------------------------------------------------- /dist/Makefile.am: -------------------------------------------------------------------------------- 1 | imvirtp: imvirtp-core imvirtp-bundle 2 | 3 | imvirtp-core: ../imvirt ../perl/lib/ImVirt.pm ../perl/lib/ImVirt/*/*.pm 4 | pp -x -P -o imvirtp-core -I ../perl/lib ../imvirt 5 | 6 | imvirtp-bundle: ../imvirt ../perl/lib/ImVirt.pm ../perl/lib/ImVirt/*/*.pm 7 | pp -x -B -P -o imvirtp-bundle -I ../perl/lib ../imvirt 8 | -------------------------------------------------------------------------------- /dist/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.14.1 from Makefile.am. 2 | # @configure_input@ 3 | 4 | # Copyright (C) 1994-2013 Free Software Foundation, Inc. 5 | 6 | # This Makefile.in is free software; the Free Software Foundation 7 | # gives unlimited permission to copy and/or distribute it, 8 | # with or without modifications, as long as this notice is preserved. 9 | 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 12 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | # PARTICULAR PURPOSE. 14 | 15 | @SET_MAKE@ 16 | VPATH = @srcdir@ 17 | am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' 18 | am__make_running_with_option = \ 19 | case $${target_option-} in \ 20 | ?) ;; \ 21 | *) echo "am__make_running_with_option: internal error: invalid" \ 22 | "target option '$${target_option-}' specified" >&2; \ 23 | exit 1;; \ 24 | esac; \ 25 | has_opt=no; \ 26 | sane_makeflags=$$MAKEFLAGS; \ 27 | if $(am__is_gnu_make); then \ 28 | sane_makeflags=$$MFLAGS; \ 29 | else \ 30 | case $$MAKEFLAGS in \ 31 | *\\[\ \ ]*) \ 32 | bs=\\; \ 33 | sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ 34 | | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ 35 | esac; \ 36 | fi; \ 37 | skip_next=no; \ 38 | strip_trailopt () \ 39 | { \ 40 | flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ 41 | }; \ 42 | for flg in $$sane_makeflags; do \ 43 | test $$skip_next = yes && { skip_next=no; continue; }; \ 44 | case $$flg in \ 45 | *=*|--*) continue;; \ 46 | -*I) strip_trailopt 'I'; skip_next=yes;; \ 47 | -*I?*) strip_trailopt 'I';; \ 48 | -*O) strip_trailopt 'O'; skip_next=yes;; \ 49 | -*O?*) strip_trailopt 'O';; \ 50 | -*l) strip_trailopt 'l'; skip_next=yes;; \ 51 | -*l?*) strip_trailopt 'l';; \ 52 | -[dEDm]) skip_next=yes;; \ 53 | -[JT]) skip_next=yes;; \ 54 | esac; \ 55 | case $$flg in \ 56 | *$$target_option*) has_opt=yes; break;; \ 57 | esac; \ 58 | done; \ 59 | test $$has_opt = yes 60 | am__make_dryrun = (target_option=n; $(am__make_running_with_option)) 61 | am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 62 | pkgdatadir = $(datadir)/@PACKAGE@ 63 | pkgincludedir = $(includedir)/@PACKAGE@ 64 | pkglibdir = $(libdir)/@PACKAGE@ 65 | pkglibexecdir = $(libexecdir)/@PACKAGE@ 66 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 67 | install_sh_DATA = $(install_sh) -c -m 644 68 | install_sh_PROGRAM = $(install_sh) -c 69 | install_sh_SCRIPT = $(install_sh) -c 70 | INSTALL_HEADER = $(INSTALL_DATA) 71 | transform = $(program_transform_name) 72 | NORMAL_INSTALL = : 73 | PRE_INSTALL = : 74 | POST_INSTALL = : 75 | NORMAL_UNINSTALL = : 76 | PRE_UNINSTALL = : 77 | POST_UNINSTALL = : 78 | subdir = dist 79 | DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am 80 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 81 | am__aclocal_m4_deps = $(top_srcdir)/configure.in 82 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 83 | $(ACLOCAL_M4) 84 | mkinstalldirs = $(install_sh) -d 85 | CONFIG_HEADER = $(top_builddir)/helper/config.h 86 | CONFIG_CLEAN_FILES = 87 | CONFIG_CLEAN_VPATH_FILES = 88 | AM_V_P = $(am__v_P_@AM_V@) 89 | am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) 90 | am__v_P_0 = false 91 | am__v_P_1 = : 92 | AM_V_GEN = $(am__v_GEN_@AM_V@) 93 | am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) 94 | am__v_GEN_0 = @echo " GEN " $@; 95 | am__v_GEN_1 = 96 | AM_V_at = $(am__v_at_@AM_V@) 97 | am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) 98 | am__v_at_0 = @ 99 | am__v_at_1 = 100 | SOURCES = 101 | DIST_SOURCES = 102 | am__can_run_installinfo = \ 103 | case $$AM_UPDATE_INFO_DIR in \ 104 | n|no|NO) false;; \ 105 | *) (install-info --version) >/dev/null 2>&1;; \ 106 | esac 107 | am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) 108 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 109 | ACLOCAL = @ACLOCAL@ 110 | AMTAR = @AMTAR@ 111 | AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ 112 | AUTOCONF = @AUTOCONF@ 113 | AUTOHEADER = @AUTOHEADER@ 114 | AUTOMAKE = @AUTOMAKE@ 115 | AWK = @AWK@ 116 | CC = @CC@ 117 | CCDEPMODE = @CCDEPMODE@ 118 | CFLAGS = @CFLAGS@ 119 | CPP = @CPP@ 120 | CPPFLAGS = @CPPFLAGS@ 121 | CYGPATH_W = @CYGPATH_W@ 122 | DEFS = @DEFS@ 123 | DEPDIR = @DEPDIR@ 124 | ECHO_C = @ECHO_C@ 125 | ECHO_N = @ECHO_N@ 126 | ECHO_T = @ECHO_T@ 127 | EGREP = @EGREP@ 128 | EXEEXT = @EXEEXT@ 129 | GREP = @GREP@ 130 | INSTALL = @INSTALL@ 131 | INSTALL_DATA = @INSTALL_DATA@ 132 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 133 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 134 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 135 | LDFLAGS = @LDFLAGS@ 136 | LIBOBJS = @LIBOBJS@ 137 | LIBS = @LIBS@ 138 | LTLIBOBJS = @LTLIBOBJS@ 139 | MAKEINFO = @MAKEINFO@ 140 | MKDIR_P = @MKDIR_P@ 141 | MYDIR = @MYDIR@ 142 | OBJEXT = @OBJEXT@ 143 | PACKAGE = @PACKAGE@ 144 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 145 | PACKAGE_NAME = @PACKAGE_NAME@ 146 | PACKAGE_STRING = @PACKAGE_STRING@ 147 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ 148 | PACKAGE_URL = @PACKAGE_URL@ 149 | PACKAGE_VERSION = @PACKAGE_VERSION@ 150 | PATH_SEPARATOR = @PATH_SEPARATOR@ 151 | SET_MAKE = @SET_MAKE@ 152 | SHELL = @SHELL@ 153 | STRIP = @STRIP@ 154 | VERSION = @VERSION@ 155 | abs_builddir = @abs_builddir@ 156 | abs_srcdir = @abs_srcdir@ 157 | abs_top_builddir = @abs_top_builddir@ 158 | abs_top_srcdir = @abs_top_srcdir@ 159 | ac_ct_CC = @ac_ct_CC@ 160 | am__include = @am__include@ 161 | am__leading_dot = @am__leading_dot@ 162 | am__quote = @am__quote@ 163 | am__tar = @am__tar@ 164 | am__untar = @am__untar@ 165 | bindir = @bindir@ 166 | build_alias = @build_alias@ 167 | builddir = @builddir@ 168 | datadir = @datadir@ 169 | datarootdir = @datarootdir@ 170 | docdir = @docdir@ 171 | dvidir = @dvidir@ 172 | exec_prefix = @exec_prefix@ 173 | host_alias = @host_alias@ 174 | htmldir = @htmldir@ 175 | includedir = @includedir@ 176 | infodir = @infodir@ 177 | install_sh = @install_sh@ 178 | libdir = @libdir@ 179 | libexecdir = @libexecdir@ 180 | localedir = @localedir@ 181 | localstatedir = @localstatedir@ 182 | mandir = @mandir@ 183 | mkdir_p = @mkdir_p@ 184 | oldincludedir = @oldincludedir@ 185 | pdfdir = @pdfdir@ 186 | prefix = @prefix@ 187 | program_transform_name = @program_transform_name@ 188 | psdir = @psdir@ 189 | sbindir = @sbindir@ 190 | sharedstatedir = @sharedstatedir@ 191 | srcdir = @srcdir@ 192 | sysconfdir = @sysconfdir@ 193 | target_alias = @target_alias@ 194 | top_build_prefix = @top_build_prefix@ 195 | top_builddir = @top_builddir@ 196 | top_srcdir = @top_srcdir@ 197 | all: all-am 198 | 199 | .SUFFIXES: 200 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 201 | @for dep in $?; do \ 202 | case '$(am__configure_deps)' in \ 203 | *$$dep*) \ 204 | ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ 205 | && { if test -f $@; then exit 0; else break; fi; }; \ 206 | exit 1;; \ 207 | esac; \ 208 | done; \ 209 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu dist/Makefile'; \ 210 | $(am__cd) $(top_srcdir) && \ 211 | $(AUTOMAKE) --gnu dist/Makefile 212 | .PRECIOUS: Makefile 213 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 214 | @case '$?' in \ 215 | *config.status*) \ 216 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 217 | *) \ 218 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 219 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 220 | esac; 221 | 222 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 223 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 224 | 225 | $(top_srcdir)/configure: $(am__configure_deps) 226 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 227 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) 228 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 229 | $(am__aclocal_m4_deps): 230 | tags TAGS: 231 | 232 | ctags CTAGS: 233 | 234 | cscope cscopelist: 235 | 236 | 237 | distdir: $(DISTFILES) 238 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 239 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 240 | list='$(DISTFILES)'; \ 241 | dist_files=`for file in $$list; do echo $$file; done | \ 242 | sed -e "s|^$$srcdirstrip/||;t" \ 243 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 244 | case $$dist_files in \ 245 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 246 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 247 | sort -u` ;; \ 248 | esac; \ 249 | for file in $$dist_files; do \ 250 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 251 | if test -d $$d/$$file; then \ 252 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 253 | if test -d "$(distdir)/$$file"; then \ 254 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 255 | fi; \ 256 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 257 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 258 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 259 | fi; \ 260 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 261 | else \ 262 | test -f "$(distdir)/$$file" \ 263 | || cp -p $$d/$$file "$(distdir)/$$file" \ 264 | || exit 1; \ 265 | fi; \ 266 | done 267 | check-am: all-am 268 | check: check-am 269 | all-am: Makefile 270 | installdirs: 271 | install: install-am 272 | install-exec: install-exec-am 273 | install-data: install-data-am 274 | uninstall: uninstall-am 275 | 276 | install-am: all-am 277 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 278 | 279 | installcheck: installcheck-am 280 | install-strip: 281 | if test -z '$(STRIP)'; then \ 282 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 283 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 284 | install; \ 285 | else \ 286 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 287 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 288 | "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ 289 | fi 290 | mostlyclean-generic: 291 | 292 | clean-generic: 293 | 294 | distclean-generic: 295 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 296 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 297 | 298 | maintainer-clean-generic: 299 | @echo "This command is intended for maintainers to use" 300 | @echo "it deletes files that may require special tools to rebuild." 301 | clean: clean-am 302 | 303 | clean-am: clean-generic mostlyclean-am 304 | 305 | distclean: distclean-am 306 | -rm -f Makefile 307 | distclean-am: clean-am distclean-generic 308 | 309 | dvi: dvi-am 310 | 311 | dvi-am: 312 | 313 | html: html-am 314 | 315 | html-am: 316 | 317 | info: info-am 318 | 319 | info-am: 320 | 321 | install-data-am: 322 | 323 | install-dvi: install-dvi-am 324 | 325 | install-dvi-am: 326 | 327 | install-exec-am: 328 | 329 | install-html: install-html-am 330 | 331 | install-html-am: 332 | 333 | install-info: install-info-am 334 | 335 | install-info-am: 336 | 337 | install-man: 338 | 339 | install-pdf: install-pdf-am 340 | 341 | install-pdf-am: 342 | 343 | install-ps: install-ps-am 344 | 345 | install-ps-am: 346 | 347 | installcheck-am: 348 | 349 | maintainer-clean: maintainer-clean-am 350 | -rm -f Makefile 351 | maintainer-clean-am: distclean-am maintainer-clean-generic 352 | 353 | mostlyclean: mostlyclean-am 354 | 355 | mostlyclean-am: mostlyclean-generic 356 | 357 | pdf: pdf-am 358 | 359 | pdf-am: 360 | 361 | ps: ps-am 362 | 363 | ps-am: 364 | 365 | uninstall-am: 366 | 367 | .MAKE: install-am install-strip 368 | 369 | .PHONY: all all-am check check-am clean clean-generic cscopelist-am \ 370 | ctags-am distclean distclean-generic distdir dvi dvi-am html \ 371 | html-am info info-am install install-am install-data \ 372 | install-data-am install-dvi install-dvi-am install-exec \ 373 | install-exec-am install-html install-html-am install-info \ 374 | install-info-am install-man install-pdf install-pdf-am \ 375 | install-ps install-ps-am install-strip installcheck \ 376 | installcheck-am installdirs maintainer-clean \ 377 | maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ 378 | pdf-am ps ps-am tags-am uninstall uninstall-am 379 | 380 | imvirtp: imvirtp-core imvirtp-bundle 381 | 382 | imvirtp-core: ../imvirt ../perl/lib/ImVirt.pm ../perl/lib/ImVirt/*/*.pm 383 | pp -x -P -o imvirtp-core -I ../perl/lib ../imvirt 384 | 385 | imvirtp-bundle: ../imvirt ../perl/lib/ImVirt.pm ../perl/lib/ImVirt/*/*.pm 386 | pp -x -B -P -o imvirtp-bundle -I ../perl/lib ../imvirt 387 | 388 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 389 | # Otherwise a system limit (for SysV at least) may be exceeded. 390 | .NOEXPORT: 391 | -------------------------------------------------------------------------------- /helper/Makefile.am: -------------------------------------------------------------------------------- 1 | if X86ARCH 2 | pkglibexec_PROGRAMS = hvm hyperv vmware xen pillbox 3 | 4 | hvm_SOURCES = \ 5 | detect.c \ 6 | detect.h \ 7 | hvm.c 8 | 9 | hyperv_SOURCES = \ 10 | detect.c \ 11 | detect.h \ 12 | hyperv.c 13 | 14 | vmware_SOURCES = \ 15 | detect.c \ 16 | detect.h \ 17 | vmware.c 18 | 19 | xen_SOURCES = \ 20 | detect.c \ 21 | detect.h \ 22 | xen.c 23 | 24 | endif 25 | 26 | AM_CFLAGS = -Wall 27 | AM_LDFLAGS = -Wl,--as-needed 28 | -------------------------------------------------------------------------------- /helper/config.h.in: -------------------------------------------------------------------------------- 1 | /* helper/config.h.in. Generated from configure.in by autoheader. */ 2 | 3 | /* Define to 1 if you have the `fork' function. */ 4 | #undef HAVE_FORK 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_INTTYPES_H 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_MEMORY_H 11 | 12 | /* Define to 1 if you have the header file. */ 13 | #undef HAVE_STDINT_H 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_STDLIB_H 17 | 18 | /* Define to 1 if you have the header file. */ 19 | #undef HAVE_STRINGS_H 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_STRING_H 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #undef HAVE_SYS_STAT_H 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_SYS_TYPES_H 29 | 30 | /* Define to 1 if you have that is POSIX.1 compatible. */ 31 | #undef HAVE_SYS_WAIT_H 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_UNISTD_H 35 | 36 | /* Define to 1 if you have the `vfork' function. */ 37 | #undef HAVE_VFORK 38 | 39 | /* Define to 1 if you have the header file. */ 40 | #undef HAVE_VFORK_H 41 | 42 | /* Define to 1 if `fork' works. */ 43 | #undef HAVE_WORKING_FORK 44 | 45 | /* Define to 1 if `vfork' works. */ 46 | #undef HAVE_WORKING_VFORK 47 | 48 | /* Name of package */ 49 | #undef PACKAGE 50 | 51 | /* Define to the address where bug reports for this package should be sent. */ 52 | #undef PACKAGE_BUGREPORT 53 | 54 | /* Define to the full name of this package. */ 55 | #undef PACKAGE_NAME 56 | 57 | /* Define to the full name and version of this package. */ 58 | #undef PACKAGE_STRING 59 | 60 | /* Define to the one symbol short name of this package. */ 61 | #undef PACKAGE_TARNAME 62 | 63 | /* Define to the home page for this package. */ 64 | #undef PACKAGE_URL 65 | 66 | /* Define to the version of this package. */ 67 | #undef PACKAGE_VERSION 68 | 69 | /* Define as the return type of signal handlers (`int' or `void'). */ 70 | #undef RETSIGTYPE 71 | 72 | /* Define to 1 if you have the ANSI C header files. */ 73 | #undef STDC_HEADERS 74 | 75 | /* Version number of package */ 76 | #undef VERSION 77 | 78 | /* Define for Solaris 2.5.1 so the uint32_t typedef from , 79 | , or is not used. If the typedef were allowed, the 80 | #define below would cause a syntax error. */ 81 | #undef _UINT32_T 82 | 83 | /* Define to `int' if does not define. */ 84 | #undef pid_t 85 | 86 | /* Define to the type of an unsigned integer type of width exactly 16 bits if 87 | such a type exists and the standard includes do not define it. */ 88 | #undef uint16_t 89 | 90 | /* Define to the type of an unsigned integer type of width exactly 32 bits if 91 | such a type exists and the standard includes do not define it. */ 92 | #undef uint32_t 93 | 94 | /* Define as `fork' if `vfork' does not work. */ 95 | #undef vfork 96 | -------------------------------------------------------------------------------- /helper/detect.c: -------------------------------------------------------------------------------- 1 | /* imvirt / Generic detection code 2 | * 3 | * Authors: 4 | * Thomas Liske 5 | * 6 | * Copyright Holder: 7 | * 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | * 9 | * License: 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this package; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include "detect.h" 30 | 31 | int debug_cpuid = 0; 32 | 33 | void helper_main(int argc, char **argv) { 34 | int opts; 35 | 36 | while ((opts = getopt(argc, argv, "c")) != EOF) { 37 | switch(opts) { 38 | case 'c': 39 | debug_cpuid = 1; 40 | break; 41 | default: 42 | fprintf(stderr, "Usage: %s [-c]\n\t-c\tdebug CPUID calls\n\n", argv[0]); 43 | exit(1); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /helper/detect.h: -------------------------------------------------------------------------------- 1 | /* imvirt / Generic detection code 2 | * 3 | * Authors: 4 | * Thomas Liske 5 | * 6 | * Copyright Holder: 7 | * 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | * 9 | * License: 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this package; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #include "config.h" 26 | 27 | extern int debug_cpuid; 28 | 29 | void helper_main(int, char **); 30 | 31 | #if defined(__i386__) && defined(__PIC__) 32 | #define CPUID(leaf, eax, ebx, ecx, edx) \ 33 | __asm__ ( \ 34 | "xchgl %%ebx, %1;" \ 35 | "cpuid;" \ 36 | "xchgl %%ebx, %1" \ 37 | : "=a" (eax), "=r" (ebx), "=c" (ecx), "=d" (edx) \ 38 | : "0" (leaf)); \ 39 | if(debug_cpuid) fprintf(stderr, "%s:%d\tCPUID[0x%x]: eax=%d ebx=%d ecx=%d edx=%d\n", __FILE__, __LINE__, leaf, eax, ebx, ecx, edx) 40 | #else 41 | #define CPUID(leaf, eax, ebx, ecx, edx) \ 42 | __asm__ ( \ 43 | "cpuid" \ 44 | : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) \ 45 | : "0" (leaf)); \ 46 | if(debug_cpuid) fprintf(stderr, "%s:%d\tCPUID[0x%x]: eax=%d ebx=%d ecx=%d edx=%d\n", __FILE__, __LINE__, leaf, eax, ebx, ecx, edx) 47 | #endif 48 | -------------------------------------------------------------------------------- /helper/hvm.c: -------------------------------------------------------------------------------- 1 | /* imvirt / Generic HyperVisor Manager detection code 2 | * 3 | * Authors: 4 | * Thomas Liske 5 | * 6 | * Copyright Holder: 7 | * 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | * 9 | * License: 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this package; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include "detect.h" 30 | 31 | int main(int argc, char **argv) { 32 | helper_main(argc, argv); 33 | 34 | uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0; 35 | char signature[13]; 36 | 37 | CPUID(0x40000000, eax, ebx, ecx, edx); 38 | memcpy(&signature[0], &ebx, 4); 39 | memcpy(&signature[4], &ecx, 4); 40 | memcpy(&signature[8], &edx, 4); 41 | signature[12] = 0; 42 | 43 | /* P4 reports '@' */ 44 | if((eax == 64) && 45 | (ebx == 64) && 46 | (ecx == 0) && 47 | (edx == 0)) 48 | return 0; 49 | 50 | if(strlen(signature) && isprint(signature[0])) { 51 | printf("%s\n", signature); 52 | return 1; 53 | } 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /helper/hyperv.c: -------------------------------------------------------------------------------- 1 | /* imvirt / HyperV detection code 2 | * 3 | * Authors: 4 | * Thomas Liske 5 | * 6 | * Copyright Holder: 7 | * 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | * 9 | * License: 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this package; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include "detect.h" 31 | 32 | int main(int argc, char **argv) { 33 | helper_main(argc, argv); 34 | 35 | uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0; 36 | char signature[13]; 37 | 38 | CPUID(0x40000000, eax, ebx, ecx, edx); 39 | memcpy(&signature[0], &ebx, 4); 40 | memcpy(&signature[4], &ecx, 4); 41 | memcpy(&signature[8], &edx, 4); 42 | signature[12] = 0; 43 | 44 | if(!strcmp(signature, "Microsoft Hv")) { 45 | printf("Virtual Machine\n"); 46 | return 1; 47 | } 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /helper/pillbox.c: -------------------------------------------------------------------------------- 1 | /* imvirt / pillbox - retrieve several unprivileged registers 2 | * 3 | * Authors: 4 | * Thomas Liske 5 | * 6 | * Copyright Holder: 7 | * 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | * 9 | * License: 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this package; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | #define _GNU_SOURCE 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | void sidt() { 33 | volatile uint64_t idt = 0; 34 | 35 | asm("sidt %0" : :"m"(idt)); 36 | volatile uint64_t old = idt; 37 | 38 | unsigned int i; 39 | for(i=0; i<0xffffff; i++) { 40 | asm("sidt %0" : :"m"(idt)); 41 | 42 | if(old != idt) { 43 | printf(",idt,%" PRIu64 ",idt2,%" PRIu64, old, idt); 44 | return; 45 | } 46 | } 47 | 48 | printf(",idt,%" PRIu64, old); 49 | } 50 | 51 | void sgdt() { 52 | volatile uint64_t gdt = 0; 53 | 54 | asm("sgdt %0" : :"m"(gdt)); 55 | volatile uint64_t old = gdt; 56 | 57 | unsigned int i; 58 | for(i=0; i<0xffffff; i++) { 59 | asm("sgdt %0" : :"m"(gdt)); 60 | 61 | if(old != gdt) { 62 | printf(",gdt,%" PRIu64 ",gdt2,%" PRIu64, old, gdt); 63 | return; 64 | } 65 | } 66 | 67 | printf(",gdt,%" PRIu64, old); 68 | } 69 | 70 | void sldt() { 71 | volatile uint64_t ldt = 0; 72 | 73 | asm("sldt %0" : :"m"(ldt)); 74 | 75 | printf(",ldt,%" PRIu64, ldt); 76 | } 77 | 78 | void str() { 79 | volatile uint64_t tr = 0; 80 | 81 | asm("str %0" : :"m"(tr)); 82 | 83 | printf(",tr,%" PRIu64, tr); 84 | } 85 | 86 | int main () { 87 | /* Some of the tests need to be run on the same CPU. */ 88 | cpu_set_t mask; 89 | 90 | if(sched_getaffinity(0, sizeof(mask), &mask) < 0) { 91 | perror("sched_getaffinity"); 92 | return -1; 93 | } 94 | 95 | /* Bind onto first online cpu. */ 96 | int n; 97 | for(n = 0; n < CPU_SETSIZE; n++) { 98 | if(CPU_ISSET(n, &mask)) { 99 | CPU_ZERO(&mask); 100 | CPU_SET(n, &mask); 101 | break; 102 | } 103 | } 104 | if(!CPU_ISSET(n, &mask)) { 105 | fprintf(stderr, "Oops, could not find an online CPU!\n"); 106 | return -1; 107 | } 108 | 109 | if (sched_setaffinity(0, sizeof(mask), &mask) < 0) { 110 | perror("sched_setaffinity"); 111 | return -1; 112 | } 113 | 114 | printf("cpu,%d", n); 115 | 116 | sidt(); 117 | sgdt(); 118 | sldt(); 119 | str(); 120 | 121 | printf("\n"); 122 | 123 | exit(0); 124 | } 125 | -------------------------------------------------------------------------------- /helper/vmware.c: -------------------------------------------------------------------------------- 1 | /* imvirt / VMware detection code 2 | * 3 | * Authors: 4 | * Thomas Liske 5 | * 6 | * Copyright Holder: 7 | * 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | * 9 | * License: 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this package; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | */ 24 | 25 | /* This code tries to detect the VMware version using the VMware backdoor's 26 | * GETVERSION command (http://chitchat.at.infoseek.co.jp/vmware/backdoor.html#cmd0ah). 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include "detect.h" 38 | 39 | #define VMWARE_MAGIC 0x564d5868 40 | #define VMWARE_PORT 0x5658 41 | 42 | #define VMWARE_CMD_GETVERSION 0x0a 43 | 44 | #if defined(__i386__) && defined(__PIC__) 45 | #define VMWARE_CMD(eax, ebx, ecx, edx) \ 46 | __asm__( \ 47 | "xchgl %%ebx, %1;" \ 48 | "inl (%%dx);" \ 49 | "xchgl %%ebx, %1" \ 50 | : "+a"(eax), "+r"(ebx), "+c"(ecx), "+d"(edx) \ 51 | ); 52 | #else 53 | #define VMWARE_CMD(eax, ebx, ecx, edx) \ 54 | __asm__("inl (%%dx)" \ 55 | : "+a"(eax), "+b"(ebx), "+c"(ecx), "+d"(edx) \ 56 | ); 57 | #endif 58 | 59 | static void vmware_cmd(uint32_t cmd, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { 60 | *eax = VMWARE_MAGIC; 61 | *ebx = 0xffffffff; 62 | *ecx = cmd; 63 | *edx = VMWARE_PORT; 64 | 65 | VMWARE_CMD(*eax, *ebx, *ecx, *edx); 66 | } 67 | 68 | static void sigh(int signum) { 69 | exit(0); 70 | } 71 | 72 | static int do_vmware() { 73 | uint32_t eax, ebx, ecx, edx; 74 | struct sigaction sa; 75 | 76 | /* ignore SIGSEGV (VMWARE_CMD will cause a SEGV on none VMware systems) */ 77 | sa.sa_handler = sigh; 78 | sigemptyset(&sa.sa_mask); 79 | sa.sa_flags = 0; 80 | sigaction(SIGSEGV, &sa, NULL); 81 | 82 | vmware_cmd(VMWARE_CMD_GETVERSION, &eax, &ebx, &ecx, &edx); 83 | 84 | /* sanity check: maybe VMWARE_CMD did not SEGV if there was something 85 | * on the I/O port - test if EBX has been set to VMWARE_MAGIC */ 86 | if ((uint32_t)-1 && ebx == VMWARE_MAGIC) { 87 | char *product; 88 | 89 | switch(ecx) { 90 | case 0x01: 91 | product = "Express"; 92 | break; 93 | case 0x02: 94 | product = "ESX Server"; 95 | break; 96 | case 0x03: 97 | product = "GSX Server"; 98 | break; 99 | case 0x04: 100 | product = "Workstation"; 101 | break; 102 | default: 103 | product = "?"; 104 | break; 105 | } 106 | 107 | printf("%s\n", product); 108 | 109 | return 1; 110 | } 111 | 112 | return 0; 113 | } 114 | 115 | int main(int argc, char **argv) { 116 | helper_main(argc, argv); 117 | 118 | pid_t pid = fork(); 119 | switch (pid) { 120 | case 0: 121 | exit(do_vmware()); 122 | case -1: 123 | return 0; 124 | } 125 | 126 | int status; 127 | waitpid(pid, &status, 0); 128 | if (WIFEXITED(status)) 129 | return WEXITSTATUS(status); 130 | 131 | return 0; 132 | } 133 | -------------------------------------------------------------------------------- /helper/xen.c: -------------------------------------------------------------------------------- 1 | /* imvirt / Xen detection code 2 | * 3 | * This file has been taken from XenSource's xen_detect.c with some small 4 | * changes to fit imvirt requirements on output / return codes. 5 | * 6 | * 7 | * xen_detect.c 8 | * 9 | * Simple GNU C / POSIX application to detect execution on Xen VMM platform. 10 | * 11 | * Copyright (c) 2007, XenSource Inc. 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to 15 | * deal in the Software without restriction, including without limitation the 16 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 17 | * sell copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29 | * DEALINGS IN THE SOFTWARE. 30 | */ 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include "detect.h" 41 | 42 | static int pv_context; 43 | 44 | #if defined(__i386__) && defined(__PIC__) 45 | static void cpuid(uint32_t idx, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { 46 | asm volatile ( 47 | "test %1,%1 ; jz 1f ; ud2a ; .ascii \"xen\" ; 1: xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1" 48 | : "=a" (*eax), "=r" (*ebx), "=c" (*ecx), "=d" (*edx) 49 | : "0" (idx), "1" (pv_context) 50 | ); 51 | } 52 | #else 53 | static void cpuid(uint32_t idx, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { 54 | asm volatile ( 55 | "test %1,%1 ; jz 1f ; ud2a ; .ascii \"xen\" ; 1: cpuid" 56 | : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) 57 | : "0" (idx), "1" (pv_context) 58 | ); 59 | } 60 | #endif 61 | 62 | static int check_for_xen(void) { 63 | uint32_t eax, ebx, ecx, edx; 64 | char signature[13]; 65 | 66 | cpuid(0x40000000, &eax, &ebx, &ecx, &edx); 67 | memcpy(&signature[0], &ebx, 4); 68 | memcpy(&signature[4], &ecx, 4); 69 | memcpy(&signature[8], &edx, 4); 70 | signature[12] = '\0'; 71 | 72 | if (strcmp("XenVMMXenVMM", signature) || (eax < 0x40000002)) 73 | return 0; 74 | 75 | cpuid(0x40000001, &eax, &ebx, &ecx, &edx); 76 | printf("%s %d.%d\n", 77 | pv_context ? "PV" : "HVM", 78 | (uint16_t)(eax >> 16), (uint16_t)eax); 79 | 80 | return 1; 81 | } 82 | 83 | static void sigh(int signum) { 84 | exit(0); 85 | } 86 | 87 | int main(int argc, char **argv) { 88 | helper_main(argc, argv); 89 | 90 | pid_t pid; 91 | int status; 92 | uint32_t dummy; 93 | 94 | /* Check for execution in HVM context. */ 95 | if (check_for_xen()) 96 | return 1; 97 | 98 | /* Now we check for execution in PV context. */ 99 | pv_context = 1; 100 | 101 | /* 102 | * Fork a child to test the paravirtualised CPUID instruction. 103 | * If executed outside Xen PV context, the extended opcode will fault. 104 | */ 105 | pid = fork(); 106 | switch ( pid ) 107 | { 108 | case 0: 109 | /* ignore SIGILL on amd64 */ 110 | { 111 | struct sigaction sa; 112 | 113 | sa.sa_handler = sigh; 114 | sigemptyset(&sa.sa_mask); 115 | sa.sa_flags = 0; 116 | sigaction(SIGILL, &sa, NULL); 117 | } 118 | 119 | /* Child: test paravirtualised CPUID opcode and then exit cleanly. */ 120 | cpuid(0x40000000, &dummy, &dummy, &dummy, &dummy); 121 | exit(1); 122 | case -1: 123 | return 0; 124 | } 125 | 126 | /* 127 | * Parent waits for child to terminate and checks for clean exit. 128 | * Only if the exit is clean is it safe for us to try the extended CPUID. 129 | */ 130 | waitpid(pid, &status, 0); 131 | if ( WIFEXITED(status) && WEXITSTATUS(status) && check_for_xen() ) 132 | return 0; 133 | 134 | return 0; 135 | } 136 | -------------------------------------------------------------------------------- /imvirt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # imvirt - I'm virtualized? 4 | # 5 | # Authors: 6 | # Thomas Liske 7 | # 8 | # Copyright Holder: 9 | # 2008 - 2014 (C) IBH IT-Service GmbH [http://www.ibh.de/] 10 | # 11 | # License: 12 | # This program is free software; you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation; either version 2 of the License, or 15 | # (at your option) any later version. 16 | # 17 | # This program is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | # GNU General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU General Public License 23 | # along with this package; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 25 | # 26 | 27 | use strict; 28 | use warnings; 29 | use ImVirt; 30 | use Getopt::Long; 31 | 32 | sub HELP_MESSAGE { 33 | my $prod = 'ImVirt'; 34 | $prod .= ' Portable' if(exists($ENV{PAR_0}) && __FILE__ =~ /^script\//); 35 | 36 | print STDERR < 41 | 42 | Copyright Holder: 43 | 2008 - 2014 (C) IBH IT-Service GmbH [http://www.ibh.de/] 44 | 45 | License: 46 | This program is free software; you can redistribute it and/or modify 47 | it under the terms of the GNU General Public License as published by 48 | the Free Software Foundation; either version 2 of the License, or 49 | (at your option) any later version. 50 | 51 | About: 52 | imvirt tries to detect if it runs on a physical machine or on a 53 | virtualized one. If it detects that it is a virtualized one it also 54 | tries to find out which virtualization technology is used. 55 | 56 | Usage: 57 | imvirt [-d] [-c|-m] 58 | -d enable debug output 59 | -c detect virtualization containers only 60 | -m detect virtual machines only 61 | 62 | Output (virtualization containers): 63 | EOH 64 | #' 65 | 66 | print " ",join("\n ", imv_get_pos_results_vc()),"\n\n"; 67 | 68 | print "Output (virtual machines):\n"; 69 | print " ",join("\n ", imv_get_pos_results_vm()),"\n\n"; 70 | 71 | exit; 72 | } 73 | 74 | my %opts; 75 | my $mode; 76 | GetOptions( 77 | 'd' => sub { ImVirt::set_debug(1); }, 78 | 'c' => sub { $mode .= 'c'; }, 79 | 'm' => sub { $mode .= 'm'; }, 80 | help => sub { HELP_MESSAGE(); }, 81 | ) or HELP_MESSAGE(); 82 | 83 | $mode = 'cm' unless(defined($mode)); 84 | 85 | my $vc = ($mode =~ /c/ ? imv_get_vc(IMV_PROB_DEFAULT) : IMV_NONE); 86 | if($vc ne IMV_NONE) { 87 | print "$vc\n"; 88 | } 89 | else { 90 | if($mode =~ /m/) { 91 | print imv_get_vm(IMV_PROB_DEFAULT),"\n"; 92 | } 93 | else { 94 | print IMV_NONE,"\n"; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /imvirt-report: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # imvirt - I'm virtualized? 4 | # 5 | # Authors: 6 | # Thomas Liske 7 | # 8 | # Copyright Holder: 9 | # 2012 - 2014 (C) IBH IT-Service GmbH [http://www.ibh.de/] 10 | # 11 | # License: 12 | # This program is free software; you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation; either version 2 of the License, or 15 | # (at your option) any later version. 16 | # 17 | # This program is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | # GNU General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU General Public License 23 | # along with this package; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 25 | # 26 | 27 | use strict; 28 | use warnings; 29 | use Getopt::Std; 30 | use MIME::Lite; 31 | use ImVirt; 32 | 33 | $|++; 34 | 35 | eval 'use File::Which;'; 36 | my $nowhich = $@; 37 | 38 | 39 | my $hostname = `hostname -f`; 40 | chomp($hostname); 41 | 42 | $Getopt::Std::STANDARD_HELP_VERSION++; 43 | 44 | sub HELP_MESSAGE { 45 | print <] 54 | 55 | -s where to write the collected data 56 | 57 | USG 58 | } 59 | 60 | sub VERSION_MESSAGE { 61 | print < 66 | 67 | Copyright Holder: 68 | 2008 - 2014 (C) IBH IT-Service GmbH [http://www.ibh.de/] 69 | 70 | License: 71 | This program is free software; you can redistribute it and/or modify 72 | it under the terms of the GNU General Public License as published by 73 | the Free Software Foundation; either version 2 of the License, or 74 | (at your option) any later version. 75 | 76 | LIC 77 | #' 78 | } 79 | 80 | our $opt_s = "imvirt-report_${hostname}_$$.eml"; 81 | getopts('s:') || exit(1); 82 | 83 | my $ivout = imv_get(IMV_PROB_DEFAULT); 84 | 85 | my $msg = MIME::Lite->new( 86 | Subject => $hostname, 87 | Type => 'multipart/mixed', 88 | ); 89 | 90 | $msg->attach( 91 | Type => 'TEXT', 92 | Data => "Hostname: $hostname\nImVirt Version: $ImVirt::VERSION\nImVirt Output: $ivout\n", 93 | ); 94 | 95 | sub attach_path($$) { 96 | my ($msg, $glob) = @_; 97 | 98 | foreach my $path (glob $glob) { 99 | my $fn = $path; 100 | $fn =~ s@/@_@g; 101 | 102 | unless (-r $path) { 103 | $msg->attach( 104 | Type => 'TEXT', 105 | Data => "File $path not readable!", 106 | Filename => $fn, 107 | ); 108 | } 109 | else { 110 | print STDERR " Attaching '$path'.\n"; 111 | $msg->attach( 112 | Type => 'TEXT', 113 | Path => $path, 114 | Filename => $fn, 115 | ); 116 | } 117 | } 118 | } 119 | 120 | sub attach_cmd($$$) { 121 | my ($msg, $cmd, $params) = @_; 122 | my $run = ($nowhich ne '' ? $cmd : which($cmd)); 123 | 124 | unless (defined($run)) { 125 | $msg->attach( 126 | Type => 'TEXT', 127 | Data => "Command $cmd not available!", 128 | Filename => $cmd, 129 | ); 130 | 131 | return; 132 | } 133 | 134 | print STDERR " Attaching `$cmd $params`.\n"; 135 | $msg->attach( 136 | Type => 'TEXT', 137 | Data => scalar `$run $params 2>&1`, 138 | Filename => $cmd, 139 | ); 140 | } 141 | 142 | print STDERR "Collecting data...\n"; 143 | 144 | attach_path($msg, '/proc/1/cgroup'); 145 | attach_path($msg, '/proc/1/environ'); 146 | attach_path($msg, '/proc/1/stat'); 147 | attach_path($msg, '/proc/cmdline'); 148 | attach_path($msg, '/proc/cpuinfo'); 149 | attach_path($msg, '/proc/kallsyms'); 150 | attach_path($msg, '/proc/mounts'); 151 | attach_path($msg, '/proc/modules'); 152 | attach_path($msg, '/proc/bus/input/devices'); 153 | attach_path($msg, '/proc/uptime'); 154 | attach_path($msg, '/proc/timer_list'); 155 | attach_path($msg, '/sys/devices/system/clocksource/clocksource*/available_clocksource'); 156 | attach_path($msg, '/sys/devices/system/cpu/cpu*/cpufreq/scaling_driver'); 157 | attach_path($msg, '/var/log/dmesg'); 158 | 159 | attach_cmd($msg, 'dmesg', ''); 160 | attach_cmd($msg, 'dmidecode', ''); 161 | attach_cmd($msg, 'find', '/dev'); 162 | attach_cmd($msg, 'find', '/proc'); 163 | attach_cmd($msg, 'find', '/sys'); 164 | attach_cmd($msg, 'imvirt', '-d'); 165 | attach_cmd($msg, 'lsb_release', '-a'); 166 | attach_cmd($msg, 'lspci', ''); 167 | attach_cmd($msg, 'uname', '-a'); 168 | 169 | 170 | open(HSAVE, '>', $opt_s) || die "Could not open $opt_s: $!\n"; 171 | $msg->print(\*HSAVE); 172 | close(HSAVE); 173 | 174 | print STDERR "Data saved to '$opt_s'.\n"; 175 | -------------------------------------------------------------------------------- /imvirt.spec.in: -------------------------------------------------------------------------------- 1 | %define name @PACKAGE@ 2 | %define version @PACKAGE_VERSION@ 3 | %define release 1 4 | 5 | Name: %{name} 6 | Summary: Detects several virtualizations 7 | Version: %{version} 8 | Release: %{release} 9 | URL: http://micky.ibh.net/~liske/imvirt.html 10 | Source0: http://downloads.sourceforge.net/project/%{name}/%{name}/%{version}/%{name}-%{version}.tar.gz 11 | License: GPLv2+ 12 | Group: Applications/System 13 | Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) 14 | BuildRequires: perl(ExtUtils::MakeMaker) 15 | Buildroot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) 16 | Vendor: IBH IT-Service GmbH (http://www.ibh.de/) 17 | 18 | %description 19 | 20 | This little Perl script tries to detect if it is called from within 21 | a virtualization container. This is detected by looking for well known boot 22 | messages, directories and reading DMI (Desktop Management Interface) data. 23 | 24 | The following containers are detected: 25 | 26 | * ARAnyM 27 | * KVM 28 | * lguest 29 | * LXC 30 | * OpenVZ/Virtuozzo 31 | * QEMU 32 | * UML 33 | * VMware GSX, ESX, Workstation 34 | * Virtual PC/Virtual Server 35 | * VirtualBox 36 | * Xen (para and non-para virtualized) 37 | * any HVM providing CPUID 0x40000000 detection 38 | 39 | %prep 40 | %setup -q 41 | 42 | %build 43 | 44 | %configure --prefix=%{_prefix} --libexec=%{_libexecdir}/imvirt 45 | make %{?_smp_mflags} 46 | 47 | %install 48 | rm -rf $RPM_BUILD_ROOT 49 | make install DESTDIR=$RPM_BUILD_ROOT 50 | 51 | rm $RPM_BUILD_ROOT%{perl_vendorarch}/auto/ImVirt/.packlist 52 | rm $RPM_BUILD_ROOT%{perl_archlib}/perllocal.pod 53 | 54 | %check 55 | #make check 56 | 57 | %clean 58 | rm -rf $RPM_BUILD_ROOT 59 | make clean 60 | 61 | %files 62 | %defattr(-,root,root,-) 63 | %{_bindir}/* 64 | %{_sbindir}/* 65 | %dir %{_libexecdir}/imvirt 66 | %{_libexecdir}/imvirt/* 67 | %doc AUTHORS COPYING ChangeLog README 68 | %{_mandir}/man1/*.1* 69 | %{_mandir}/man3/*.3* 70 | %{perl_vendorlib}/* 71 | -------------------------------------------------------------------------------- /install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # install - install a program, script, or datafile 3 | 4 | scriptversion=2005-05-14.22 5 | 6 | # This originates from X11R5 (mit/util/scripts/install.sh), which was 7 | # later released in X11R6 (xc/config/util/install.sh) with the 8 | # following copyright and license. 9 | # 10 | # Copyright (C) 1994 X Consortium 11 | # 12 | # Permission is hereby granted, free of charge, to any person obtaining a copy 13 | # of this software and associated documentation files (the "Software"), to 14 | # deal in the Software without restriction, including without limitation the 15 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 16 | # sell copies of the Software, and to permit persons to whom the Software is 17 | # furnished to do so, subject to the following conditions: 18 | # 19 | # The above copyright notice and this permission notice shall be included in 20 | # all copies or substantial portions of the Software. 21 | # 22 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 26 | # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- 27 | # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | # 29 | # Except as contained in this notice, the name of the X Consortium shall not 30 | # be used in advertising or otherwise to promote the sale, use or other deal- 31 | # ings in this Software without prior written authorization from the X Consor- 32 | # tium. 33 | # 34 | # 35 | # FSF changes to this file are in the public domain. 36 | # 37 | # Calling this script install-sh is preferred over install.sh, to prevent 38 | # `make' implicit rules from creating a file called install from it 39 | # when there is no Makefile. 40 | # 41 | # This script is compatible with the BSD install script, but was written 42 | # from scratch. It can only install one file at a time, a restriction 43 | # shared with many OS's install programs. 44 | 45 | # set DOITPROG to echo to test this script 46 | 47 | # Don't use :- since 4.3BSD and earlier shells don't like it. 48 | doit="${DOITPROG-}" 49 | 50 | # put in absolute paths if you don't have them in your path; or use env. vars. 51 | 52 | mvprog="${MVPROG-mv}" 53 | cpprog="${CPPROG-cp}" 54 | chmodprog="${CHMODPROG-chmod}" 55 | chownprog="${CHOWNPROG-chown}" 56 | chgrpprog="${CHGRPPROG-chgrp}" 57 | stripprog="${STRIPPROG-strip}" 58 | rmprog="${RMPROG-rm}" 59 | mkdirprog="${MKDIRPROG-mkdir}" 60 | 61 | chmodcmd="$chmodprog 0755" 62 | chowncmd= 63 | chgrpcmd= 64 | stripcmd= 65 | rmcmd="$rmprog -f" 66 | mvcmd="$mvprog" 67 | src= 68 | dst= 69 | dir_arg= 70 | dstarg= 71 | no_target_directory= 72 | 73 | usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE 74 | or: $0 [OPTION]... SRCFILES... DIRECTORY 75 | or: $0 [OPTION]... -t DIRECTORY SRCFILES... 76 | or: $0 [OPTION]... -d DIRECTORIES... 77 | 78 | In the 1st form, copy SRCFILE to DSTFILE. 79 | In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. 80 | In the 4th, create DIRECTORIES. 81 | 82 | Options: 83 | -c (ignored) 84 | -d create directories instead of installing files. 85 | -g GROUP $chgrpprog installed files to GROUP. 86 | -m MODE $chmodprog installed files to MODE. 87 | -o USER $chownprog installed files to USER. 88 | -s $stripprog installed files. 89 | -t DIRECTORY install into DIRECTORY. 90 | -T report an error if DSTFILE is a directory. 91 | --help display this help and exit. 92 | --version display version info and exit. 93 | 94 | Environment variables override the default commands: 95 | CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG 96 | " 97 | 98 | while test -n "$1"; do 99 | case $1 in 100 | -c) shift 101 | continue;; 102 | 103 | -d) dir_arg=true 104 | shift 105 | continue;; 106 | 107 | -g) chgrpcmd="$chgrpprog $2" 108 | shift 109 | shift 110 | continue;; 111 | 112 | --help) echo "$usage"; exit $?;; 113 | 114 | -m) chmodcmd="$chmodprog $2" 115 | shift 116 | shift 117 | continue;; 118 | 119 | -o) chowncmd="$chownprog $2" 120 | shift 121 | shift 122 | continue;; 123 | 124 | -s) stripcmd=$stripprog 125 | shift 126 | continue;; 127 | 128 | -t) dstarg=$2 129 | shift 130 | shift 131 | continue;; 132 | 133 | -T) no_target_directory=true 134 | shift 135 | continue;; 136 | 137 | --version) echo "$0 $scriptversion"; exit $?;; 138 | 139 | *) # When -d is used, all remaining arguments are directories to create. 140 | # When -t is used, the destination is already specified. 141 | test -n "$dir_arg$dstarg" && break 142 | # Otherwise, the last argument is the destination. Remove it from $@. 143 | for arg 144 | do 145 | if test -n "$dstarg"; then 146 | # $@ is not empty: it contains at least $arg. 147 | set fnord "$@" "$dstarg" 148 | shift # fnord 149 | fi 150 | shift # arg 151 | dstarg=$arg 152 | done 153 | break;; 154 | esac 155 | done 156 | 157 | if test -z "$1"; then 158 | if test -z "$dir_arg"; then 159 | echo "$0: no input file specified." >&2 160 | exit 1 161 | fi 162 | # It's OK to call `install-sh -d' without argument. 163 | # This can happen when creating conditional directories. 164 | exit 0 165 | fi 166 | 167 | for src 168 | do 169 | # Protect names starting with `-'. 170 | case $src in 171 | -*) src=./$src ;; 172 | esac 173 | 174 | if test -n "$dir_arg"; then 175 | dst=$src 176 | src= 177 | 178 | if test -d "$dst"; then 179 | mkdircmd=: 180 | chmodcmd= 181 | else 182 | mkdircmd=$mkdirprog 183 | fi 184 | else 185 | # Waiting for this to be detected by the "$cpprog $src $dsttmp" command 186 | # might cause directories to be created, which would be especially bad 187 | # if $src (and thus $dsttmp) contains '*'. 188 | if test ! -f "$src" && test ! -d "$src"; then 189 | echo "$0: $src does not exist." >&2 190 | exit 1 191 | fi 192 | 193 | if test -z "$dstarg"; then 194 | echo "$0: no destination specified." >&2 195 | exit 1 196 | fi 197 | 198 | dst=$dstarg 199 | # Protect names starting with `-'. 200 | case $dst in 201 | -*) dst=./$dst ;; 202 | esac 203 | 204 | # If destination is a directory, append the input filename; won't work 205 | # if double slashes aren't ignored. 206 | if test -d "$dst"; then 207 | if test -n "$no_target_directory"; then 208 | echo "$0: $dstarg: Is a directory" >&2 209 | exit 1 210 | fi 211 | dst=$dst/`basename "$src"` 212 | fi 213 | fi 214 | 215 | # This sed command emulates the dirname command. 216 | dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'` 217 | 218 | # Make sure that the destination directory exists. 219 | 220 | # Skip lots of stat calls in the usual case. 221 | if test ! -d "$dstdir"; then 222 | defaultIFS=' 223 | ' 224 | IFS="${IFS-$defaultIFS}" 225 | 226 | oIFS=$IFS 227 | # Some sh's can't handle IFS=/ for some reason. 228 | IFS='%' 229 | set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` 230 | shift 231 | IFS=$oIFS 232 | 233 | pathcomp= 234 | 235 | while test $# -ne 0 ; do 236 | pathcomp=$pathcomp$1 237 | shift 238 | if test ! -d "$pathcomp"; then 239 | $mkdirprog "$pathcomp" 240 | # mkdir can fail with a `File exist' error in case several 241 | # install-sh are creating the directory concurrently. This 242 | # is OK. 243 | test -d "$pathcomp" || exit 244 | fi 245 | pathcomp=$pathcomp/ 246 | done 247 | fi 248 | 249 | if test -n "$dir_arg"; then 250 | $doit $mkdircmd "$dst" \ 251 | && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ 252 | && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ 253 | && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ 254 | && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } 255 | 256 | else 257 | dstfile=`basename "$dst"` 258 | 259 | # Make a couple of temp file names in the proper directory. 260 | dsttmp=$dstdir/_inst.$$_ 261 | rmtmp=$dstdir/_rm.$$_ 262 | 263 | # Trap to clean up those temp files at exit. 264 | trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 265 | trap '(exit $?); exit' 1 2 13 15 266 | 267 | # Copy the file name to the temp name. 268 | $doit $cpprog "$src" "$dsttmp" && 269 | 270 | # and set any options; do chmod last to preserve setuid bits. 271 | # 272 | # If any of these fail, we abort the whole thing. If we want to 273 | # ignore errors from any of these, just make sure not to ignore 274 | # errors from the above "$doit $cpprog $src $dsttmp" command. 275 | # 276 | { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ 277 | && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ 278 | && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ 279 | && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && 280 | 281 | # Now rename the file to the real destination. 282 | { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \ 283 | || { 284 | # The rename failed, perhaps because mv can't rename something else 285 | # to itself, or perhaps because mv is so ancient that it does not 286 | # support -f. 287 | 288 | # Now remove or move aside any old file at destination location. 289 | # We try this two ways since rm can't unlink itself on some 290 | # systems and the destination file might be busy for other 291 | # reasons. In this case, the final cleanup might fail but the new 292 | # file should still install successfully. 293 | { 294 | if test -f "$dstdir/$dstfile"; then 295 | $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ 296 | || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ 297 | || { 298 | echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 299 | (exit 1); exit 1 300 | } 301 | else 302 | : 303 | fi 304 | } && 305 | 306 | # Now rename the file to the real destination. 307 | $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" 308 | } 309 | } 310 | fi || { (exit 1); exit 1; } 311 | done 312 | 313 | # The final little trick to "correctly" pass the exit status to the exit trap. 314 | { 315 | (exit 0); exit 0 316 | } 317 | 318 | # Local variables: 319 | # eval: (add-hook 'write-file-hooks 'time-stamp) 320 | # time-stamp-start: "scriptversion=" 321 | # time-stamp-format: "%:y-%02m-%02d.%02H" 322 | # time-stamp-end: "$" 323 | # End: 324 | -------------------------------------------------------------------------------- /man/Makefile.am: -------------------------------------------------------------------------------- 1 | man_MANS=imvirt.1 imvirt-report.1 2 | 3 | EXTRA_DIST=$(man_MANS) 4 | 5 | %.1: 6 | 7 | -------------------------------------------------------------------------------- /man/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.14.1 from Makefile.am. 2 | # @configure_input@ 3 | 4 | # Copyright (C) 1994-2013 Free Software Foundation, Inc. 5 | 6 | # This Makefile.in is free software; the Free Software Foundation 7 | # gives unlimited permission to copy and/or distribute it, 8 | # with or without modifications, as long as this notice is preserved. 9 | 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 12 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | # PARTICULAR PURPOSE. 14 | 15 | @SET_MAKE@ 16 | VPATH = @srcdir@ 17 | am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' 18 | am__make_running_with_option = \ 19 | case $${target_option-} in \ 20 | ?) ;; \ 21 | *) echo "am__make_running_with_option: internal error: invalid" \ 22 | "target option '$${target_option-}' specified" >&2; \ 23 | exit 1;; \ 24 | esac; \ 25 | has_opt=no; \ 26 | sane_makeflags=$$MAKEFLAGS; \ 27 | if $(am__is_gnu_make); then \ 28 | sane_makeflags=$$MFLAGS; \ 29 | else \ 30 | case $$MAKEFLAGS in \ 31 | *\\[\ \ ]*) \ 32 | bs=\\; \ 33 | sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ 34 | | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ 35 | esac; \ 36 | fi; \ 37 | skip_next=no; \ 38 | strip_trailopt () \ 39 | { \ 40 | flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ 41 | }; \ 42 | for flg in $$sane_makeflags; do \ 43 | test $$skip_next = yes && { skip_next=no; continue; }; \ 44 | case $$flg in \ 45 | *=*|--*) continue;; \ 46 | -*I) strip_trailopt 'I'; skip_next=yes;; \ 47 | -*I?*) strip_trailopt 'I';; \ 48 | -*O) strip_trailopt 'O'; skip_next=yes;; \ 49 | -*O?*) strip_trailopt 'O';; \ 50 | -*l) strip_trailopt 'l'; skip_next=yes;; \ 51 | -*l?*) strip_trailopt 'l';; \ 52 | -[dEDm]) skip_next=yes;; \ 53 | -[JT]) skip_next=yes;; \ 54 | esac; \ 55 | case $$flg in \ 56 | *$$target_option*) has_opt=yes; break;; \ 57 | esac; \ 58 | done; \ 59 | test $$has_opt = yes 60 | am__make_dryrun = (target_option=n; $(am__make_running_with_option)) 61 | am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 62 | pkgdatadir = $(datadir)/@PACKAGE@ 63 | pkgincludedir = $(includedir)/@PACKAGE@ 64 | pkglibdir = $(libdir)/@PACKAGE@ 65 | pkglibexecdir = $(libexecdir)/@PACKAGE@ 66 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 67 | install_sh_DATA = $(install_sh) -c -m 644 68 | install_sh_PROGRAM = $(install_sh) -c 69 | install_sh_SCRIPT = $(install_sh) -c 70 | INSTALL_HEADER = $(INSTALL_DATA) 71 | transform = $(program_transform_name) 72 | NORMAL_INSTALL = : 73 | PRE_INSTALL = : 74 | POST_INSTALL = : 75 | NORMAL_UNINSTALL = : 76 | PRE_UNINSTALL = : 77 | POST_UNINSTALL = : 78 | subdir = man 79 | DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am 80 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 81 | am__aclocal_m4_deps = $(top_srcdir)/configure.in 82 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 83 | $(ACLOCAL_M4) 84 | mkinstalldirs = $(install_sh) -d 85 | CONFIG_HEADER = $(top_builddir)/helper/config.h 86 | CONFIG_CLEAN_FILES = 87 | CONFIG_CLEAN_VPATH_FILES = 88 | AM_V_P = $(am__v_P_@AM_V@) 89 | am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) 90 | am__v_P_0 = false 91 | am__v_P_1 = : 92 | AM_V_GEN = $(am__v_GEN_@AM_V@) 93 | am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) 94 | am__v_GEN_0 = @echo " GEN " $@; 95 | am__v_GEN_1 = 96 | AM_V_at = $(am__v_at_@AM_V@) 97 | am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) 98 | am__v_at_0 = @ 99 | am__v_at_1 = 100 | SOURCES = 101 | DIST_SOURCES = 102 | am__can_run_installinfo = \ 103 | case $$AM_UPDATE_INFO_DIR in \ 104 | n|no|NO) false;; \ 105 | *) (install-info --version) >/dev/null 2>&1;; \ 106 | esac 107 | am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; 108 | am__vpath_adj = case $$p in \ 109 | $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ 110 | *) f=$$p;; \ 111 | esac; 112 | am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; 113 | am__install_max = 40 114 | am__nobase_strip_setup = \ 115 | srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` 116 | am__nobase_strip = \ 117 | for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" 118 | am__nobase_list = $(am__nobase_strip_setup); \ 119 | for p in $$list; do echo "$$p $$p"; done | \ 120 | sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ 121 | $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ 122 | if (++n[$$2] == $(am__install_max)) \ 123 | { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ 124 | END { for (dir in files) print dir, files[dir] }' 125 | am__base_list = \ 126 | sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ 127 | sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' 128 | am__uninstall_files_from_dir = { \ 129 | test -z "$$files" \ 130 | || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ 131 | || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ 132 | $(am__cd) "$$dir" && rm -f $$files; }; \ 133 | } 134 | man1dir = $(mandir)/man1 135 | am__installdirs = "$(DESTDIR)$(man1dir)" 136 | NROFF = nroff 137 | MANS = $(man_MANS) 138 | am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) 139 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 140 | ACLOCAL = @ACLOCAL@ 141 | AMTAR = @AMTAR@ 142 | AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ 143 | AUTOCONF = @AUTOCONF@ 144 | AUTOHEADER = @AUTOHEADER@ 145 | AUTOMAKE = @AUTOMAKE@ 146 | AWK = @AWK@ 147 | CC = @CC@ 148 | CCDEPMODE = @CCDEPMODE@ 149 | CFLAGS = @CFLAGS@ 150 | CPP = @CPP@ 151 | CPPFLAGS = @CPPFLAGS@ 152 | CYGPATH_W = @CYGPATH_W@ 153 | DEFS = @DEFS@ 154 | DEPDIR = @DEPDIR@ 155 | ECHO_C = @ECHO_C@ 156 | ECHO_N = @ECHO_N@ 157 | ECHO_T = @ECHO_T@ 158 | EGREP = @EGREP@ 159 | EXEEXT = @EXEEXT@ 160 | GREP = @GREP@ 161 | INSTALL = @INSTALL@ 162 | INSTALL_DATA = @INSTALL_DATA@ 163 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 164 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 165 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 166 | LDFLAGS = @LDFLAGS@ 167 | LIBOBJS = @LIBOBJS@ 168 | LIBS = @LIBS@ 169 | LTLIBOBJS = @LTLIBOBJS@ 170 | MAKEINFO = @MAKEINFO@ 171 | MKDIR_P = @MKDIR_P@ 172 | MYDIR = @MYDIR@ 173 | OBJEXT = @OBJEXT@ 174 | PACKAGE = @PACKAGE@ 175 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 176 | PACKAGE_NAME = @PACKAGE_NAME@ 177 | PACKAGE_STRING = @PACKAGE_STRING@ 178 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ 179 | PACKAGE_URL = @PACKAGE_URL@ 180 | PACKAGE_VERSION = @PACKAGE_VERSION@ 181 | PATH_SEPARATOR = @PATH_SEPARATOR@ 182 | SET_MAKE = @SET_MAKE@ 183 | SHELL = @SHELL@ 184 | STRIP = @STRIP@ 185 | VERSION = @VERSION@ 186 | abs_builddir = @abs_builddir@ 187 | abs_srcdir = @abs_srcdir@ 188 | abs_top_builddir = @abs_top_builddir@ 189 | abs_top_srcdir = @abs_top_srcdir@ 190 | ac_ct_CC = @ac_ct_CC@ 191 | am__include = @am__include@ 192 | am__leading_dot = @am__leading_dot@ 193 | am__quote = @am__quote@ 194 | am__tar = @am__tar@ 195 | am__untar = @am__untar@ 196 | bindir = @bindir@ 197 | build_alias = @build_alias@ 198 | builddir = @builddir@ 199 | datadir = @datadir@ 200 | datarootdir = @datarootdir@ 201 | docdir = @docdir@ 202 | dvidir = @dvidir@ 203 | exec_prefix = @exec_prefix@ 204 | host_alias = @host_alias@ 205 | htmldir = @htmldir@ 206 | includedir = @includedir@ 207 | infodir = @infodir@ 208 | install_sh = @install_sh@ 209 | libdir = @libdir@ 210 | libexecdir = @libexecdir@ 211 | localedir = @localedir@ 212 | localstatedir = @localstatedir@ 213 | mandir = @mandir@ 214 | mkdir_p = @mkdir_p@ 215 | oldincludedir = @oldincludedir@ 216 | pdfdir = @pdfdir@ 217 | prefix = @prefix@ 218 | program_transform_name = @program_transform_name@ 219 | psdir = @psdir@ 220 | sbindir = @sbindir@ 221 | sharedstatedir = @sharedstatedir@ 222 | srcdir = @srcdir@ 223 | sysconfdir = @sysconfdir@ 224 | target_alias = @target_alias@ 225 | top_build_prefix = @top_build_prefix@ 226 | top_builddir = @top_builddir@ 227 | top_srcdir = @top_srcdir@ 228 | man_MANS = imvirt.1 imvirt-report.1 229 | EXTRA_DIST = $(man_MANS) 230 | all: all-am 231 | 232 | .SUFFIXES: 233 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 234 | @for dep in $?; do \ 235 | case '$(am__configure_deps)' in \ 236 | *$$dep*) \ 237 | ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ 238 | && { if test -f $@; then exit 0; else break; fi; }; \ 239 | exit 1;; \ 240 | esac; \ 241 | done; \ 242 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu man/Makefile'; \ 243 | $(am__cd) $(top_srcdir) && \ 244 | $(AUTOMAKE) --gnu man/Makefile 245 | .PRECIOUS: Makefile 246 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 247 | @case '$?' in \ 248 | *config.status*) \ 249 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 250 | *) \ 251 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 252 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 253 | esac; 254 | 255 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 256 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 257 | 258 | $(top_srcdir)/configure: $(am__configure_deps) 259 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 260 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) 261 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 262 | $(am__aclocal_m4_deps): 263 | install-man1: $(man_MANS) 264 | @$(NORMAL_INSTALL) 265 | @list1=''; \ 266 | list2='$(man_MANS)'; \ 267 | test -n "$(man1dir)" \ 268 | && test -n "`echo $$list1$$list2`" \ 269 | || exit 0; \ 270 | echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ 271 | $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ 272 | { for i in $$list1; do echo "$$i"; done; \ 273 | if test -n "$$list2"; then \ 274 | for i in $$list2; do echo "$$i"; done \ 275 | | sed -n '/\.1[a-z]*$$/p'; \ 276 | fi; \ 277 | } | while read p; do \ 278 | if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ 279 | echo "$$d$$p"; echo "$$p"; \ 280 | done | \ 281 | sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ 282 | -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ 283 | sed 'N;N;s,\n, ,g' | { \ 284 | list=; while read file base inst; do \ 285 | if test "$$base" = "$$inst"; then list="$$list $$file"; else \ 286 | echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ 287 | $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ 288 | fi; \ 289 | done; \ 290 | for i in $$list; do echo "$$i"; done | $(am__base_list) | \ 291 | while read files; do \ 292 | test -z "$$files" || { \ 293 | echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ 294 | $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ 295 | done; } 296 | 297 | uninstall-man1: 298 | @$(NORMAL_UNINSTALL) 299 | @list=''; test -n "$(man1dir)" || exit 0; \ 300 | files=`{ for i in $$list; do echo "$$i"; done; \ 301 | l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ 302 | sed -n '/\.1[a-z]*$$/p'; \ 303 | } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ 304 | -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ 305 | dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) 306 | tags TAGS: 307 | 308 | ctags CTAGS: 309 | 310 | cscope cscopelist: 311 | 312 | 313 | distdir: $(DISTFILES) 314 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 315 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 316 | list='$(DISTFILES)'; \ 317 | dist_files=`for file in $$list; do echo $$file; done | \ 318 | sed -e "s|^$$srcdirstrip/||;t" \ 319 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 320 | case $$dist_files in \ 321 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 322 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 323 | sort -u` ;; \ 324 | esac; \ 325 | for file in $$dist_files; do \ 326 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 327 | if test -d $$d/$$file; then \ 328 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 329 | if test -d "$(distdir)/$$file"; then \ 330 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 331 | fi; \ 332 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 333 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 334 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 335 | fi; \ 336 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 337 | else \ 338 | test -f "$(distdir)/$$file" \ 339 | || cp -p $$d/$$file "$(distdir)/$$file" \ 340 | || exit 1; \ 341 | fi; \ 342 | done 343 | check-am: all-am 344 | check: check-am 345 | all-am: Makefile $(MANS) 346 | installdirs: 347 | for dir in "$(DESTDIR)$(man1dir)"; do \ 348 | test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 349 | done 350 | install: install-am 351 | install-exec: install-exec-am 352 | install-data: install-data-am 353 | uninstall: uninstall-am 354 | 355 | install-am: all-am 356 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 357 | 358 | installcheck: installcheck-am 359 | install-strip: 360 | if test -z '$(STRIP)'; then \ 361 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 362 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 363 | install; \ 364 | else \ 365 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 366 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 367 | "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ 368 | fi 369 | mostlyclean-generic: 370 | 371 | clean-generic: 372 | 373 | distclean-generic: 374 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 375 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 376 | 377 | maintainer-clean-generic: 378 | @echo "This command is intended for maintainers to use" 379 | @echo "it deletes files that may require special tools to rebuild." 380 | clean: clean-am 381 | 382 | clean-am: clean-generic mostlyclean-am 383 | 384 | distclean: distclean-am 385 | -rm -f Makefile 386 | distclean-am: clean-am distclean-generic 387 | 388 | dvi: dvi-am 389 | 390 | dvi-am: 391 | 392 | html: html-am 393 | 394 | html-am: 395 | 396 | info: info-am 397 | 398 | info-am: 399 | 400 | install-data-am: install-man 401 | 402 | install-dvi: install-dvi-am 403 | 404 | install-dvi-am: 405 | 406 | install-exec-am: 407 | 408 | install-html: install-html-am 409 | 410 | install-html-am: 411 | 412 | install-info: install-info-am 413 | 414 | install-info-am: 415 | 416 | install-man: install-man1 417 | 418 | install-pdf: install-pdf-am 419 | 420 | install-pdf-am: 421 | 422 | install-ps: install-ps-am 423 | 424 | install-ps-am: 425 | 426 | installcheck-am: 427 | 428 | maintainer-clean: maintainer-clean-am 429 | -rm -f Makefile 430 | maintainer-clean-am: distclean-am maintainer-clean-generic 431 | 432 | mostlyclean: mostlyclean-am 433 | 434 | mostlyclean-am: mostlyclean-generic 435 | 436 | pdf: pdf-am 437 | 438 | pdf-am: 439 | 440 | ps: ps-am 441 | 442 | ps-am: 443 | 444 | uninstall-am: uninstall-man 445 | 446 | uninstall-man: uninstall-man1 447 | 448 | .MAKE: install-am install-strip 449 | 450 | .PHONY: all all-am check check-am clean clean-generic cscopelist-am \ 451 | ctags-am distclean distclean-generic distdir dvi dvi-am html \ 452 | html-am info info-am install install-am install-data \ 453 | install-data-am install-dvi install-dvi-am install-exec \ 454 | install-exec-am install-html install-html-am install-info \ 455 | install-info-am install-man install-man1 install-pdf \ 456 | install-pdf-am install-ps install-ps-am install-strip \ 457 | installcheck installcheck-am installdirs maintainer-clean \ 458 | maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ 459 | pdf-am ps ps-am tags-am uninstall uninstall-am uninstall-man \ 460 | uninstall-man1 461 | 462 | 463 | %.1: 464 | 465 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 466 | # Otherwise a system limit (for SysV at least) may be exceeded. 467 | .NOEXPORT: 468 | -------------------------------------------------------------------------------- /man/imvirt-report.1: -------------------------------------------------------------------------------- 1 | .TH "IMVIRT-REPORT" "1" 2 | .SH "NAME" 3 | imvirt-report \- system reporting to improve detection 4 | .SH "SYNOPSIS" 5 | \fBimvirt-report\fR 6 | .SH "DESCRIPTION" 7 | This manual page documents briefly the \fBimvirt-report\fR script. 8 | \fBimvirt-report\fR collects various system information and sends them to the 9 | upstream authors to provide a better detection support of virtualizing 10 | technologies. 11 | .SH "USAGE" 12 | \fBimvirt-report\fR does not need any arguments. 13 | .SH "SEE ALSO" 14 | .BR imvirt (1) 15 | .SH "AUTHOR" 16 | This manual page was written by Patrick Matth\[:a]i 17 | for imvirt. 18 | Permission is granted to copy, distribute and/or modify this document 19 | under the terms of the GNU General Public License, Version 2 any 20 | later version published by the Free Software Foundation. 21 | -------------------------------------------------------------------------------- /man/imvirt.1: -------------------------------------------------------------------------------- 1 | .TH "IMVIRT" "1" 2 | .SH "NAME" 3 | imvirt \- detects several virtualizations 4 | .SH "SYNOPSIS" 5 | \fBimvirt\fR 6 | .SH "DESCRIPTION" 7 | This manual page documents briefly the \fBimvirt\fR script. 8 | \fBimvirt\fR tries to detect if it runs on a physical machine or on a 9 | virtualized one. If it detects that it is a virtualized one it also tries to 10 | find out which virtualization technology is used. 11 | .SH "USAGE" 12 | \fBimvirt\fR does not need any arguments. 13 | But there is at the moment a restriction if you do not call this script with 14 | the administrative root user, because \fBimvirt\fR also uses \fBdmidecode\fR to 15 | determine the used virtualization technology. \fBdmidecode\fR itself needs root 16 | privileges to access /dev/mem. You have to wrap \fBimvirt\fR with sudo 17 | if you want to detect every virtualization technology. 18 | .SH "SEE ALSO" 19 | .BR dmidecode (8) 20 | .SH "AUTHOR" 21 | This manual page was written by Patrick Matth\[:a]i 22 | for imvirt. 23 | Permission is granted to copy, distribute and/or modify this document 24 | under the terms of the GNU General Public License, Version 2 any 25 | later version published by the Free Software Foundation. 26 | -------------------------------------------------------------------------------- /missing: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Common stub for a few missing GNU programs while installing. 3 | 4 | scriptversion=2005-06-08.21 5 | 6 | # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005 7 | # Free Software Foundation, Inc. 8 | # Originally by Fran,cois Pinard , 1996. 9 | 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2, or (at your option) 13 | # any later version. 14 | 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | 20 | # You should have received a copy of the GNU General Public License 21 | # along with this program; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 23 | # 02110-1301, USA. 24 | 25 | # As a special exception to the GNU General Public License, if you 26 | # distribute this file as part of a program that contains a 27 | # configuration script generated by Autoconf, you may include it under 28 | # the same distribution terms that you use for the rest of that program. 29 | 30 | if test $# -eq 0; then 31 | echo 1>&2 "Try \`$0 --help' for more information" 32 | exit 1 33 | fi 34 | 35 | run=: 36 | 37 | # In the cases where this matters, `missing' is being run in the 38 | # srcdir already. 39 | if test -f configure.ac; then 40 | configure_ac=configure.ac 41 | else 42 | configure_ac=configure.in 43 | fi 44 | 45 | msg="missing on your system" 46 | 47 | case "$1" in 48 | --run) 49 | # Try to run requested program, and just exit if it succeeds. 50 | run= 51 | shift 52 | "$@" && exit 0 53 | # Exit code 63 means version mismatch. This often happens 54 | # when the user try to use an ancient version of a tool on 55 | # a file that requires a minimum version. In this case we 56 | # we should proceed has if the program had been absent, or 57 | # if --run hadn't been passed. 58 | if test $? = 63; then 59 | run=: 60 | msg="probably too old" 61 | fi 62 | ;; 63 | 64 | -h|--h|--he|--hel|--help) 65 | echo "\ 66 | $0 [OPTION]... PROGRAM [ARGUMENT]... 67 | 68 | Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an 69 | error status if there is no known handling for PROGRAM. 70 | 71 | Options: 72 | -h, --help display this help and exit 73 | -v, --version output version information and exit 74 | --run try to run the given command, and emulate it if it fails 75 | 76 | Supported PROGRAM values: 77 | aclocal touch file \`aclocal.m4' 78 | autoconf touch file \`configure' 79 | autoheader touch file \`config.h.in' 80 | automake touch all \`Makefile.in' files 81 | bison create \`y.tab.[ch]', if possible, from existing .[ch] 82 | flex create \`lex.yy.c', if possible, from existing .c 83 | help2man touch the output file 84 | lex create \`lex.yy.c', if possible, from existing .c 85 | makeinfo touch the output file 86 | tar try tar, gnutar, gtar, then tar without non-portable flags 87 | yacc create \`y.tab.[ch]', if possible, from existing .[ch] 88 | 89 | Send bug reports to ." 90 | exit $? 91 | ;; 92 | 93 | -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 94 | echo "missing $scriptversion (GNU Automake)" 95 | exit $? 96 | ;; 97 | 98 | -*) 99 | echo 1>&2 "$0: Unknown \`$1' option" 100 | echo 1>&2 "Try \`$0 --help' for more information" 101 | exit 1 102 | ;; 103 | 104 | esac 105 | 106 | # Now exit if we have it, but it failed. Also exit now if we 107 | # don't have it and --version was passed (most likely to detect 108 | # the program). 109 | case "$1" in 110 | lex|yacc) 111 | # Not GNU programs, they don't have --version. 112 | ;; 113 | 114 | tar) 115 | if test -n "$run"; then 116 | echo 1>&2 "ERROR: \`tar' requires --run" 117 | exit 1 118 | elif test "x$2" = "x--version" || test "x$2" = "x--help"; then 119 | exit 1 120 | fi 121 | ;; 122 | 123 | *) 124 | if test -z "$run" && ($1 --version) > /dev/null 2>&1; then 125 | # We have it, but it failed. 126 | exit 1 127 | elif test "x$2" = "x--version" || test "x$2" = "x--help"; then 128 | # Could not run --version or --help. This is probably someone 129 | # running `$TOOL --version' or `$TOOL --help' to check whether 130 | # $TOOL exists and not knowing $TOOL uses missing. 131 | exit 1 132 | fi 133 | ;; 134 | esac 135 | 136 | # If it does not exist, or fails to run (possibly an outdated version), 137 | # try to emulate it. 138 | case "$1" in 139 | aclocal*) 140 | echo 1>&2 "\ 141 | WARNING: \`$1' is $msg. You should only need it if 142 | you modified \`acinclude.m4' or \`${configure_ac}'. You might want 143 | to install the \`Automake' and \`Perl' packages. Grab them from 144 | any GNU archive site." 145 | touch aclocal.m4 146 | ;; 147 | 148 | autoconf) 149 | echo 1>&2 "\ 150 | WARNING: \`$1' is $msg. You should only need it if 151 | you modified \`${configure_ac}'. You might want to install the 152 | \`Autoconf' and \`GNU m4' packages. Grab them from any GNU 153 | archive site." 154 | touch configure 155 | ;; 156 | 157 | autoheader) 158 | echo 1>&2 "\ 159 | WARNING: \`$1' is $msg. You should only need it if 160 | you modified \`acconfig.h' or \`${configure_ac}'. You might want 161 | to install the \`Autoconf' and \`GNU m4' packages. Grab them 162 | from any GNU archive site." 163 | files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` 164 | test -z "$files" && files="config.h" 165 | touch_files= 166 | for f in $files; do 167 | case "$f" in 168 | *:*) touch_files="$touch_files "`echo "$f" | 169 | sed -e 's/^[^:]*://' -e 's/:.*//'`;; 170 | *) touch_files="$touch_files $f.in";; 171 | esac 172 | done 173 | touch $touch_files 174 | ;; 175 | 176 | automake*) 177 | echo 1>&2 "\ 178 | WARNING: \`$1' is $msg. You should only need it if 179 | you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. 180 | You might want to install the \`Automake' and \`Perl' packages. 181 | Grab them from any GNU archive site." 182 | find . -type f -name Makefile.am -print | 183 | sed 's/\.am$/.in/' | 184 | while read f; do touch "$f"; done 185 | ;; 186 | 187 | autom4te) 188 | echo 1>&2 "\ 189 | WARNING: \`$1' is needed, but is $msg. 190 | You might have modified some files without having the 191 | proper tools for further handling them. 192 | You can get \`$1' as part of \`Autoconf' from any GNU 193 | archive site." 194 | 195 | file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` 196 | test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` 197 | if test -f "$file"; then 198 | touch $file 199 | else 200 | test -z "$file" || exec >$file 201 | echo "#! /bin/sh" 202 | echo "# Created by GNU Automake missing as a replacement of" 203 | echo "# $ $@" 204 | echo "exit 0" 205 | chmod +x $file 206 | exit 1 207 | fi 208 | ;; 209 | 210 | bison|yacc) 211 | echo 1>&2 "\ 212 | WARNING: \`$1' $msg. You should only need it if 213 | you modified a \`.y' file. You may need the \`Bison' package 214 | in order for those modifications to take effect. You can get 215 | \`Bison' from any GNU archive site." 216 | rm -f y.tab.c y.tab.h 217 | if [ $# -ne 1 ]; then 218 | eval LASTARG="\${$#}" 219 | case "$LASTARG" in 220 | *.y) 221 | SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` 222 | if [ -f "$SRCFILE" ]; then 223 | cp "$SRCFILE" y.tab.c 224 | fi 225 | SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` 226 | if [ -f "$SRCFILE" ]; then 227 | cp "$SRCFILE" y.tab.h 228 | fi 229 | ;; 230 | esac 231 | fi 232 | if [ ! -f y.tab.h ]; then 233 | echo >y.tab.h 234 | fi 235 | if [ ! -f y.tab.c ]; then 236 | echo 'main() { return 0; }' >y.tab.c 237 | fi 238 | ;; 239 | 240 | lex|flex) 241 | echo 1>&2 "\ 242 | WARNING: \`$1' is $msg. You should only need it if 243 | you modified a \`.l' file. You may need the \`Flex' package 244 | in order for those modifications to take effect. You can get 245 | \`Flex' from any GNU archive site." 246 | rm -f lex.yy.c 247 | if [ $# -ne 1 ]; then 248 | eval LASTARG="\${$#}" 249 | case "$LASTARG" in 250 | *.l) 251 | SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` 252 | if [ -f "$SRCFILE" ]; then 253 | cp "$SRCFILE" lex.yy.c 254 | fi 255 | ;; 256 | esac 257 | fi 258 | if [ ! -f lex.yy.c ]; then 259 | echo 'main() { return 0; }' >lex.yy.c 260 | fi 261 | ;; 262 | 263 | help2man) 264 | echo 1>&2 "\ 265 | WARNING: \`$1' is $msg. You should only need it if 266 | you modified a dependency of a manual page. You may need the 267 | \`Help2man' package in order for those modifications to take 268 | effect. You can get \`Help2man' from any GNU archive site." 269 | 270 | file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` 271 | if test -z "$file"; then 272 | file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` 273 | fi 274 | if [ -f "$file" ]; then 275 | touch $file 276 | else 277 | test -z "$file" || exec >$file 278 | echo ".ab help2man is required to generate this page" 279 | exit 1 280 | fi 281 | ;; 282 | 283 | makeinfo) 284 | echo 1>&2 "\ 285 | WARNING: \`$1' is $msg. You should only need it if 286 | you modified a \`.texi' or \`.texinfo' file, or any other file 287 | indirectly affecting the aspect of the manual. The spurious 288 | call might also be the consequence of using a buggy \`make' (AIX, 289 | DU, IRIX). You might want to install the \`Texinfo' package or 290 | the \`GNU make' package. Grab either from any GNU archive site." 291 | # The file to touch is that specified with -o ... 292 | file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` 293 | if test -z "$file"; then 294 | # ... or it is the one specified with @setfilename ... 295 | infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` 296 | file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile` 297 | # ... or it is derived from the source name (dir/f.texi becomes f.info) 298 | test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info 299 | fi 300 | # If the file does not exist, the user really needs makeinfo; 301 | # let's fail without touching anything. 302 | test -f $file || exit 1 303 | touch $file 304 | ;; 305 | 306 | tar) 307 | shift 308 | 309 | # We have already tried tar in the generic part. 310 | # Look for gnutar/gtar before invocation to avoid ugly error 311 | # messages. 312 | if (gnutar --version > /dev/null 2>&1); then 313 | gnutar "$@" && exit 0 314 | fi 315 | if (gtar --version > /dev/null 2>&1); then 316 | gtar "$@" && exit 0 317 | fi 318 | firstarg="$1" 319 | if shift; then 320 | case "$firstarg" in 321 | *o*) 322 | firstarg=`echo "$firstarg" | sed s/o//` 323 | tar "$firstarg" "$@" && exit 0 324 | ;; 325 | esac 326 | case "$firstarg" in 327 | *h*) 328 | firstarg=`echo "$firstarg" | sed s/h//` 329 | tar "$firstarg" "$@" && exit 0 330 | ;; 331 | esac 332 | fi 333 | 334 | echo 1>&2 "\ 335 | WARNING: I can't seem to be able to run \`tar' with the given arguments. 336 | You may want to install GNU tar or Free paxutils, or check the 337 | command line arguments." 338 | exit 1 339 | ;; 340 | 341 | *) 342 | echo 1>&2 "\ 343 | WARNING: \`$1' is needed, and is $msg. 344 | You might have modified some files without having the 345 | proper tools for further handling them. Check the \`README' file, 346 | it often tells you about the needed prerequisites for installing 347 | this package. You may also peek at any GNU archive site, in case 348 | some other package would contain this missing \`$1' program." 349 | exit 1 350 | ;; 351 | esac 352 | 353 | exit 0 354 | 355 | # Local variables: 356 | # eval: (add-hook 'write-file-hooks 'time-stamp) 357 | # time-stamp-start: "scriptversion=" 358 | # time-stamp-format: "%:y-%02m-%02d.%02H" 359 | # time-stamp-end: "$" 360 | # End: 361 | -------------------------------------------------------------------------------- /perl/Makefile.PL: -------------------------------------------------------------------------------- 1 | use ExtUtils::MakeMaker; 2 | 3 | WriteMakefile( 4 | 'AUTHOR' => 'Thomas Liske ', 5 | 'LICENSE' => 'gpl', 6 | 'NAME' => 'ImVirt', 7 | 'VERSION_FROM' => 'lib/ImVirt.pm', 8 | 'PREREQ_PM' => { 9 | Module::Find => 0, 10 | File::Slurp => 0, 11 | File::Which => 0, 12 | }, 13 | ); 14 | -------------------------------------------------------------------------------- /perl/lib/ImVirt.pm.in: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2014 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt; 26 | 27 | =head1 NAME 28 | 29 | ImVirt - detects several virtualizations 30 | 31 | =head1 SYNOPSIS 32 | 33 | use ImVirt; 34 | print imv_get(IMV_PROB_DEFAULT, imv_detect()),"\n"; 35 | 36 | =head1 DESCRIPTION 37 | 38 | The C package tries to detect if it is run in a 39 | virtualization. At least the following virtual machines 40 | should be detected: 41 | 42 | =over 43 | 44 | =item ARAnyM 45 | 46 | =item KVM 47 | 48 | =item lguest 49 | 50 | =item QEMU 51 | 52 | =item VirtualBox 53 | 54 | =item Virtual PC/Server 55 | 56 | =item VMware 57 | 58 | =item Xen 59 | 60 | =back 61 | 62 | The following virtualization containers should be detected: 63 | 64 | =over 65 | 66 | =item LXC 67 | 68 | =item OpenVZ 69 | 70 | =item UML 71 | 72 | =item systemd-nspawn 73 | 74 | =back 75 | 76 | =head1 DETECTION HEURISTIC 77 | 78 | The detection is based on a heuristic - you should not trust the result at all. 79 | 80 | ImVirt probes for different well-known characteristics of different 81 | virtualizations. Any characteristics found or not found are weighted 82 | by their significance. 83 | 84 | The result of the heuristic is a weighted tree. The leaves are the (not) 85 | detected containers. 86 | 87 | =head1 FUNCTIONS 88 | 89 | The following functions can be used to retrieve the detected virtualization 90 | containers: 91 | 92 | =head2 Virtual Machines 93 | 94 | =over 4 95 | 96 | =item imv_get_vm($prob) 97 | Returns exactly one string describing the detected virtual machine. If the detected 98 | virtual machine has a smaller match probability than $prob the string 'Unknown' is 99 | returned. 100 | 101 | =item imv_get_all_vm() 102 | Returns a hash any positive detected virtual machines as keys and their 103 | corresponding match probability as value. 104 | 105 | =item imv_get_pos_results_vm() 106 | Returns a list of all possible results which might be returned by all 107 | virtual machine detection modules. The list entries might be appended by 108 | some additional data like version numbers etc. 109 | 110 | =back 111 | 112 | =head2 Virtual Containers 113 | 114 | =over 4 115 | 116 | =item imv_get_vc($prob) 117 | Returns exactly one string describing the detected virtual container. If the detected 118 | virtual container has a smaller match probability than $prob the string 'Unknown' is 119 | returned. 120 | 121 | =item imv_get_all_vc() 122 | Returns a hash any positive detected virtual container as keys and their 123 | corresponding match probability as value. 124 | 125 | =item imv_get_pos_results_vc() 126 | Returns a list of all possible results which might be returned by all 127 | virtual container detection modules. The list entries might be appended by 128 | some additional data like version numbers etc. 129 | 130 | =back 131 | 132 | =cut 133 | 134 | use strict; 135 | use warnings; 136 | use Module::Find; 137 | use List::Util qw(sum); 138 | use Data::Dumper; 139 | 140 | use constant { 141 | KV_POINTS => 'points', 142 | KV_SUBPRODS => 'prods', 143 | KV_PROB => 'prob', 144 | 145 | IMV_PHYSICAL => 'Physical', 146 | IMV_VIRTUAL => 'Virtual', 147 | IMV_NONE => 'None', 148 | IMV_UNKNOWN => 'Unknown', 149 | 150 | IMV_PROB_DEFAULT => 0.9, 151 | 152 | IMV_PTS_MINOR => 1, 153 | IMV_PTS_NORMAL => 3, 154 | IMV_PTS_MAJOR => 6, 155 | IMV_PTS_DRASTIC => 12, 156 | }; 157 | 158 | require Exporter; 159 | our @ISA = qw(Exporter); 160 | 161 | our @EXPORT = qw( 162 | imv_detect 163 | imv_get 164 | imv_get_vm 165 | imv_get_vc 166 | imv_get_all 167 | imv_get_all_vm 168 | imv_get_all_vc 169 | imv_get_pos_results 170 | imv_get_pos_results_vm 171 | imv_get_pos_results_vc 172 | IMV_PROB_DEFAULT 173 | IMV_PHYSICAL 174 | IMV_VIRTUAL 175 | IMV_NONE 176 | IMV_UNKNOWN 177 | IMV_PTS_MINOR 178 | IMV_PTS_NORMAL 179 | IMV_PTS_MAJOR 180 | IMV_PTS_DRASTIC 181 | ); 182 | 183 | our $VERSION = '@PACKAGE_VERSION@'; 184 | 185 | sub get_libexecdir() { 186 | return '@libexecdir@/@PACKAGE@'; 187 | } 188 | 189 | my @vmds = (); 190 | my @vcds = (); 191 | my $debug = 0; 192 | my %detected_vm = (); 193 | my %detected_vc = (); 194 | my %rtree_vm; 195 | my %rtree_vc; 196 | 197 | sub register_vmd($) { 198 | my $vmd = shift || return; 199 | 200 | push(@vmds, $vmd); 201 | } 202 | 203 | sub register_vcd($) { 204 | my $vcd = shift || return; 205 | 206 | push(@vcds, $vcd); 207 | } 208 | 209 | sub _rtree($$$@) { 210 | my $dref = shift; 211 | my $cref = shift; 212 | my $pts = shift; 213 | 214 | foreach my $prod (keys %{$dref}) { 215 | my $href = ${$dref}{$prod}; 216 | 217 | if(keys %{${$href}{KV_SUBPRODS}}) { 218 | &_rtree(${$href}{KV_SUBPRODS}, $cref, $pts + ${$href}{KV_POINTS}, @_, $prod); 219 | } 220 | else { 221 | if(${$href}{KV_POINTS} > 0) { 222 | my $n = join(' ', @_, $prod); 223 | $n =~ s/^.*\|([^\|]+)/$1/ if($n =~ /\|/); 224 | ${$cref}{$n} = $pts + ${$href}{KV_POINTS}; 225 | } 226 | } 227 | } 228 | } 229 | 230 | sub imv_detect() { 231 | imv_init() unless (@vmds); 232 | 233 | # detect Virtual Machines 234 | %detected_vm = (ImVirt::IMV_PHYSICAL => {KV_POINTS => IMV_PTS_MINOR}); 235 | foreach my $vmd (@vmds) { 236 | eval "${vmd}::detect(\\\%detected_vm);"; 237 | warn "Error in ${vmd}::detect(): $@\n" if $@; 238 | } 239 | 240 | %rtree_vm = (); 241 | _rtree(\%detected_vm, \%rtree_vm, 0); 242 | 243 | my $psum = sum grep { $_ > 0 } values %rtree_vm; 244 | foreach my $prod (keys %rtree_vm) { 245 | my $pts = $rtree_vm{$prod}; 246 | 247 | if($pts > 0) { 248 | $rtree_vm{$prod} = $pts/$psum; 249 | } 250 | else { 251 | $rtree_vm{$prod} = 0; 252 | } 253 | } 254 | 255 | debug(__PACKAGE__, "imvirt_detect(): VM\n".Dumper(\%rtree_vm)); 256 | 257 | # detect Virtual Containers 258 | %detected_vc = (ImVirt::IMV_NONE => {KV_POINTS => IMV_PTS_MINOR}); 259 | foreach my $vcd (@vcds) { 260 | eval "${vcd}::detect(\\\%detected_vc);"; 261 | warn "Error in ${vcd}::detect(): $@\n" if $@; 262 | } 263 | 264 | %rtree_vc = (); 265 | _rtree(\%detected_vc, \%rtree_vc, 0); 266 | 267 | $psum = sum grep { $_ > 0 } values %rtree_vc; 268 | foreach my $prod (keys %rtree_vc) { 269 | my $pts = $rtree_vc{$prod}; 270 | 271 | if($pts > 0) { 272 | $rtree_vc{$prod} = $pts/$psum; 273 | } 274 | else { 275 | $rtree_vc{$prod} = 0; 276 | } 277 | } 278 | 279 | debug(__PACKAGE__, "imvirt_detect(): VC\n".Dumper(\%rtree_vc)); 280 | } 281 | 282 | sub inc_pts($$@) { 283 | debug(__PACKAGE__, 'inc_pts('.join(', ',@_).')'); 284 | 285 | my $dref = shift; 286 | my $prop = shift; 287 | 288 | _change_pts($prop, $dref, @_); 289 | } 290 | 291 | sub dec_pts($$@) { 292 | debug(__PACKAGE__, 'dec_pts('.join(', ',@_).')'); 293 | 294 | my $dref = shift; 295 | my $prop = shift; 296 | 297 | _change_pts(-$prop, $dref, @_); 298 | } 299 | 300 | sub _change_pts($\%@) { 301 | my $prop = shift; 302 | my $ref = shift; 303 | my $key = shift; 304 | 305 | my $href = ${$ref}{$key}; 306 | unless($href) { 307 | $href = ${$ref}{$key} = {KV_POINTS => 0, KV_SUBPRODS => {}}; 308 | } 309 | 310 | if($#_ != -1) { 311 | &_change_pts($prop, ${$href}{KV_SUBPRODS}, @_); 312 | } 313 | else { 314 | ${$href}{KV_POINTS} += $prop; 315 | } 316 | } 317 | 318 | sub imv_get_all() { 319 | return imv_get_all_vm(); 320 | } 321 | 322 | sub imv_get_all_vm() { 323 | imv_detect() unless (%detected_vm); 324 | 325 | return %rtree_vm; 326 | } 327 | 328 | sub imv_get_all_vc() { 329 | imv_detect() unless (%detected_vc); 330 | 331 | return %rtree_vc; 332 | } 333 | 334 | sub imv_get($) { 335 | return imv_get_vm(@_); 336 | } 337 | 338 | sub imv_get_vm($) { 339 | imv_detect() unless (%detected_vm); 340 | 341 | my $prob = shift; 342 | 343 | my @res = sort { $rtree_vm{$b} <=> $rtree_vm{$a} } keys %rtree_vm; 344 | my $vm = shift @res; 345 | 346 | return $vm if(eval { 347 | my $m = (sum values %rtree_vm)/($#res+2); 348 | debug(__PACKAGE__, "imv_get: m = $m"); 349 | 350 | my $s = 0; 351 | foreach my $v (values %rtree_vm) { 352 | $s += ($v - $m)**2; 353 | } 354 | $s /=($#res+1); 355 | debug(__PACKAGE__, "imv_get: s² = $s"); 356 | 357 | my $vm2 = shift @res; 358 | debug(__PACKAGE__, "imv_get: $rtree_vm{$vm} - sqrt($s) > $rtree_vm{$vm2}"); 359 | $rtree_vm{$vm} - sqrt($s) > $rtree_vm{$vm2}; 360 | }); 361 | 362 | return $vm if($rtree_vm{$vm} >= $prob); 363 | 364 | return IMV_UNKNOWN; 365 | } 366 | 367 | sub imv_get_vc($) { 368 | imv_detect() unless (%detected_vc); 369 | 370 | my $prob = shift; 371 | 372 | my @res = sort { $rtree_vc{$b} <=> $rtree_vc{$a} } keys %rtree_vc; 373 | my $vc = shift @res; 374 | 375 | return $vc if(eval { 376 | my $m = (sum values %rtree_vc)/($#res+2); 377 | debug(__PACKAGE__, "imv_get: m = $m"); 378 | 379 | my $s = 0; 380 | foreach my $v (values %rtree_vc) { 381 | $s += ($v - $m)**2; 382 | } 383 | $s /=($#res+1); 384 | debug(__PACKAGE__, "imv_get: s² = $s"); 385 | 386 | my $vc2 = shift @res; 387 | debug(__PACKAGE__, "imv_get: $rtree_vc{$vc} - sqrt($s) > $rtree_vc{$vc2}"); 388 | $rtree_vc{$vc} - sqrt($s) > $rtree_vc{$vc2}; 389 | }); 390 | 391 | return $vc if($rtree_vc{$vc} >= $prob); 392 | 393 | return IMV_UNKNOWN; 394 | } 395 | 396 | sub imv_get_pos_results { 397 | return imv_get_pos_results_vm(); 398 | } 399 | 400 | sub imv_get_pos_results_vm { 401 | imv_init() unless (@vmds); 402 | 403 | my @pres; 404 | 405 | foreach my $vmd (@vmds) { 406 | eval "\@pres = (\@pres, ${vmd}::pres());"; 407 | } 408 | 409 | my %pres = map { $_, 1 } map { s/^.*\|([^|]+)$/$1/; $_; } @pres; 410 | return sort {uc($a) cmp uc($b)} keys %pres; 411 | } 412 | 413 | sub imv_get_pos_results_vc { 414 | imv_init() unless (@vcds); 415 | 416 | my @pres; 417 | 418 | foreach my $vcd (@vcds) { 419 | eval "\@pres = (\@pres, ${vcd}::pres());"; 420 | } 421 | 422 | my %pres = map { $_, 1 } map { s/^.*\|([^|]+)$/$1/; $_; } @pres; 423 | return sort {uc($a) cmp uc($b)} keys %pres; 424 | } 425 | 426 | sub set_debug($) { 427 | $debug = shift; 428 | } 429 | 430 | sub get_debug() { 431 | return $debug; 432 | } 433 | 434 | sub debug($$) { 435 | printf STDERR "%s: %s\n", @_ if($debug); 436 | } 437 | 438 | sub imv_init() { 439 | # autoload VCD/VMD modules 440 | foreach my $module (findsubmod ImVirt::VCD, findsubmod ImVirt::VMD) { 441 | eval "use $module;"; 442 | die "Error loading $module: $@\n" if $@; 443 | } 444 | } 445 | 446 | 1; 447 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/Utils/blkdev.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2013 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::Utils::blkdev; 26 | 27 | use strict; 28 | use warnings; 29 | use File::Slurp; 30 | use ImVirt::Utils::procfs; 31 | use ImVirt::Utils::sysfs; 32 | 33 | require Exporter; 34 | our @ISA = qw(Exporter); 35 | 36 | our @EXPORT = qw( 37 | blkdev_match 38 | ); 39 | 40 | our $VERSION = '0.1'; 41 | 42 | sub blkdev_match(%) { 43 | my %regexs = @_; 44 | my $pts = 0; 45 | 46 | # scan SCSI devices 47 | ImVirt::debug(__PACKAGE__, "scanning SCSI devices..."); 48 | if(my @scsi = procfs_read('scsi/scsi')) { 49 | if(defined($scsi[0])) { 50 | foreach my $regex (keys %regexs) { 51 | $pts += $regexs{$regex} if(grep { /$regex/; } @scsi); 52 | } 53 | } 54 | } 55 | 56 | # scan IDE devices 57 | ImVirt::debug(__PACKAGE__, "scanning IDE devices..."); 58 | my $glob = procfs_getmp().'/ide/hd*/model'; 59 | foreach my $hd (glob $glob) { 60 | my @ide = read_file($hd); 61 | 62 | foreach my $regex (keys %regexs) { 63 | $pts += $regexs{$regex} if(grep { /$regex/; } @ide); 64 | } 65 | } 66 | 67 | # scan ATA devices 68 | ImVirt::debug(__PACKAGE__, "scanning ATA devices..."); 69 | $glob = sysfs_getmp().'/class/block/*/device/model'; 70 | foreach my $hd (glob $glob) { 71 | my @ata = read_file($hd); 72 | 73 | foreach my $regex (keys %regexs) { 74 | $pts += $regexs{$regex} if(grep { /$regex/; } @ata); 75 | } 76 | } 77 | 78 | return $pts; 79 | } 80 | 81 | 1; 82 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/Utils/cpuinfo.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::Utils::cpuinfo; 26 | 27 | use strict; 28 | use warnings; 29 | use Data::Dumper; 30 | use ImVirt::Utils::procfs; 31 | 32 | use constant { 33 | CPUINFO_UNKNOWN => 'UNKNOWN', 34 | }; 35 | 36 | require Exporter; 37 | our @ISA = qw(Exporter); 38 | 39 | our @EXPORT = qw( 40 | cpuinfo_get 41 | cpuinfo_hasflags 42 | CPUINFO_UNKNOWN 43 | ); 44 | 45 | our $VERSION = '0.1'; 46 | 47 | my %cpuinfo; 48 | my $fn = procfs_getmp().'/cpuinfo'; 49 | if(open(HCPUINFO, $fn)) { 50 | my $proc; 51 | while(my $line = ) { 52 | chomp($line); 53 | if($line =~ /^(\w[^:]+\S)\s+: (.+)$/) { 54 | $proc = $2 if($1 eq 'processor'); 55 | ${$cpuinfo{$proc}}{$1} = $2; 56 | } 57 | } 58 | close(HCPUINFO); 59 | } 60 | else { 61 | ImVirt::debug(__PACKAGE__, "Cannot open '$fn': $!"); 62 | 63 | $cpuinfo{0} = { 64 | processor => 0, 65 | vendor_id => CPUINFO_UNKNOWN, 66 | flags => '', 67 | model => CPUINFO_UNKNOWN, 68 | 'model name' => CPUINFO_UNKNOWN, 69 | } 70 | } 71 | ImVirt::debug(__PACKAGE__, Dumper(\%cpuinfo)); 72 | 73 | sub cpuinfo_get() { 74 | return %cpuinfo; 75 | } 76 | 77 | sub cpuinfo_hasflags(%) { 78 | my %regexs = @_; 79 | my $pts = 0; 80 | 81 | foreach my $cpuinfo (keys %cpuinfo) { 82 | next unless(exists(${$cpuinfo{$cpuinfo}}{'flags'})); 83 | 84 | foreach my $regex (keys %regexs) { 85 | if(${$cpuinfo{$cpuinfo}}{'flags'} =~ /$regex/) { 86 | $pts += $regexs{$regex}; 87 | delete($regexs{$regex}); 88 | } 89 | } 90 | } 91 | 92 | return $pts; 93 | } 94 | 95 | 1; 96 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/Utils/dmesg.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::Utils::dmesg; 26 | 27 | use strict; 28 | use warnings; 29 | use IO::Handle; 30 | use File::Slurp; 31 | require Exporter; 32 | our @ISA = qw(Exporter); 33 | 34 | our @EXPORT = qw( 35 | dmesg_match 36 | ); 37 | 38 | our $VERSION = '0.1'; 39 | 40 | my $dmesg = '/bin/dmesg'; 41 | my $logfile = '/var/log/dmesg'; 42 | 43 | sub dmesg_match(%) { 44 | return -1 unless (-x $dmesg || -r $logfile); 45 | 46 | my %regexs = @_; 47 | my $pts = 0; 48 | my %lines; 49 | 50 | if(-x $dmesg) { 51 | pipe(PARENT_RDR, CHILD_WTR); 52 | if(my $pid = fork()) { 53 | close(CHILD_WTR); 54 | %lines = map { $_, 1 } ; 55 | close(PARENT_RDR); 56 | } else { 57 | die "Cannot fork: $!\n" unless defined($pid); 58 | 59 | close(PARENT_RDR); 60 | open(STDOUT, '>&CHILD_WTR') || die "Could not dup: $!\n"; 61 | 62 | exec($dmesg); 63 | 64 | die("Cannot exec $dmesg: $!\n"); 65 | } 66 | } 67 | 68 | %lines = (%lines, map { $_, 1 } read_file($logfile)) if(-r $logfile); 69 | 70 | foreach my $line (keys %lines) { 71 | chomp($line); 72 | foreach my $regex (keys %regexs) { 73 | $pts += $regexs{$regex} if($line =~ /$regex/); 74 | } 75 | } 76 | 77 | return $pts; 78 | } 79 | 80 | 1; 81 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/Utils/dmidecode.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::Utils::dmidecode; 26 | 27 | use strict; 28 | use warnings; 29 | use IO::Handle; 30 | use ImVirt::Utils::dmidecode::kernel; 31 | use ImVirt::Utils::dmidecode::pipe; 32 | 33 | require Exporter; 34 | our @ISA = qw(Exporter); 35 | 36 | our @EXPORT = qw( 37 | dmidecode_string 38 | dmidecode_type 39 | ); 40 | 41 | our $VERSION = '0.2'; 42 | 43 | my $has_kernel = ImVirt::Utils::dmidecode::kernel::available(); 44 | my $has_pipe = ImVirt::Utils::dmidecode::pipe::available(); 45 | 46 | sub dmidecode_string($) { 47 | return ImVirt::Utils::dmidecode::kernel::dmidecode_string(shift) 48 | if($has_kernel); 49 | 50 | return ImVirt::Utils::dmidecode::pipe::dmidecode_string(shift) 51 | if($has_pipe); 52 | 53 | return (); 54 | } 55 | sub dmidecode_type($) { 56 | return ImVirt::Utils::dmidecode::kernel::dmidecode_type(shift) 57 | if($has_kernel); 58 | 59 | return ImVirt::Utils::dmidecode::pipe::dmidecode_type(shift) 60 | if($has_pipe); 61 | 62 | return (); 63 | } 64 | 65 | 1; 66 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/Utils/dmidecode/kernel.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::Utils::dmidecode::kernel; 26 | 27 | use strict; 28 | use warnings; 29 | use IO::Handle; 30 | use ImVirt; 31 | use ImVirt::Utils::sysfs; 32 | 33 | require Exporter; 34 | our @ISA = qw(Exporter); 35 | 36 | our $VERSION = '0.1'; 37 | 38 | my $sysfs_relp = 'class/dmi/id'; 39 | my $sysfs_absp = join('/', sysfs_getmp(), $sysfs_relp); 40 | 41 | sub available() { 42 | my $avail = sysfs_isdir('class/dmi/id'); 43 | if(defined($avail)) { 44 | ImVirt::debug(__PACKAGE__, "sysfs_isdir('class/dmi/id') = $avail"); 45 | } 46 | else { 47 | ImVirt::debug(__PACKAGE__, "sysfs_isdir('class/dmi/id') does not exist"); 48 | } 49 | 50 | return $avail; 51 | } 52 | 53 | sub dmidecode_string($) { 54 | my $s = shift; 55 | $s =~ s/^system-//; 56 | $s =~ s/-/_/g; 57 | 58 | my $fn = join('/', $sysfs_absp, $s); 59 | 60 | open(HR, '<', $fn); 61 | my @res =
; 62 | close(HR); 63 | 64 | my $res = join(' ', @res); 65 | 66 | if($res) { 67 | ImVirt::debug(__PACKAGE__, "dmidecode_string($s) => $res"); 68 | return $res; 69 | } 70 | 71 | return undef; 72 | } 73 | 74 | sub dmidecode_type($) { 75 | my @res; 76 | 77 | shift; 78 | foreach my $string (glob join('/', $sysfs_absp, "${_}_*")) { 79 | push(@res, dmidecode_string($string)); 80 | } 81 | 82 | my $res = join(' ', @res); 83 | 84 | if($res) { 85 | ImVirt::debug(__PACKAGE__, "dmidecode_type($_) => $res"); 86 | return $res; 87 | } 88 | 89 | return undef; 90 | } 91 | 92 | 1; 93 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/Utils/dmidecode/pipe.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::Utils::dmidecode::pipe; 26 | 27 | use strict; 28 | use warnings; 29 | use IO::Handle; 30 | use ImVirt; 31 | 32 | require Exporter; 33 | our @ISA = qw(Exporter); 34 | 35 | our $VERSION = '0.1'; 36 | 37 | my $dmidecode = '/usr/sbin/dmidecode'; 38 | my $devmem = '/dev/mem'; 39 | 40 | sub available() { 41 | my $avail = (-r $devmem && -x $dmidecode); 42 | ImVirt::debug(__PACKAGE__, "(-r $devmem && -x $dmidecode) => ".defined($avail)); 43 | 44 | return $avail; 45 | } 46 | 47 | sub dmidecode_string($) { 48 | return dmidecode('-s', shift) 49 | } 50 | sub dmidecode_type($) { 51 | return dmidecode('-t', shift) 52 | } 53 | 54 | sub dmidecode() { 55 | return () unless (-r $devmem && -x $dmidecode); 56 | 57 | pipe(PARENT_RDR, CHILD_WTR); 58 | if(my $pid = fork()) { 59 | close(CHILD_WTR); 60 | my @res = ; 61 | close(PARENT_RDR); 62 | 63 | my $res = join(' ', @res); 64 | 65 | if($res) { 66 | ImVirt::debug(__PACKAGE__, "dmidecode(".join(', ', @_).") => $res"); 67 | return $res; 68 | } 69 | 70 | return undef; 71 | } else { 72 | die "Cannot fork: $!\n" unless defined($pid); 73 | 74 | close(PARENT_RDR); 75 | open(STDOUT, '>&CHILD_WTR') || die "Could not dup: $!\n"; 76 | close(STDERR); 77 | 78 | exec($dmidecode, '-d', $devmem, @_); 79 | 80 | die("Cannot exec $dmidecode: $!\n"); 81 | } 82 | } 83 | 84 | 1; 85 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/Utils/helper.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::Utils::helper; 26 | 27 | use strict; 28 | use warnings; 29 | require Exporter; 30 | our @ISA = qw(Exporter); 31 | 32 | our @EXPORT = qw( 33 | helper 34 | ); 35 | 36 | our $VERSION = '0.1'; 37 | 38 | my %helpers; 39 | foreach my $glob (ImVirt::get_libexecdir().'/*') { 40 | foreach my $helper (glob $glob) { 41 | if(-x $helper) { 42 | my $out; 43 | my $hname = $helper; 44 | $hname =~ s@^.+/([^/]+)$@$1@; 45 | 46 | chomp($helpers{$hname} = $out) if(defined($out = scalar ` "$helper"`)); 47 | } 48 | } 49 | } 50 | 51 | sub helper($) { 52 | my $helper = shift; 53 | return $helpers{$helper} if (exists($helpers{$helper})); 54 | 55 | return undef; 56 | } 57 | 58 | 1; 59 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/Utils/jiffies.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::Utils::jiffies; 26 | 27 | use strict; 28 | use warnings; 29 | use File::Slurp; 30 | use ImVirt::Utils::procfs; 31 | 32 | require Exporter; 33 | our @ISA = qw(Exporter); 34 | 35 | our @EXPORT = qw( 36 | jiffies_hz 37 | jiffies_sec 38 | ); 39 | 40 | our $VERSION = '0.1'; 41 | 42 | my @HZ = qw(100 250 300 1000); 43 | my $hz = undef; 44 | 45 | sub jiffies_hz() { 46 | return $hz if(defined($hz)); 47 | 48 | my $uptime = procfs_read('uptime'); 49 | my $tlist = procfs_read('timer_list'); 50 | 51 | unless(defined($uptime) && defined($tlist)) { 52 | ImVirt::debug(__PACKAGE__, "could not get timing data from procfs"); 53 | return undef; 54 | } 55 | 56 | $uptime =~ s/\s.+$//; 57 | $tlist =~ /^jiffies: (\d+)$/m; 58 | my $jiffies = $1 % (2**32); 59 | 60 | $hz = $jiffies / $uptime; 61 | ImVirt::debug(__PACKAGE__, "calculated jiffies: $hz"); 62 | 63 | foreach my $h (@HZ) { 64 | if(abs($h - $hz) < $h*0.1) { 65 | $hz = $h; 66 | ImVirt::debug(__PACKAGE__, "estimated jiffies: $hz"); 67 | last; 68 | } 69 | } 70 | 71 | return $hz; 72 | } 73 | 74 | sub jiffies_sec($) { 75 | jiffies_hz(); 76 | 77 | return (shift) / $hz if(defined($hz)); 78 | 79 | return undef; 80 | } 81 | 82 | 1; 83 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/Utils/kmods.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::Utils::kmods; 26 | 27 | use strict; 28 | use warnings; 29 | use Data::Dumper; 30 | use ImVirt::Utils::procfs; 31 | 32 | require Exporter; 33 | our @ISA = qw(Exporter); 34 | 35 | our @EXPORT = qw( 36 | kmods_get 37 | kmods_match 38 | kmods_match_used 39 | ); 40 | 41 | our $VERSION = '0.1'; 42 | 43 | my $procdir = procfs_getmp(); 44 | my %kmods; 45 | 46 | if(open(HKMS, "$procdir/modules")) { 47 | while() { 48 | chomp; 49 | if(/^(\S+) (\d+) (\d+) (\S+) (\S+) (0x[a-f\d]+)/) { 50 | ${$kmods{$1}}{'size'} = $2; 51 | ${$kmods{$1}}{'instances'} = $3; 52 | ${$kmods{$1}}{'usedby'} = $4; 53 | ${$kmods{$1}}{'state'} = $5; 54 | ${$kmods{$1}}{'by'} = $6; 55 | } 56 | } 57 | ImVirt::debug(__PACKAGE__, Dumper(\%kmods)); 58 | } 59 | else { 60 | ImVirt::debug(__PACKAGE__, "failed to open $procdir/modules: $!"); 61 | } 62 | 63 | sub kmods_get() { 64 | return %kmods; 65 | } 66 | 67 | sub kmods_match(%) { 68 | my %regexs = @_; 69 | my $pts = 0; 70 | 71 | foreach my $kmod (keys %kmods) { 72 | foreach my $regex (keys %regexs) { 73 | if($kmod =~ /$regex/) { 74 | $pts += $regexs{$regex}; 75 | delete($regexs{$regex}); 76 | } 77 | } 78 | } 79 | 80 | return $pts; 81 | } 82 | 83 | sub kmods_match_used(%) { 84 | my %regexs = @_; 85 | my $pts = 0; 86 | 87 | foreach my $kmod (keys %kmods) { 88 | foreach my $regex (keys %regexs) { 89 | if($kmod =~ /$regex/ && ${$kmods{$kmod}}{'instances'} > 0) { 90 | $pts += $regexs{$regex}; 91 | delete($regexs{$regex}); 92 | } 93 | } 94 | } 95 | 96 | return $pts; 97 | } 98 | 99 | 1; 100 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/Utils/ksyms.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::Utils::ksyms; 26 | 27 | use strict; 28 | use warnings; 29 | use Data::Dumper; 30 | use ImVirt::Utils::procfs; 31 | use constant { 32 | KSYM_STYPE_ABSOL => 'A', 33 | KSYM_STYPE_UDATA => 'B', 34 | KSYM_STYPE_COMMON => 'C', 35 | KSYM_STYPE_IDATA => 'D', 36 | KSYM_STYPE_ISDATA => 'G', 37 | KSYM_STYPE_IREF => 'I', 38 | KSYM_STYPE_DEBUG => 'N', 39 | KSYM_STYPE_RODATA => 'R', 40 | KSYM_STYPE_USDATA => 'S', 41 | KSYM_STYPE_TEXT => 'T', 42 | KSYM_STYPE_UNDEF => 'U', 43 | KSYM_STYPE_TWEAK => 'V', 44 | KSYM_STYPE_UWEAK => 'W', 45 | }; 46 | 47 | require Exporter; 48 | our @ISA = qw(Exporter); 49 | 50 | our @EXPORT = qw( 51 | ksyms_provides 52 | KSYM_STYPE_ABSOL 53 | KSYM_STYPE_UDATA 54 | KSYM_STYPE_COMMON 55 | KSYM_STYPE_IDATA 56 | KSYM_STYPE_ISDATA 57 | KSYM_STYPE_IREF 58 | KSYM_STYPE_DEBUG 59 | KSYM_STYPE_RODATA 60 | KSYM_STYPE_USDATA 61 | KSYM_STYPE_TEXT 62 | KSYM_STYPE_UNDEF 63 | KSYM_STYPE_TWEAK 64 | KSYM_STYPE_UWEAK 65 | ); 66 | 67 | our $VERSION = '0.1'; 68 | 69 | my $procdir = procfs_getmp(); 70 | my %kallsyms; 71 | 72 | open(HKAS, "$procdir/kallsyms"); 73 | while() { 74 | chomp; 75 | if(/^([a-f\d]+) (\w) (\S+)\s*(\[([^\]]+)\])?/) { 76 | ${$kallsyms{$3}}{'value'} = $1; 77 | ${$kallsyms{$3}}{'type'} = $2; 78 | ${$kallsyms{$3}}{'module'} = $5 if(defined($5)); 79 | } 80 | } 81 | ImVirt::debug(__PACKAGE__, Dumper(\%kallsyms)); 82 | 83 | sub ksym_provides($$) { 84 | my ($type, $name) = @_; 85 | 86 | return exists($kallsyms{$name}) && (${$kallsyms{$name}}{'type'} eq uc($type)); 87 | } 88 | 89 | 1; 90 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/Utils/pcidevs.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::Utils::pcidevs; 26 | 27 | use strict; 28 | use warnings; 29 | use Data::Dumper; 30 | use IO::Handle; 31 | use ImVirt::Utils::run; 32 | use ImVirt::Utils::procfs; 33 | require Exporter; 34 | our @ISA = qw(Exporter); 35 | 36 | our @EXPORT = qw( 37 | pcidevs_get 38 | ); 39 | 40 | our $VERSION = '0.1'; 41 | 42 | my %pcidevs; 43 | 44 | if(procfs_isdir('bus/pci')) { 45 | pipe(PARENT_RDR, CHILD_WTR); 46 | if(my $pid = fork()) { 47 | close(CHILD_WTR); 48 | foreach my $line () { 49 | chomp($line); 50 | unless($line =~ /^([\da-f:.]+) "(.*)" "(.*)" "(.*)" ([^"]*) ?"(.*)" "(.*)"$/) { 51 | warn "Unexpected output from lspci: $line\n"; 52 | next; 53 | } 54 | 55 | $pcidevs{$1} = { 56 | 'addr' => $1, 57 | 'type' => $2, 58 | 'vendor' => $3, 59 | 'device' => $4, 60 | 'rev' => $5, 61 | }; 62 | } 63 | close(PARENT_RDR); 64 | } else { 65 | die "Cannot fork: $!\n" unless defined($pid); 66 | 67 | close(PARENT_RDR); 68 | open(STDOUT, '>&CHILD_WTR') || die "Could not dup: $!\n"; 69 | 70 | run_exec('lspci', '-m'); 71 | 72 | exit; 73 | } 74 | ImVirt::debug(__PACKAGE__, Dumper(\%pcidevs)); 75 | } 76 | else { 77 | ImVirt::debug(__PACKAGE__, "procfs does not contain a bus/pci directory"); 78 | } 79 | 80 | sub pcidevs_get() { 81 | return %pcidevs; 82 | } 83 | 84 | 1; 85 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/Utils/procfs.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2013 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::Utils::procfs; 26 | 27 | use strict; 28 | use warnings; 29 | use File::Slurp; 30 | require Exporter; 31 | our @ISA = qw(Exporter); 32 | 33 | our @EXPORT = qw( 34 | procfs_getmp 35 | procfs_isdir 36 | procfs_isfile 37 | procfs_read 38 | procfs_starttime 39 | ); 40 | 41 | our $VERSION = '0.2'; 42 | 43 | my $procdir = '/proc'; 44 | 45 | sub procfs_getmp() { 46 | return $procdir; 47 | } 48 | 49 | sub procfs_isdir($) { 50 | return -d join('/', procfs_getmp(), shift); 51 | } 52 | 53 | sub procfs_isfile($) { 54 | return -f join('/', procfs_getmp(), shift); 55 | } 56 | 57 | sub procfs_read($) { 58 | my $fn = join('/', procfs_getmp(), shift); 59 | if(-r $fn) { 60 | my $f = read_file($fn); 61 | chomp($f); 62 | return $f; 63 | } 64 | 65 | return undef; 66 | } 67 | 68 | sub procfs_starttime($) { 69 | my $fn = join('/', procfs_getmp(), shift, 'stat'); 70 | if(-r $fn) { 71 | my @f = split(/\s/, read_file($fn)); 72 | return $f[21]; 73 | } 74 | 75 | return undef; 76 | } 77 | 78 | 1; 79 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/Utils/run.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::Utils::run; 26 | 27 | use strict; 28 | use warnings; 29 | 30 | require Exporter; 31 | our @ISA = qw(Exporter); 32 | 33 | our @EXPORT = qw( 34 | run_exec 35 | ); 36 | 37 | our $VERSION = '0.1'; 38 | 39 | eval 'use File::Which;'; 40 | my $nowhich = $@; 41 | 42 | sub run_exec(@) { 43 | my $cmd = shift; 44 | my $run = ($nowhich ne '' ? $cmd : which($cmd)); 45 | if(defined($run)) { 46 | exec($run, @_); 47 | } 48 | else { 49 | ImVirt::debug(__PACKAGE__, "binary $cmd not found"); 50 | } 51 | } 52 | 53 | 1; 54 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/Utils/sysfs.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2013 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::Utils::sysfs; 26 | 27 | use strict; 28 | use warnings; 29 | use File::Slurp; 30 | require Exporter; 31 | our @ISA = qw(Exporter); 32 | 33 | our @EXPORT = qw( 34 | sysfs_getmp 35 | sysfs_isdir 36 | sysfs_isfile 37 | sysfs_read 38 | ); 39 | 40 | our $VERSION = '0.2'; 41 | 42 | my $sysfsdir = '/sys'; 43 | 44 | sub sysfs_getmp() { 45 | return $sysfsdir; 46 | } 47 | 48 | sub sysfs_isdir($) { 49 | return -d join('/', sysfs_getmp(), shift); 50 | } 51 | 52 | sub sysfs_isfile($) { 53 | return -f join('/', sysfs_getmp(), shift); 54 | } 55 | 56 | sub sysfs_read($) { 57 | my $fn = join('/', sysfs_getmp(), shift); 58 | if(-r $fn) { 59 | my $f = read_file($fn); 60 | chomp($f); 61 | return $f; 62 | } 63 | 64 | return undef; 65 | } 66 | 67 | 1; 68 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/Utils/uname.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::Utils::uname; 26 | 27 | use strict; 28 | use warnings; 29 | use Data::Dumper; 30 | use POSIX; 31 | 32 | require Exporter; 33 | our @ISA = qw(Exporter); 34 | 35 | our @EXPORT = qw( 36 | posix_uname 37 | ); 38 | 39 | our $VERSION = '0.1'; 40 | 41 | my @uname = POSIX::uname(); 42 | my %uname = ( 43 | sysname => shift(@uname), 44 | nodename => shift(@uname), 45 | release => shift(@uname), 46 | version => shift(@uname), 47 | machine => shift(@uname), 48 | ); 49 | ImVirt::debug(__PACKAGE__, Dumper(\%uname)); 50 | 51 | sub posix_uname() { 52 | return %uname; 53 | } 54 | 55 | 1; 56 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/VCD/LXC.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::VCD::LXC; 26 | 27 | use strict; 28 | use warnings; 29 | use constant PRODUCT => '|LXC'; 30 | 31 | use ImVirt; 32 | use ImVirt::Utils::procfs; 33 | use ImVirt::Utils::jiffies; 34 | 35 | ImVirt::register_vcd(__PACKAGE__); 36 | 37 | sub detect($) { 38 | ImVirt::debug(__PACKAGE__, 'detect()'); 39 | 40 | my $dref = shift; 41 | 42 | # Check init's control group data 43 | if(defined(my $cg = procfs_read('1/cgroup'))) { 44 | if($cg =~ /^\d+:[^:]+:\/lxc\/.+$/m) { 45 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 46 | } 47 | else { 48 | ImVirt::dec_pts($dref, IMV_PTS_MINOR, IMV_VIRTUAL, PRODUCT); 49 | } 50 | } 51 | 52 | # Check init's environment for LXC 53 | if(defined(my $env = procfs_read('1/environ'))) { 54 | if($env =~ /lxc/i) { 55 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 56 | } 57 | else { 58 | ImVirt::dec_pts($dref, IMV_PTS_MINOR, IMV_VIRTUAL, PRODUCT); 59 | } 60 | } 61 | 62 | # Check init's starttime for LXC 63 | if(defined(my $st = procfs_starttime(1))) { 64 | my $sec = jiffies_sec($st); 65 | if(defined($sec)) { 66 | if($sec >= 5) { 67 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 68 | } 69 | else { 70 | ImVirt::dec_pts($dref, IMV_PTS_MINOR, IMV_VIRTUAL, PRODUCT); 71 | } 72 | } 73 | } 74 | } 75 | 76 | sub pres() { 77 | return (PRODUCT); 78 | } 79 | 80 | 1; 81 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/VCD/OpenVZ.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::VCD::OpenVZ; 26 | 27 | use strict; 28 | use warnings; 29 | use constant PRODUCT => '|OpenVZ'; 30 | 31 | use ImVirt; 32 | use ImVirt::Utils::procfs; 33 | 34 | ImVirt::register_vcd(__PACKAGE__); 35 | 36 | sub detect($) { 37 | ImVirt::debug(__PACKAGE__, 'detect()'); 38 | 39 | my $dref = shift; 40 | 41 | foreach my $fn (qw(time_list bus/pci/devices bus/input/devices)) { 42 | if(procfs_isfile('time_list')) { 43 | ImVirt::dec_pts($dref, IMV_PTS_MINOR, IMV_VIRTUAL, PRODUCT); 44 | } 45 | else { 46 | ImVirt::inc_pts($dref, IMV_PTS_MINOR, IMV_VIRTUAL, PRODUCT); 47 | } 48 | } 49 | 50 | if(procfs_isdir('vz') && !procfs_isdir('bc')) { 51 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 52 | } 53 | else { 54 | ImVirt::dec_pts($dref, IMV_PTS_NORMAL, IMV_VIRTUAL, PRODUCT); 55 | } 56 | } 57 | 58 | sub pres() { 59 | return (PRODUCT); 60 | } 61 | 1; 62 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/VCD/UML.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::VCD::UML; 26 | 27 | use strict; 28 | use warnings; 29 | use constant PRODUCT => '|UML'; 30 | 31 | use ImVirt; 32 | use ImVirt::Utils::cpuinfo; 33 | use ImVirt::Utils::dmesg; 34 | 35 | ImVirt::register_vcd(__PACKAGE__); 36 | 37 | sub detect($) { 38 | ImVirt::debug(__PACKAGE__, 'detect()'); 39 | 40 | my $dref = shift; 41 | 42 | # Check /proc/cpuinfo 43 | my %cpuinfo = cpuinfo_get(); 44 | foreach my $cpu (keys %cpuinfo) { 45 | if(exists(${$cpuinfo{$cpu}}{'vendor_id'}) && ${$cpuinfo{$cpu}}{'vendor_id'} eq 'User Mode Linux') { 46 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 47 | } 48 | 49 | if(exists(${$cpuinfo{$cpu}}{'model name'}) && ${$cpuinfo{$cpu}}{'model name'} eq 'UML') { 50 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 51 | } 52 | 53 | if(exists(${$cpuinfo{$cpu}}{'model'}) && ${$cpuinfo{$cpu}}{'model'} eq 'skas') { 54 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 55 | } 56 | 57 | if(exists(${$cpuinfo{$cpu}}{'host'})) { 58 | ImVirt::inc_pts($dref, IMV_PTS_NORMAL, IMV_VIRTUAL, PRODUCT); 59 | } 60 | } 61 | 62 | # Look for dmesg lines 63 | if(defined(my $m = dmesg_match('UML Watchdog Timer' => IMV_PTS_NORMAL))) { 64 | if($m > 0) { 65 | ImVirt::inc_pts($dref, $m, IMV_VIRTUAL, PRODUCT); 66 | } 67 | else { 68 | ImVirt::dec_pts($dref, IMV_PTS_MINOR, IMV_VIRTUAL, PRODUCT); 69 | } 70 | } 71 | } 72 | 73 | sub pres() { 74 | return (PRODUCT); 75 | } 76 | 77 | 1; 78 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/VCD/systemd_nspawn.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2014 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::VCD::systemd_nspawn; 26 | 27 | use strict; 28 | use warnings; 29 | use constant PRODUCT => '|systemd-nspawn'; 30 | 31 | use ImVirt; 32 | use ImVirt::Utils::procfs; 33 | 34 | ImVirt::register_vcd(__PACKAGE__); 35 | 36 | sub detect($) { 37 | ImVirt::debug(__PACKAGE__, 'detect()'); 38 | 39 | my $dref = shift; 40 | 41 | # Check init's environment for systemd-nspawn 42 | if(defined(my $env = procfs_read('1/environ'))) { 43 | if($env =~ /systemd-nspawn/i) { 44 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 45 | } 46 | else { 47 | ImVirt::dec_pts($dref, IMV_PTS_MINOR, IMV_VIRTUAL, PRODUCT); 48 | } 49 | } 50 | } 51 | 52 | sub pres() { 53 | return (PRODUCT); 54 | } 55 | 56 | 1; 57 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/VMD/ARAnyM.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::VMD::ARAnyM; 26 | 27 | use strict; 28 | use warnings; 29 | use constant PRODUCT => '|ARAnyM'; 30 | 31 | use ImVirt; 32 | use ImVirt::Utils::dmesg; 33 | use ImVirt::Utils::uname; 34 | use ImVirt::Utils::sysfs; 35 | 36 | ImVirt::register_vmd(__PACKAGE__); 37 | 38 | sub detect($) { 39 | ImVirt::debug(__PACKAGE__, 'detect()'); 40 | 41 | my $dref = shift; 42 | 43 | # Check machine type 44 | my %uname = posix_uname(); 45 | if(exists($uname{machine}) && $uname{machine} ne 'm68k') { 46 | ImVirt::dec_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 47 | return; 48 | } 49 | 50 | # Look for a dmesg line 51 | if(defined(my $m = dmesg_match( 52 | 'NatFeats found \(ARAnyM,' => IMV_PTS_MAJOR, 53 | ))) { 54 | ImVirt::inc_pts($dref, $m, IMV_VIRTUAL, PRODUCT) if($m > 0); 55 | } 56 | 57 | # Clocksource should be jiffies 58 | if(defined(my $cs = sysfs_read('devices/system/clocksource/clocksource0/available_clocksource'))) { 59 | if($cs eq 'jiffies') { 60 | ImVirt::inc_pts($dref, IMV_PTS_MINOR, IMV_VIRTUAL, PRODUCT); 61 | } 62 | else { 63 | ImVirt::dec_pts($dref, IMV_PTS_MINOR, IMV_VIRTUAL, PRODUCT); 64 | } 65 | } 66 | } 67 | 68 | sub pres() { 69 | return (PRODUCT); 70 | } 71 | 72 | 1; 73 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/VMD/Generic.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::VMD::Generic; 26 | 27 | use strict; 28 | use warnings; 29 | 30 | use ImVirt; 31 | use ImVirt::Utils::helper; 32 | use ImVirt::Utils::cpuinfo; 33 | use ImVirt::Utils::dmesg; 34 | use ImVirt::Utils::procfs; 35 | 36 | ImVirt::register_vmd(__PACKAGE__); 37 | 38 | sub detect($) { 39 | ImVirt::debug(__PACKAGE__, 'detect()'); 40 | 41 | my $dref = shift; 42 | 43 | # Is hardware virtualization available? 44 | if(defined(my $f = cpuinfo_hasflags( 45 | 'vmx' => IMV_PTS_MINOR, 46 | 'svm' => IMV_PTS_MINOR, 47 | ))) { 48 | ImVirt::inc_pts($dref, $f, IMV_PHYSICAL) if($f > 0); 49 | } 50 | 51 | # Does the kernel provide /dev/kvm? 52 | ImVirt::inc_pts($dref, IMV_PTS_MINOR, IMV_PHYSICAL) 53 | if(-c '/dev/kvm'); 54 | 55 | # Does the kernel reports a hypervisor? 56 | if(defined(my $f = cpuinfo_hasflags( 57 | 'hypervisor' => IMV_PTS_DRASTIC, 58 | ))) { 59 | ImVirt::inc_pts($dref, $f, IMV_VIRTUAL) if($f > 0); 60 | } 61 | 62 | # Check helper output for hypervisor detection 63 | if(my $hlp = helper('hvm')) { 64 | ImVirt::inc_pts($dref, IMV_PTS_NORMAL, IMV_VIRTUAL); 65 | } 66 | 67 | # Look for dmesg lines 68 | if(defined(my $m = dmesg_match( 69 | 'Booting paravirtualized kernel on bare hardware' => IMV_PTS_NORMAL, 70 | ))) { 71 | if($m > 0) { 72 | ImVirt::inc_pts($dref, $m, IMV_VIRTUAL); 73 | } 74 | } 75 | } 76 | 77 | sub pres() { 78 | return (IMV_PHYSICAL, IMV_VIRTUAL); 79 | } 80 | 81 | 1; 82 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/VMD/KVM.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::VMD::KVM; 26 | 27 | use strict; 28 | use warnings; 29 | use constant PRODUCT => '|KVM'; 30 | 31 | use ImVirt; 32 | use ImVirt::Utils::cpuinfo; 33 | use ImVirt::Utils::dmesg; 34 | use ImVirt::Utils::kmods; 35 | use ImVirt::Utils::pcidevs; 36 | use ImVirt::Utils::dmidecode; 37 | use ImVirt::Utils::dmesg; 38 | use ImVirt::Utils::sysfs; 39 | use ImVirt::Utils::procfs; 40 | use ImVirt::Utils::helper; 41 | use ImVirt::Utils::kmods; 42 | 43 | ImVirt::register_vmd(__PACKAGE__); 44 | 45 | sub detect($) { 46 | ImVirt::debug(__PACKAGE__, 'detect()'); 47 | 48 | my $dref = shift; 49 | 50 | # Check dmidecode 51 | if(defined(my $spn = dmidecode_string('system-product-name'))) { 52 | if ($spn =~ /^(KVM|Bochs)/) { 53 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 54 | } 55 | else { 56 | ImVirt::dec_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 57 | } 58 | } 59 | if(defined(my $spn = dmidecode_string('bios-vendor'))) { 60 | if ($spn =~ /^(QEMU|Bochs)/) { 61 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 62 | } 63 | else { 64 | ImVirt::dec_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 65 | } 66 | } 67 | 68 | # Look for dmesg lines 69 | if(defined(my $m = dmesg_match( 70 | ' QEMUAPIC ' => IMV_PTS_NORMAL, 71 | 'QEMU Virtual CPU' => IMV_PTS_NORMAL, 72 | 'Booting paravirtualized kernel on KVM' => IMV_PTS_MAJOR, 73 | 'kvm-clock' => IMV_PTS_MAJOR, 74 | ))) { 75 | if($m > 0) { 76 | ImVirt::inc_pts($dref, $m, IMV_VIRTUAL, PRODUCT); 77 | } 78 | else { 79 | ImVirt::dec_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 80 | } 81 | } 82 | 83 | # Look for clock source 84 | if(defined(my $cs = sysfs_read('devices/system/clocksource/clocksource0/available_clocksource'))) { 85 | if($cs =~ /kvm/) { 86 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 87 | } 88 | else { 89 | ImVirt::dec_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 90 | } 91 | } 92 | 93 | # Check /proc/cpuinfo 94 | my %cpuinfo = cpuinfo_get(); 95 | foreach my $cpu (keys %cpuinfo) { 96 | if(exists(${$cpuinfo{$cpu}}{'model name'}) && ${$cpuinfo{$cpu}}{'model name'} =~ /QEMU Virtual CPU/) { 97 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 98 | } 99 | } 100 | 101 | # Check /proc/bus/pci/devices 102 | my %pcidevs = pcidevs_get(); 103 | foreach my $addr (keys %pcidevs) { 104 | if(${$pcidevs{$addr}}{'device'} =~ /Qumranet, Inc\. Virtio/) { 105 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 106 | } 107 | } 108 | 109 | # Check helper output for hypervisor detection 110 | if(my $hvm = helper('hvm')) { 111 | if($hvm =~ /KVM/) { 112 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 113 | } 114 | } 115 | 116 | # Look for virtio modules 117 | my $p = kmods_match_used( 118 | '^virtio(_(blk|pci|net|ballon|ring))?$' => IMV_PTS_MINOR, 119 | ); 120 | if($p > 0) { 121 | ImVirt::inc_pts($dref, $p, IMV_VIRTUAL, PRODUCT); 122 | } 123 | } 124 | 125 | sub pres() { 126 | return (PRODUCT); 127 | } 128 | 129 | 1; 130 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/VMD/Microsoft.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::VMD::Microsoft; 26 | 27 | use strict; 28 | use warnings; 29 | use constant PRODUCT => '|Microsoft'; 30 | use constant HYPERV => 'Hyper-V'; 31 | use constant VIRTUALPC => 'VirtualPC'; 32 | 33 | use ImVirt; 34 | use ImVirt::Utils::blkdev; 35 | use ImVirt::Utils::dmidecode; 36 | use ImVirt::Utils::dmesg; 37 | use ImVirt::Utils::helper; 38 | use ImVirt::Utils::pcidevs; 39 | use ImVirt::Utils::procfs; 40 | use ImVirt::Utils::kmods; 41 | 42 | ImVirt::register_vmd(__PACKAGE__); 43 | 44 | sub detect($) { 45 | ImVirt::debug(__PACKAGE__, 'detect()'); 46 | 47 | my $dref = shift; 48 | 49 | if(defined(my $spn = dmidecode_string('system-product-name'))) { 50 | if ($spn =~ /^Virtual Machine/) { 51 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 52 | } 53 | else { 54 | ImVirt::dec_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 55 | } 56 | } 57 | 58 | my $p = blkdev_match( 59 | 'Virtual HD' => IMV_PTS_NORMAL, 60 | 'Virtual CD' => IMV_PTS_NORMAL, 61 | ); 62 | if($p > 0) { 63 | ImVirt::inc_pts($dref, $p, IMV_VIRTUAL, PRODUCT); 64 | } 65 | else { 66 | ImVirt::dec_pts($dref, IMV_PTS_NORMAL, IMV_VIRTUAL, PRODUCT); 67 | } 68 | 69 | # Check helper output 70 | if(my $hlp = helper('hyperv')) { 71 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 72 | } 73 | 74 | # Check /proc/bus/pci/devices 75 | my %pcidevs = pcidevs_get(); 76 | foreach my $addr (keys %pcidevs) { 77 | if( 78 | ${$pcidevs{$addr}}{'device'} eq 'Hyper-V virtual VGA' && 79 | ${$pcidevs{$addr}}{'vendor'} eq 'Microsoft Corporation' 80 | ) { 81 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT, HYPERV); 82 | } 83 | elsif(${$pcidevs{$addr}}{'device'} eq 'DECchip 21140 [FasterNet]') { 84 | ImVirt::inc_pts($dref, IMV_PTS_MINOR, IMV_VIRTUAL, PRODUCT); 85 | } 86 | elsif( 87 | ${$pcidevs{$addr}}{'type'} eq 'Multimedia audio controller' && 88 | ${$pcidevs{$addr}}{'vendor'} eq 'Microsoft Corporation' && 89 | ${$pcidevs{$addr}}{'device'} eq 'Device 0007' 90 | ) { 91 | ImVirt::inc_pts($dref, IMV_PTS_MINOR, IMV_VIRTUAL, PRODUCT, VIRTUALPC); 92 | } 93 | } 94 | 95 | # Check /proc/irq/7/hyperv 96 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT, HYPERV) 97 | if(procfs_isdir('irq/7/hyperv')); 98 | 99 | # Look for Hyper-V modules 100 | $p = kmods_match_used( 101 | '^hv_(vmbus|storvsc|netvsc|utils)$' => IMV_PTS_NORMAL, 102 | ); 103 | if($p > 0) { 104 | ImVirt::inc_pts($dref, $p, IMV_VIRTUAL, PRODUCT); 105 | } 106 | } 107 | 108 | sub pres() { 109 | return ( 110 | PRODUCT, 111 | PRODUCT.' '.HYPERV, 112 | PRODUCT.' '.VIRTUALPC 113 | ); 114 | } 115 | 116 | 1; 117 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/VMD/Parallels.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::VMD::Parallels; 26 | 27 | use strict; 28 | use warnings; 29 | use constant PRODUCT => '|Parallels'; 30 | 31 | use ImVirt; 32 | use ImVirt::Utils::cpuinfo; 33 | use ImVirt::Utils::dmesg; 34 | use ImVirt::Utils::kmods; 35 | use ImVirt::Utils::pcidevs; 36 | use ImVirt::Utils::dmidecode; 37 | use ImVirt::Utils::dmesg; 38 | use ImVirt::Utils::sysfs; 39 | use ImVirt::Utils::procfs; 40 | use ImVirt::Utils::helper; 41 | use ImVirt::Utils::kmods; 42 | 43 | ImVirt::register_vmd(__PACKAGE__); 44 | 45 | sub detect($) { 46 | ImVirt::debug(__PACKAGE__, 'detect()'); 47 | 48 | my $dref = shift; 49 | 50 | # Check dmidecode 51 | if(defined(my $spn = dmidecode_string('system-product-name'))) { 52 | if ($spn =~ /^Parallels Virtual Platform/) { 53 | ImVirt::inc_pts($dref, IMV_PTS_DRASTIC, IMV_VIRTUAL, PRODUCT); 54 | } 55 | else { 56 | ImVirt::dec_pts($dref, IMV_PTS_DRASTIC, IMV_VIRTUAL, PRODUCT); 57 | } 58 | } 59 | if(defined(my $spn = dmidecode_string('bios-vendor'))) { 60 | if ($spn =~ /^Parallels Software International Inc\./) { 61 | ImVirt::inc_pts($dref, IMV_PTS_DRASTIC, IMV_VIRTUAL, PRODUCT); 62 | } 63 | else { 64 | ImVirt::dec_pts($dref, IMV_PTS_DRASTIC, IMV_VIRTUAL, PRODUCT); 65 | } 66 | } 67 | 68 | # Look for dmesg lines 69 | if(defined(my $m = dmesg_match( 70 | 'Booting paravirtualized kernel on KVM' => IMV_PTS_NORMAL, 71 | 'kvm-clock' => IMV_PTS_NORMAL, 72 | 'DMI: Parallels Software International Inc.' => IMV_PTS_DRASTIC, 73 | 'intel8x0: enable Parallels VM optimization' => IMV_PTS_DRASTIC, 74 | ))) { 75 | if($m > 0) { 76 | ImVirt::inc_pts($dref, $m, IMV_VIRTUAL, PRODUCT); 77 | } 78 | else { 79 | ImVirt::dec_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 80 | } 81 | } 82 | 83 | # Look for clock source 84 | if(defined(my $cs = sysfs_read('devices/system/clocksource/clocksource0/available_clocksource'))) { 85 | if($cs =~ /kvm/) { 86 | ImVirt::inc_pts($dref, IMV_PTS_MINOR, IMV_VIRTUAL, PRODUCT); 87 | } 88 | else { 89 | ImVirt::dec_pts($dref, IMV_PTS_MINOR, IMV_VIRTUAL, PRODUCT); 90 | } 91 | } 92 | 93 | # Check /proc/bus/pci/devices 94 | my %pcidevs = pcidevs_get(); 95 | foreach my $addr (keys %pcidevs) { 96 | if(${$pcidevs{$addr}}{'device'} =~ /Parallels, Inc\. /) { 97 | ImVirt::inc_pts($dref, IMV_PTS_DRASTIC, IMV_VIRTUAL, PRODUCT); 98 | } 99 | } 100 | 101 | # Check helper output for hypervisor detection 102 | if(my $hvm = helper('hvm')) { 103 | if($hvm =~ /KVM/) { 104 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 105 | } 106 | } 107 | 108 | # Look for virtio modules 109 | my $p = kmods_match_used( 110 | '^virtio(_(blk|pci|net|ballon|ring))?$' => IMV_PTS_MINOR, 111 | ); 112 | if($p > 0) { 113 | ImVirt::inc_pts($dref, $p, IMV_VIRTUAL, PRODUCT); 114 | } 115 | 116 | # Look for e1000, snd_intel8x0 117 | $p = kmods_match_used( 118 | '^(e1000|snd_intel8x0)?$' => IMV_PTS_MINOR, 119 | ); 120 | if($p > 0) { 121 | ImVirt::inc_pts($dref, $p, IMV_VIRTUAL, PRODUCT); 122 | } 123 | } 124 | 125 | sub pres() { 126 | return (PRODUCT); 127 | } 128 | 129 | 1; 130 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/VMD/PillBox.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::VMD::PillBox; 26 | 27 | use strict; 28 | use warnings; 29 | 30 | use ImVirt; 31 | use ImVirt::Utils::helper; 32 | 33 | ImVirt::register_vmd(__PACKAGE__); 34 | 35 | # 36 | # The detection heuristic is based on: 37 | # 38 | # [1] "Red Pill... or how to detect VMM using (almost) one CPU instruction" 39 | # Joanna Rutkowska 40 | # http://invisiblethings.org/papers/redpill.html 41 | # 42 | # [2] "Detecting the Presence of Virtual Machines Using the Local Data Table" 43 | # Danny Quist, Val Smith 44 | # http://www.offensivecomputing.net/files/active/0/vm.pdf 45 | # 46 | # [3] "Methods for Virtual Machine Detection" 47 | # Alfredo Andrés Omella 48 | # http://www.s21sec.com/descargas/vmware-eng.pdf 49 | # 50 | # [4] "ScoopyNG - The VMware detection tool" 51 | # Tobias Klein 52 | # http://www.trapkit.de/research/vmm/scoopyng/index.html 53 | 54 | sub detect($) { 55 | ImVirt::debug(__PACKAGE__, 'detect()'); 56 | 57 | my $dref = shift; 58 | 59 | if (my $pb = helper('pillbox')) { 60 | my %pb = split(/,/, $pb); 61 | 62 | # pillbox was bound to one cpu - if we got different 63 | # IDTR/GDTR values, we are virtualized (so the HVM 64 | # did schedule us on a different physical cpus) or 65 | # our cpu has been taken offline. 66 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL) 67 | if (exists($pb{'idt2'}) || exists($pb{'gdt2'})); 68 | 69 | ImVirt::inc_pts($dref, IMV_PTS_NORMAL, IMV_VIRTUAL) 70 | if ((($pb{'idt'} & 0xffff) > 0xd000) && 71 | (($pb{'gdt'} & 0xffff) > 0xd000)); # [1] 72 | 73 | ImVirt::inc_pts($dref, IMV_PTS_MINOR, IMV_VIRTUAL) 74 | if ($pb{'ldt'} > 0); # [2] 75 | 76 | ImVirt::inc_pts($dref, IMV_PTS_MINOR, IMV_VIRTUAL, '|VMware') 77 | if ($pb{'tr'} == 0x4000); # [3] 78 | 79 | ImVirt::inc_pts($dref, IMV_PTS_MINOR, IMV_VIRTUAL, '|VMware') 80 | if ($pb{'idt'} >> 24 == 0xff); # [4] 81 | 82 | ImVirt::inc_pts($dref, IMV_PTS_MINOR, IMV_VIRTUAL, '|VMware') 83 | if ($pb{'gdt'} >> 24 == 0xff); # [4] 84 | } 85 | } 86 | 87 | sub pres() { 88 | return ('|VMware'); 89 | } 90 | 91 | 1; 92 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/VMD/QEMU.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::VMD::QEMU; 26 | 27 | use strict; 28 | use warnings; 29 | use constant PRODUCT => '|QEMU'; 30 | 31 | use ImVirt; 32 | use ImVirt::Utils::blkdev; 33 | use ImVirt::Utils::dmidecode; 34 | use ImVirt::Utils::dmesg; 35 | use ImVirt::Utils::helper; 36 | 37 | ImVirt::register_vmd(__PACKAGE__); 38 | 39 | sub detect($) { 40 | ImVirt::debug(__PACKAGE__, 'detect()'); 41 | 42 | my $dref = shift; 43 | 44 | if(defined(my $spn = dmidecode_string('bios-vendor'))) { 45 | if ($spn =~ /^QEMU/) { 46 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 47 | } 48 | else { 49 | ImVirt::dec_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 50 | } 51 | } 52 | 53 | # Look for dmesg lines 54 | if(defined(my $m = dmesg_match( 55 | ' QEMUAPIC ' => IMV_PTS_NORMAL, 56 | 'QEMU Virtual CPU' => IMV_PTS_NORMAL, 57 | ))) { 58 | if($m > 0) { 59 | ImVirt::inc_pts($dref, $m, IMV_VIRTUAL, PRODUCT); 60 | } 61 | else { 62 | ImVirt::dec_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 63 | } 64 | } 65 | 66 | my $p = blkdev_match( 67 | 'QEMU HARDDISK,' => IMV_PTS_NORMAL, 68 | 'QEMU CD-ROM,' => IMV_PTS_NORMAL, 69 | ); 70 | if($p > 0) { 71 | ImVirt::inc_pts($dref, $p, IMV_VIRTUAL, PRODUCT); 72 | } 73 | else { 74 | ImVirt::dec_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 75 | } 76 | 77 | # KVM? 78 | # Check helper output for hypervisor detection 79 | if(my $hvm = helper('hvm')) { 80 | if($hvm =~ /KVM/) { 81 | ImVirt::dec_pts($dref, IMV_PTS_DRASTIC, IMV_VIRTUAL, PRODUCT); 82 | } 83 | } 84 | 85 | } 86 | 87 | sub pres() { 88 | return (PRODUCT); 89 | } 90 | 91 | 1; 92 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/VMD/VMware.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2013 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::VMD::VMware; 26 | 27 | use strict; 28 | use warnings; 29 | use constant PRODUCT => '|VMware'; 30 | 31 | use ImVirt; 32 | use ImVirt::Utils::blkdev; 33 | use ImVirt::Utils::helper; 34 | use ImVirt::Utils::dmesg; 35 | use ImVirt::Utils::dmidecode; 36 | use ImVirt::Utils::kmods; 37 | use ImVirt::Utils::pcidevs; 38 | 39 | ImVirt::register_vmd(__PACKAGE__); 40 | 41 | sub detect($) { 42 | ImVirt::debug(__PACKAGE__, 'detect()'); 43 | 44 | my $dref = shift; 45 | 46 | if(defined(my $spn = dmidecode_string('system-product-name'))) { 47 | if ($spn =~ /^VMware/) { 48 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 49 | } 50 | else { 51 | ImVirt::dec_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 52 | } 53 | } 54 | 55 | # Look for dmesg lines 56 | if(defined(my $m = dmesg_match( 57 | 'Hypervisor detected: VMware' => IMV_PTS_MAJOR, 58 | 'Booting paravirtualized kernel on vmi' => IMV_PTS_MAJOR, 59 | 'VMware vmxnet virtual NIC driver' => IMV_PTS_NORMAL, 60 | ))) { 61 | if($m > 0) { 62 | ImVirt::inc_pts($dref, $m, IMV_VIRTUAL, PRODUCT); 63 | } 64 | else { 65 | ImVirt::dec_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 66 | } 67 | } 68 | 69 | # Look for block device names 70 | my $p = blkdev_match( 71 | 'Vendor: VMware\s+Model: Virtual disk' => IMV_PTS_NORMAL, 72 | 'Vendor: VMware,\s+Model: VMware Virtual ' => IMV_PTS_NORMAL, 73 | 'VMware Virtual IDE CDROM Drive' => IMV_PTS_NORMAL, 74 | ); 75 | if($p > 0) { 76 | ImVirt::inc_pts($dref, $p, IMV_VIRTUAL, PRODUCT); 77 | } 78 | else { 79 | ImVirt::dec_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 80 | } 81 | 82 | # Check /proc/bus/pci/devices 83 | my %pcidevs = pcidevs_get(); 84 | foreach my $addr (keys %pcidevs) { 85 | if(${$pcidevs{$addr}}{'vendor'} =~ /VMware/) { 86 | ImVirt::inc_pts($dref, IMV_PTS_NORMAL, IMV_VIRTUAL, PRODUCT); 87 | } 88 | } 89 | 90 | # Look for loaded modules 91 | $p = kmods_match( 92 | '^vmblock$' => IMV_PTS_NORMAL, 93 | '^vmhgfs$' => IMV_PTS_NORMAL, 94 | '^vmmemctl$' => IMV_PTS_NORMAL, 95 | '^vmxnet$' => IMV_PTS_NORMAL, 96 | '^vmxnet3$' => IMV_PTS_NORMAL, 97 | '^vmblock$' => IMV_PTS_NORMAL, 98 | '^vmsync$' => IMV_PTS_NORMAL, 99 | '^vmci$' => IMV_PTS_NORMAL, 100 | '^vsock$' => IMV_PTS_NORMAL, 101 | '^vmw_balloon$' => IMV_PTS_NORMAL, 102 | '^pcnet32$' => IMV_PTS_MINOR, 103 | '^BusLogic$' => IMV_PTS_MINOR, 104 | ); 105 | if($p > 0) { 106 | ImVirt::inc_pts($dref, $p, IMV_VIRTUAL, PRODUCT); 107 | } 108 | else { 109 | ImVirt::dec_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 110 | } 111 | 112 | # Check helper output 113 | if(my $hlp = helper('vmware')) { 114 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT, split(/\s+/, $hlp)); 115 | } 116 | } 117 | 118 | sub pres() { 119 | my @prods = ( 120 | PRODUCT, 121 | PRODUCT.' Express', 122 | PRODUCT.' ESX Server', 123 | PRODUCT.' GSX Server', 124 | PRODUCT.' Workstation', 125 | ); 126 | 127 | return @prods; 128 | } 129 | 130 | 1; 131 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/VMD/VirtualBox.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::VMD::VirtualBox; 26 | 27 | use strict; 28 | use warnings; 29 | use constant PRODUCT => '|VirtualBox'; 30 | 31 | use ImVirt; 32 | use ImVirt::Utils::blkdev; 33 | use ImVirt::Utils::dmesg; 34 | 35 | ImVirt::register_vmd(__PACKAGE__); 36 | 37 | sub detect($) { 38 | ImVirt::debug(__PACKAGE__, 'detect()'); 39 | 40 | my $dref = shift; 41 | 42 | # Look for dmesg lines 43 | if(defined(my $m = dmesg_match( 44 | ' VBOXBIOS ' => IMV_PTS_NORMAL, 45 | ': VBOX HARDDISK,' => IMV_PTS_NORMAL, 46 | ': VBOX CD-ROM,' => IMV_PTS_NORMAL, 47 | ))) { 48 | if($m > 0) { 49 | ImVirt::inc_pts($dref, $m, IMV_VIRTUAL, PRODUCT); 50 | } 51 | else { 52 | ImVirt::dec_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 53 | } 54 | } 55 | 56 | my $p = blkdev_match( 57 | 'VBOX HARDDISK' => IMV_PTS_NORMAL, 58 | 'VBOX CD-ROM' => IMV_PTS_NORMAL, 59 | ); 60 | if($p > 0) { 61 | ImVirt::inc_pts($dref, $p, IMV_VIRTUAL, PRODUCT); 62 | } 63 | else { 64 | ImVirt::dec_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 65 | } 66 | } 67 | 68 | sub pres() { 69 | return (PRODUCT); 70 | } 71 | 72 | 1; 73 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/VMD/Xen.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2009 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::VMD::Xen; 26 | 27 | use strict; 28 | use warnings; 29 | use constant PRODUCT => '|Xen'; 30 | 31 | use ImVirt; 32 | use ImVirt::Utils::dmidecode; 33 | use ImVirt::Utils::dmesg; 34 | use ImVirt::Utils::helper; 35 | use ImVirt::Utils::procfs; 36 | use ImVirt::Utils::sysfs; 37 | 38 | ImVirt::register_vmd(__PACKAGE__); 39 | 40 | sub detect($) { 41 | ImVirt::debug(__PACKAGE__, 'detect()'); 42 | 43 | my $dref = shift; 44 | 45 | # Check dmidecode 46 | if(defined(my $spn = dmidecode_string('bios-vendor'))) { 47 | if ($spn =~ /^Xen/) { 48 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 49 | } 50 | else { 51 | ImVirt::dec_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 52 | } 53 | } 54 | 55 | # Look for paravirutalized oldstyle Xen 56 | if(procfs_isdir('xen')) { 57 | ImVirt::inc_pts($dref, IMV_PTS_NORMAL, IMV_VIRTUAL, PRODUCT, 'PV'); 58 | } 59 | # Look for paravirutalized newstyle Xen 60 | elsif(defined(my $cs = sysfs_read('devices/system/clocksource/clocksource0/available_clocksource'))) { 61 | if($cs =~ /xen/) { 62 | ImVirt::inc_pts($dref, IMV_PTS_NORMAL, IMV_VIRTUAL, PRODUCT, 'PV'); 63 | } 64 | else { 65 | ImVirt::dec_pts($dref, IMV_PTS_NORMAL, IMV_VIRTUAL, PRODUCT, 'PV'); 66 | } 67 | } 68 | 69 | # Look for dmesg lines 70 | if(defined(my $m = dmesg_match( 71 | 'Hypervisor signature: xen' => IMV_PTS_NORMAL, 72 | 'Xen virtual console successfully installed' => IMV_PTS_NORMAL, 73 | 'Xen reported:' => IMV_PTS_NORMAL, 74 | 'Xen: \d+ - \d+' => IMV_PTS_NORMAL, 75 | 'xen-vbd: registered block device' => IMV_PTS_NORMAL, 76 | 'ACPI: RSDP \(v\d+\s+Xen ' => IMV_PTS_NORMAL, 77 | 'ACPI: XSDT \(v\d+\s+Xen ' => IMV_PTS_NORMAL, 78 | 'ACPI: FADT \(v\d+\s+Xen ' => IMV_PTS_NORMAL, 79 | 'ACPI: MADT \(v\d+\s+Xen ' => IMV_PTS_NORMAL, 80 | 'ACPI: HPET \(v\d+\s+Xen ' => IMV_PTS_NORMAL, 81 | 'ACPI: SSDT \(v\d+\s+Xen ' => IMV_PTS_NORMAL, 82 | 'ACPI: DSDT \(v\d+\s+Xen ' => IMV_PTS_NORMAL, 83 | ))) { 84 | if($m > 0) { 85 | ImVirt::inc_pts($dref, $m, IMV_VIRTUAL, PRODUCT); 86 | } 87 | else { 88 | ImVirt::dec_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT); 89 | } 90 | 91 | # Paravirtualized? 92 | if(defined(my $m = dmesg_match( 93 | 'Booting paravirtualized kernel on Xen' => IMV_PTS_MAJOR, 94 | ))) { 95 | if($m > 0) { 96 | ImVirt::inc_pts($dref, $m, IMV_VIRTUAL, PRODUCT, 'PV'); 97 | } 98 | else { 99 | ImVirt::dec_pts($dref, IMV_PTS_NORMAL, IMV_VIRTUAL, PRODUCT, 'PV'); 100 | } 101 | } 102 | } 103 | 104 | # Xen PV does not have ide/scsi drives 105 | if(procfs_isdir('ide') || procfs_isdir('scsi')) { 106 | ImVirt::dec_pts($dref, IMV_PTS_NORMAL, IMV_VIRTUAL, PRODUCT, 'PV'); 107 | } 108 | else { 109 | ImVirt::dec_pts($dref, IMV_PTS_NORMAL, IMV_VIRTUAL, PRODUCT, 'HVM'); 110 | } 111 | 112 | # Check helper output 113 | if(my $hlp = helper('xen')) { 114 | ImVirt::inc_pts($dref, IMV_PTS_MAJOR, IMV_VIRTUAL, PRODUCT, split(/\s+/, $hlp)); 115 | } 116 | 117 | # Check /sys/hypervisor/type 118 | if(defined(my $hv = sysfs_read('hypervisor/type'))) { 119 | ImVirt::inc_pts($dref, IMV_PTS_NORMAL, IMV_VIRTUAL, PRODUCT) 120 | if($hv =~ /xen/i); 121 | } 122 | } 123 | 124 | sub pres() { 125 | my @prods = ( 126 | PRODUCT, 127 | PRODUCT.' PV', 128 | PRODUCT.' HVM', 129 | ); 130 | 131 | return @prods; 132 | } 133 | 134 | 1; 135 | -------------------------------------------------------------------------------- /perl/lib/ImVirt/VMD/lguest.pm: -------------------------------------------------------------------------------- 1 | # ImVirt - I'm virtualized? 2 | # 3 | # Authors: 4 | # Thomas Liske 5 | # 6 | # Copyright Holder: 7 | # 2011 - 2012 (C) IBH IT-Service GmbH [http://www.ibh.de/] 8 | # 9 | # License: 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this package; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | # 24 | 25 | package ImVirt::VMD::lguest; 26 | 27 | use strict; 28 | use warnings; 29 | use constant PRODUCT => '|lguest'; 30 | 31 | use ImVirt; 32 | use ImVirt::Utils::kmods; 33 | use ImVirt::Utils::dmesg; 34 | 35 | ImVirt::register_vmd(__PACKAGE__); 36 | 37 | sub detect($) { 38 | ImVirt::debug(__PACKAGE__, 'detect()'); 39 | 40 | my $dref = shift; 41 | 42 | # Look for a dmesg paravirtualization line 43 | if(defined(my $m = dmesg_match( 44 | 'Booting paravirtualized kernel on lguest' => IMV_PTS_MAJOR, 45 | ))) { 46 | ImVirt::inc_pts($dref, $m, IMV_VIRTUAL, PRODUCT) if($m > 0); 47 | } 48 | 49 | # Look for virtio modules 50 | my $p = kmods_match_used( 51 | '^virtio_(blk|pci|net|ballon)$' => IMV_PTS_MINOR, 52 | ); 53 | if($p > 0) { 54 | ImVirt::inc_pts($dref, $p, IMV_VIRTUAL, PRODUCT); 55 | } 56 | } 57 | 58 | sub pres() { 59 | return (PRODUCT); 60 | } 61 | 62 | 1; 63 | --------------------------------------------------------------------------------