virtualization or OS ?
-
- Member
- Posts: 59
- Joined: Tue May 23, 2006 11:00 pm
virtualization or OS ?
I want to write a code which will determine whether it runs on a physical system or inside a virtualized environment / software ? Would this be possible ?
- Troy Martin
- Member
- Posts: 1686
- Joined: Fri Apr 18, 2008 4:40 pm
- Location: Langley, Vancouver, BC, Canada
- Contact:
Re: virtualization or OS ?
Well, if the virtualization/emulation software has certain flags in CPUID, that can be used to determine if the machine is software-based or not.
Re: virtualization or OS ?
If you're referring to emulated environment, no not in general. However the emulator may have behavior that the emulated system does not, but that would need to be specific to the emulator. Why do you ask? Do your system need to do something different when it's run in the emulator? If the emulator does not support some specific hardware then you have to test for the presence of that hardware (which you must anyway). The emulator may have hardware that is not present on normal system as well, but the same goes here - you have to test for the presence of the hardware you are going to use. Also the CPU in the emulator may behave slightly differently which probably should be possible to determine via the CPUID.extremecoder wrote:I want to write a code which will determine whether it runs on a physical system or inside a virtualized environment / software ? Would this be possible ?
Re: virtualization or OS ?
If you are referring to eht AMD/Intel virtualization extensions, then yes, you can. I think some status register contains some flag indicating it runs in virtualization. Check the Intel/AMD docs for specifics.extremecoder wrote:I want to write a code which will determine whether it runs on a physical system or inside a virtualized environment / software ? Would this be possible ?
JAL
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: virtualization or OS ?
Another nice one is to check if Virtual Mode Extensions actually work. Qemu and derivatives, as well as VirtualPC, report VME support but don't actually do it. Especially useful when the VM predates the vmx era.