如何以编程方式知道我是否在VM中? [英] How can I programmatically know if I am in a VM?
本文介绍了如何以编程方式知道我是否在VM中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望能够从Windows和Linux上做到这一点.我知道可以通过获取sysinfo并使用与硬件标识符相关的经验法则来实现.
I want to be able to do so from both Windows and from Linux. I know that there are ways by getting sysinfo and using thumb rules related to hardware identifiers.
我想知道是否还有更基本的方法,例如查看内存地址/发出中断等.
I want to know if there is a more fundamental method, like looking at a memory address / issuing an interrupt etc.
顺便说一句,我正在尝试在Intel硬件上执行此操作,而我使用的虚拟化软件是Vmware Workstation和Windows HyperV.
BTW I am trying to do this on Intel hardware and the virtualization software I use are Vmware Workstation and Windows HyperV.
推荐答案
这是另一个有用的命令:
Here is one more useful command:
$ lscpu | grep -E 'Hypervisor vendor|Virtualization type'
Hypervisor vendor: KVM
Virtualization type: full
其他命令的示例输出:
$ sudo virt-what
kvm
$ dmesg | grep -i virtual
[ 0.000000] Booting paravirtualized kernel on KVM
[ 0.029160] CPU0: Intel QEMU Virtual CPU version 1.0 stepping 03
$ sudo dmidecode | egrep -i 'manufacturer|product|vendor|domU'
Vendor: Bochs
Manufacturer: Bochs
Product Name: Bochs
Manufacturer: Bochs
Manufacturer: Bochs
Manufacturer: Bochs
Manufacturer: Bochs
Manufacturer: Bochs
Manufacturer: Bochs
Manufacturer: Bochs
Manufacturer: Bochs
Manufacturer: Bochs
这篇关于如何以编程方式知道我是否在VM中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文