How to identify that you're running under a VM?

后端 未结 12 2000
南旧
南旧 2020-11-29 23:42

Is there a way to identify, from within a VM, that your code is running inside a VM?

I guess there are more or less easy ways to identify specific VM systems, especi

12条回答
  •  旧时难觅i
    2020-11-30 00:33

    In most cases, you shouldn't try to. You shouldn't care if someone is running your code in a VM, except in a few specific cases.

    If you need to, in Linux the most common way is to look at /sys/devices/virtual/dmi/id/product_name, which will list the name of the laptop/mainboard on most real systems, and the hypervisor on most virtual systems. dmidecode | grep Product is another common method, but I think that requires root access.

提交回复
热议问题