Is it possible to run a KVM virtual machine inside of a Google Compute Engine instance? Nested virtualization, in short?
Google Compute Engine uses KVM as the hypervisor, and supports guest images running Linux and Microsoft Windows which are used to launch virtual machines based on the 64 bit x86 architecture.
Every VM runs as a separate Linux process under systemd, with dedicated virtual hardware resources attached. KVM can only be used on a processor with hardware virtualisation extensions, such as Intel-VT or AMD-V.
Enabling nested virtualization in KVMNested virtualization allows you to run a virtual machine (VM) inside another VM while still using hardware acceleration from the host.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With