How can I tell from the command line if the server has KVM enabled?

2

I am trying to solve a problem of how to run an android emulator inside a Docker container for the purposes of end-to-end testing in CI build.

One solution I have found says that it "requires KVM enabled on the host machine".

I have SSH access to this machine.

How can I find out if KVM is enabled?

All the resources I found involved enabling KVM but I do not want to make any changes, only view the current state of the server. Thanks

alichur

Posted 2019-02-13T16:40:56.960

Reputation: 123

Answers

1

I believe that the simplest check is whether the file /dev/kvm exists.

I base this on the github article QEMU/KVM on Docker and CoreOS:

For the most part, it is fairly easy to run kvm within docker. The only real hiccup is that /dev/kvm (the device node for the kernel hypervisor access) isn't reissued (or permitted) within docker. That means we have to do two things for basic usage:

  • Make the device node
  • Execute the docker container with --privileged

You might also be able to use the kvm-ok command.
See this answer for the generated output of the command when KVM is present or not.

harrymc

Posted 2019-02-13T16:40:56.960

Reputation: 306 093

I wasn't able to use kvm-ok as it required installing something new. But I do have the directory /dev/kvm so that looks promising. Thanks! – alichur – 2019-02-14T09:16:29.200