简介

Intel VT-x和AMD AMD-V硬件虚拟化特性能够使虚拟机更高效的运行。 如果BIOS中使能该选项,VMware ESXi主机能够利用此功能来提高性能。本文介绍如何在ESXi主机中查看已经使能了该特性。

使用esxcfg-info命令查看

在ESXi shell中可以运行esxcfg-info命令来查看VT-X/ADM-V的配置和使用情况。

~ # esxcfg-info -w | grep "HV Support"
      |----HV Support...............................................3
下面的表格中,列出了HV Support支持的值及含义

含义
0 VT-X/AMD-V support is not avaliable for this hardware
1 VT-X/AMD-V might be avaiiable on this CPU but it is not supported for this hardware
2 VT-X/AMD-V is available but is currently not enabled in the BIOS
VT-X/AMD-V is enabled in the BIOS and can be used






脚本批量查询

编写了一个Python脚本,支持批量查询:

#!/usr/bin/env python

import os
import paramiko

def ping(host, cnt):
    '''ping test'''
    import subprocess,traceback, platform
    print platform.system()
    if platform.system()=='Windows':
        cmd = 'ping -n %d %s' % (cnt, host)
    else:
        cmd = 'ping -c %d %s' % (cnt, host)
        
    try:
        p = subprocess.Popen(args=cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
        (stdoutput,erroutput) = p.communicate()
        # print stdoutput
    except Exception, e:
        traceback.print_exc()
    
    if platform.system()=='Windows':
        return stdoutput.find('Received = %d' % cnt )>=0
    else:
        return stdoutput.find('%d received' % cnt)>=0

def collect_platform_info(ip, fd):
    fd.write("%-20s" % ip)
    
    if not ping(ip, 3):
        fd.write("--\n")
        return
    
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(ip, 22, "root", "infinera")
    
    stdin, stdout, stderr = ssh.exec_command("esxcfg-info -w | grep 'HV Support'")
    for l in stdout.readlines():
        fd.write("%s\n" % l.strip())
 
    ssh.close()

if __name__ == "__main__":
    result_file = "/home/infinera/server_stats.txt"
    os.remove(result_file)
    fd_res = open(result_file, "w")
    fd_res.write("%-20s|%s\n" % ("HV IP", "VT-X"))
    fd_res.write(80 * "-")
    fd_res.write("\n")
        
    fd_ips = open("/home/infinera/server_list.txt", "r")
    for l in fd_ips.readlines():
        ip = l.strip()
        collect_platform_info(ip, fd_res)
    
    fd_ips.close()
    fd_res.close()

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐