Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can KVM be used inside a GCE instance?

Is it possible to run a KVM virtual machine inside of a Google Compute Engine instance? Nested virtualization, in short?

like image 751
John Avatar asked Nov 03 '14 20:11

John


People also ask

Does GCP support KVM?

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.

Can you run KVM on a VM?

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.

Can you run KVM inside KVM?

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.


2 Answers

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...

like image 101
Sammy Villoldo Avatar answered Sep 21 '22 15:09

Sammy Villoldo


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

like image 25
Mike Hardy Avatar answered Sep 18 '22 15:09

Mike Hardy