[PATCH] virt-what.in: Added VMware virt detection using cpuid in wrapper script

Previous thread: [RFC/PATCH 1/2] VMware balloon: add module parameter limiting ballon size by Dmitry Torokhov on Tuesday, June 29, 2010 - 4:15 pm. (2 messages)

Next thread: [ANNOUNCE] Git 1.7.1.1 by Junio C Hamano on Tuesday, June 29, 2010 - 4:48 pm. (1 message)
From: Chetan Loke
Date: Tuesday, June 29, 2010 - 4:29 pm

Brief discussion thread - http://lkml.org/lkml/2010/6/29/355

Added VMware detection via cpuid.Mimic'd VMware's balloon driver's init-time
check(cpuid followed by dmi-checks). Moved the existing logic into a simple
function to achieve that.

Tested virt-what.in(ran as a script) and virt-what-cpuid-helper within
a Linux guest on ESX. Thanks.

Signed-off-by: Chetan Loke <loke.c@alumni.neu.edu>

---

virt-what.in | 150 ++++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 93 insertions(+), 57 deletions(-)



--- virt-what.in.orig   2010-06-29 18:42:20.166647585 -0400
+++ virt-what.in        2010-06-29 18:59:54.765647739 -0400
@@ -25,9 +25,19 @@
 #
 # The following resources were useful in writing this script:
 # . http://www.dmo.ca/blog/20080530151107
+#
+#
+# Added VMware detection using cpuid.
+# Added functions to check the environment type
+# 06/29/2010 - Chetan Loke <loke.c@alumni.neu.edu>
+#
+

 VERSION="@VERSION@"

+cpuid=
+is_xen=1
+
 function fail {
    echo "virt-what: $1"
    exit 1
@@ -38,7 +48,8 @@
    echo "Options:"
    echo "  --help          Display this help"
    echo "  --version       Display version and exit"
-    exit 0
+    # exit after printing
+    exit 1
 }

 # Handle the command line arguments, if any.
@@ -70,74 +81,99 @@
 exec_prefix=@exec_prefix@
 PATH=@libexecdir@:/sbin:/usr/sbin:$PATH

-# Check for various products in the BIOS information.
+detect_virt_env_using_misc_info() {

-dmi=`dmidecode 2>&1`
+       # Check for various products in the BIOS information.

-if echo "$dmi" | grep -q 'Manufacturer: VMware'; then
-    echo vmware
-fi
+       dmi=`dmidecode 2>&1`

-if echo "$dmi" | grep -q 'Manufacturer: Microsoft Corporation'; then
-    echo virtualpc
-fi
+       if echo "$dmi" | grep -q 'Manufacturer: VMware'; then
+               echo vmware
+               exit 0
+       fi

-# Check for VirtualBox.
-# Added by Laurent Léonard.
-if echo "$dmi" | grep -q 'Manufacturer: innotek GmbH'; ...
From: Richard W.M. Jones
Date: Thursday, July 1, 2010 - 6:15 am

Chetan, do you think you could send me this one again as an
attachment.  Some MUA/MTA along the way has sufficiently mangled the
patch such that it can no longer be applied.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
--

From: Chetan Loke
Date: Thursday, July 1, 2010 - 7:20 am

regards
Chetan Loke
Previous thread: [RFC/PATCH 1/2] VMware balloon: add module parameter limiting ballon size by Dmitry Torokhov on Tuesday, June 29, 2010 - 4:15 pm. (2 messages)

Next thread: [ANNOUNCE] Git 1.7.1.1 by Junio C Hamano on Tuesday, June 29, 2010 - 4:48 pm. (1 message)