Is there a way to find out if OS(linux) is running inside KVM guest..
dmesg, there should be at least one line containing
kvm. On my machines:
[ 0.000000] kvm-clock: cpu 0, msr 0:5dd801, boot clock [ 0.000000] kvm-clock: cpu 0, msr 0:1023801, primary cpu clock
/proc/cpuinfo, it contains a line:
model name : QEMU Virtual CPU version 0.9.1
But, the problem is: You can't be sure you are an KVM guest (on top of QEMU) or only a QEMU-Guest.
returns on this Ubuntu 18.04 KVM setup:
and on my host:
Tested on an Ubuntu 18.04 host.
Current versions of
lscpu also show if a hypervisor is detected:
# lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 2 On-line CPU(s) list: 0,1 Thread(s) per core: 1 Core(s) per socket: 1 Socket(s): 2 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 23 Model name: Intel Core 2 Duo P9xxx (Penryn Class Core 2) Stepping: 3 CPU MHz: 2659.936 BogoMIPS: 5319.87 Hypervisor vendor: KVM Virtualization type: full ...