Chinaunix首页 | 论坛 | 博客
  • 博客访问: 696292
  • 博文数量: 183
  • 博客积分: 2650
  • 博客等级: 少校
  • 技术积分: 1428
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-22 17:02
文章分类
文章存档

2017年(1)

2015年(46)

2014年(4)

2013年(8)

2012年(2)

2011年(27)

2010年(35)

2009年(60)

分类: 虚拟化

2015-04-20 17:27:07

最近整个了阿里云,一直以为是基于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;
}
阅读(2931) | 评论(0) | 转发(0) |
0

上一篇:kvm 概观

下一篇:QEMU 的 CPU 配置

给主人留下些什么吧!~~