Just determine OpenVZ/Xen PV/UML
It is easiest to judge OpenVZ/Xen PV/UML. Check the relevant directories and files under /proc directly. You know, for example, the /proc/vz file on OpenVZ VPS; the /proc/xen/directory on the Xen PV virtual machine, and some things in the directory; /proc/cpuinfo on UML will find the UML flag. I wrote a simple Python script to detect: #!/usr/bin/python# check if a linux system running on a virtual machine (openvz/xen pv/uml)
import sys, os
def main():if os.getuid() != 0:print "must be run as root"sys.exit(0)
# check OpenVZ/Virtuozzoif os.path.exists( "/proc/vz"):if not os.path.exists("/proc/bc"):print "openvz container"else:print "openvz node"
# check Xenif os .path.exists("/proc/xen/capabilities"):if (os.path.getsize("/proc/xen/capabilities") > 0):print "xen dom0"else:print " Xen domU"
# check User Mode Linux (UML)f = open("/proc/cpuinfo", "r"); t = f.read(); f.close()if ( T.find("UML") > 0):print "uml"
if __name__=="__main__":main()
Judging VMware/Xen HVM/KVM
If you are using a virtual virtual such as VMware/Xen HVM/KVM, it is more difficult to judge. The most accurate way is to read the CPUID to judge. The Xen source code has a section below to check if Xen's C code is tools/misc/xen-detect.c. This code provides a good example. VPSee rewrites the code, replaces the function with a macro, and adds a pair. The identification of VMware and KVM, compiled with gcc, can be run: /** check if a linux system running on a virtual machine (vmware/xen hvm/kvm)*/#include stdio.h#include string.h
#define HYPERVISOR_INFO 0x40000000
#define CPUID(idx, eax, ebx, ecx, edx) \\asm volatile ( \\"test %1,%1 ; jz 1f ; ud2a ; .ascii \\" ;xen\\" ; 1: cpuid" \\: "=b" (*ebx), "=a" (*eax), "=c" (*ecx), "=d" (*edx ) \\: "0" (idx) );
int main(void){unsigned int eax, ebx, ecx, edx;char string[13];
CPUID(HYPERVISOR_INFO, &eax, &ebx, &ecx, &edx);*(unsigned int *)(string+0) = ebx;*(unsigned int *)(string+4) = ecx;*(unsigned int * )(string+8) = edx;
string[12] = 0;if (strncmp(string, "XenVMMXenVMM", 12) == 0) {printf ("xen hvm\ ");} else if (strncmp(string, "VMwareVMware", 12) == 0) {printf("vmware\ ");} else if (strncmp(string, " KVMKVMKVM", 12) == 0) {printf("kvm\ ");} elseprintf("bare hardware\ ");
return 0;}
Judging VirtualBox /Virtual PC
What? This kind of home desktop virtual machine will not know what to install? ! If you don't know, there is a way to run the dmidecode tool under Linux and look for Manufacturer: innotek GmbH, Manufacturer: Microsoft Corporation keywords to correspond to VirtualBox and Virtual PC.
Faced with powerful Microsoft and early NetWare, Linux server operating system can be said to be a r
To open a previously compiled normal project (created with IAR5.5), the following error is reported
According to foreign media reports, Linux does not seem to be fully loved by people. Operating syste
First, the Linux system startup process About the Linux system startup process we can divide into th
Linux shell time calculation and time difference calculation method
Modify IP, DNS, and routing configuration under Linux operating system
Linux kernel root directory Makefile annotation
Mounting of text editors and external storage devices in Linux system
Desktop Linux opportunities come
Windows XP system troubleshooting method
Linux mount command system mount and image processing
LINUX View Hardware Configuration Commands
Linux operating system failure skills
You may not know Linux interprocess communication
Windows 10 official version of the insider project needs to be bound to Microsoft account
PMagic changes the partition installation NT failure and excludes the instance
How Win10 adds an address input box to the taskbar
Fresh Tips for Playing Remote Desktop Connections
Win10 preview version 10125 update content introduction
How to export favorites in Win8 IE browser
Explanation of several problems of Win2000 diagnostic tool
Teach you to check the version of the VISTA system installed in the computer.