Is there any portable way or library to check if Python script is running on a virtualized OS and also which virtualization platform it's running on.
This Detect virtualized OS from an application? questions discusses a c version.
Is there any portable way or library to check if Python script is running on a virtualized OS and also which virtualization platform it's running on.
This Detect virtualized OS from an application? questions discusses a c version.
I think you call linux command virt-what
in python.
The descriptio of virt-what
is here: http://people.redhat.com/~rjones/virt-what/
To my knowledge, there is no nice, portable way to figure this out from Python. Most of the time, the way people try to figure out if they're being virtualized or not is looking for clues left by the VM -- either some instruction isn't quite right, or some behavior is off.
However, all might not be lost if you're willing to go off box. When you're in a VM, you will almost never have perfect native performance. Thus, if you make enough measurements against a server you trust, then it might be possible to detect if you're in a VM. This is especially the case if you're running on a machine with multiple machines. Check your own time, how much time you're getting scheduled, and how much wall time has past (based on an external measurement because you can't trust the local machine). You'll probably have better luck if you can watch how much time has passed on the local machine rather than just inside one process.