检测系统虚拟化

下​面​的​脚​本​可​以​鉴​别​系​统​是​半​虚​拟​客​户​端​、​全​虚​拟​客​户​端​还​是​裸​机​主​机

#!/bin/bash
declare -i IS_HVM=0
declare -i IS_PARA=0
check_hvm()
{
IS_X86HVM="$(strings /proc/acpi/dsdt | grep int-xen)"
  if [ x"${IS_X86HVM}" != x ]; then
   echo "Guest type is full-virt x86hvm"
   IS_HVM=1
fi
}
check_para()
{
if $(grep -q control_d /proc/xen/capabilities); then
  echo "Host is dom0"
  IS_PARA=1
else
  echo "Guest is para-virt domU"
  IS_PARA=1
fi
}
if [ -f /proc/acpi/dsdt ]; then
check_hvm
fi

if [ ${IS_HVM} -eq 0 ]; then
if [ -f /proc/xen/capabilities ] ; then
check_para
fi
     fi
if [ ${IS_HVM} -eq 0 -a ${IS_PARA} -eq 0 ]; then
echo "Baremetal platform"
fi

你可能感兴趣的:(检测,虚拟化)