最近整个了阿里云,一直以为是基于kvm的,今天用代码测试了下,原来是Xen的
#include
#include
#include
#define SIGNATURE 0x40000000
static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx)
{
asm volatile("cpuid"
: "=a" (*eax),
"=b" (*ebx),
"=c" (*ecx),
"=d" (*edx)
: "0" (*eax), "2" (*ecx));
}
void cpuid(unsigned int op,
unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx)
{
*eax = op;
*ecx = 0;
__cpuid(eax, ebx, ecx, edx);
}
int main(int argc,char *argv[])
{
unsigned int eax, ebx, ecx, edx;
char signature[13];
cpuid(SIGNATURE, &eax, &ebx, &ecx, &edx);
memcpy(signature + 0, &ebx, 4);
memcpy(signature + 4, &ecx, 4);
memcpy(signature + 8, &edx, 4);
signature[12] = 0;
if (strncmp(signature, "KVMKVMKVM",9) == 0)
printf("kvm\n");
else if(strncmp(signature,"XenVMMXenVMM",12) == 0)
printf("XEN\n");
else if(strncmp(signature,"VMwareVMware",12) == 0)
printf("VMware\n");
else
printf("%s\n",signature);
return 0;
}
阅读(2977) | 评论(0) | 转发(0) |