Can KVM be used inside a GCE instance?

As of right now, the virtualized environment the GCE instances run on doesn't offer the virtualization extensions KVM requires to function. During installation it does indicate so, and running:

sudo /etc/init.d/qemu-kvm start

[FAIL] Your system does not have the CPU extensions required to use KVM. Not doing anything. ... failed!

PS - Even so, at least in theory, there's nothing preventing the execution of virtualized environments that do not depend on these extensions: Docker, QEMU (stand-alone), etc...


Yes, you can use nested virtualization in the GCE environment.

When you first asked this question, and when @sammy-villoldo first answered you could not.

But September 28, 2017 Google announced:

Google Compute Engine now supports nested virtualization in beta

It used to be that you needed to be careful as it is restricted to CPU architectures based on Haswell or newer, and those were not available everywhere. Scanning the list now it appears every GCE zone has Haswell or newer as the default so that's not a problem.

Their documentation contains all the details.

Even in CI environments layered on GCE now it is possible these days to do nested virtualization, Travis CI implements it for instance with their ubuntu bionic / language general (or bash) images. You can start a free github or gitlab account and connect a repo to Travis to play with it for zero cost if you like.

Here is an example config https://travis-ci.org/ankidroid/Anki-Android/builds/607187626/config