llemoux
By:
llemoux

Running x86 Android emulators requires kvm-intel...

April 5, 2017 1k views
System Tools CoreOS

Hi all,

I use Gitlab CI to build an Android app and automatically run tests on an Android Virtual Device (AVD). I would like to use the x86 version of this emulator instead of the ARM one.
But an x86 AVD currently requires virtualization (VT) and KVM properly installed and loaded.
All this runs in a Docker container on a DigitalOcean host.

'lscpu' shows VT is enabled for an Intel processor :
Model name: Intel(R) Xeon(R) CPU E5-2650L v3 @ 1.80GHz
Virtualization: VT-x
Hypervisor vendor: KVM
Virtualization type: full

I therefore installed qemu-kvm and other related debian packages :
export DEBIAN_FRONTEND=noninteractive
apt-get --quiet update --yes
apt-get --quiet install --yes qemu-kvm libvirt-bin virtinst bridge-utils
adduser 'id -un' libvirt

Then 'virt-host-validate' shows kvm-intel is not loaded :
$ virt-host-validate
QEMU: Checking for hardware virtualization : PASS
QEMU: Checking for device /dev/kvm : FAIL (Check that the 'kvm-intel' or 'kvm-amd' modules are loaded & the BIOS has enabled virtualization)
QEMU: Checking for device /dev/vhost-net : PASS
QEMU: Checking for device /dev/net/tun : PASS
LXC: Checking for Linux >= 2.6.26 : PASS
ERROR: Job failed: exit code 1

But, adding 'modprobe kvm-intel' fails :
$ modprobe kvm-intel
modprobe: ERROR: ../libkmod/libkmod.c:557 kmodsearchmoddep() could not open moddep file '/lib/modules/4.9.16-coreos-r1/modules.dep.bin'

And neither :
$ depmod
depmod: ERROR: could not open directory /lib/modules/4.9.16-coreos-r1: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
ERROR: Job failed: exit code 1

Nor :
$ apt-get install --reinstall linux-image-'uname -r'
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package linux-image-4.9.16-coreos-r1
E: Couldn't find any package by regex 'linux-image-4.9.16-coreos-r1'

...does solve the problem. Any idea on how I can get kvm-intel loaded ?

Kind regards,

Laurent Le Moux

2 Answers

Hi again,

Finally I got an answer here :
https://groups.google.com/d/topic/coreos-user/mvmOhDMiwsU/discussion

Basically, the virtualization packages must be installed from outside the Docker instance.
And - unfortenately - I have no control / access on it as it is automatically started by Gitlab CI runner.

I may (kindly) ask for these packages to be installed by default :
https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/issues/2242

Kind regards,

Laurent

Hi again,

I'm not a Linux container expert and I'm stuck for days now.
I would really appreciate if anyone could help me figure out what to do.

Apparently, I'm just missing 'kvm-intel.ko' module for virtualization to be operational.

I run : apt-get --quiet install --yes qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils

At some point, the installation complains :
Configuring kvm qemu-kvm
modprobe: ERROR: ../libkmod/libkmod.c:586 kmodsearchmoddep() could not open moddep file '/lib/modules/4.9.16-coreos-r1/modules.dep.bin'
modprobe: FATAL: Module kvm_intel not found in directory /lib/modules/4.9.16-coreos-r1
...done.

Surprisingly, there is actually no '/lib/modules/4.9.16-coreos-r1' directory...
Nor does '/lib/modules' exist...
Is this specific to a Linux container ?

From what I read in several posts, I need to install Linux headers. Then, the missing directory will be created and it will be possible to get 'kvm-intel.ko' properly installed in a subdirectory.

But, when I issue : apt-get --quiet install linux-headers-uname -r --yes
I get the following error :
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package linux-headers-4.9.16-coreos-r1
E: Couldn't find any package by glob 'linux-headers-4.9.16-coreos-r1'
E: Couldn't find any package by regex 'linux-headers-4.9.16-coreos-r1'

I tried to use another kernel by following this tutorial :
https://www.digitalocean.com/community/tutorials/how-to-update-a-digitalocean-server-s-kernel

Then, 'kvm-intel.ko' is avalaible but can not be loaded.
Using 'insmod -f' fails with an 'invalid module format'.

Any idea ?

Regards,

Laurent

by Adam LaGreca
Updating the kernel on your DigitalOcean Droplet is a straight forward process that differs slightly based on the Droplet's operating system. In this guide, we'll walk you through the process of updating your kernels for DigitalOcean Droplets.
Have another answer? Share your knowledge.