Is there an OS command I can run to determine if running inside a Xen based virtual machine

痴心易碎 提交于 2019-12-12 09:29:44

问题


Is there an OS command I can run from within a Xen based virtual machine to tell me that it is a virtual box rather than a physical box - I heard that the kernel had some self awareness smarts about it. e.g. like an extra column in "ps" output or something? [I know vmstat provides the "st" column but I have seen this on physical host boxes running Linux Kernel 2.6.11 and greater as well].

Many Thanks,

Paul


回答1:


Dmesg may give some hints from the kernel message buffer, here is output on a virtualized Ubuntu instance from Slicehost:

bvm@qdbp:~$ sudo dmesg | grep Xen
[    0.000000]  Xen: 0000000000000000 - 00000000000a0000 (usable)
[    0.000000]  Xen: 00000000000a0000 - 0000000000100000 (reserved)
[    0.000000]  Xen: 0000000000100000 - 0000000010000000 (usable)
[    0.000000] Booting paravirtualized kernel on Xen
[    0.000000] Xen version: 3.1.2-rc1
[    0.000000] Xen: using vcpu_info placement
[    0.000000] Xen: using vcpuop timer interface
[    0.000000] installing Xen timer for CPU 0
[    0.021223] installing Xen timer for CPU 1
[    0.046157] installing Xen timer for CPU 2
[    0.046157] installing Xen timer for CPU 3
[    0.265880] Initialising Xen virtual ethernet driver.



回答2:


Try file /sys/hypervisor/uuid.

  1. It does not exist -> Not related to XEN.
  2. It does exist, and is full of 0-s -> It is a XEN Dom0
  3. It does exist, and has a not-0 values -> It is a DomU

This requires of course, that /sys is mounted and populated...



来源:https://stackoverflow.com/questions/3490995/is-there-an-os-command-i-can-run-to-determine-if-running-inside-a-xen-based-virt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!