Can KVM be used inside a GCE instance?
Asked Answered
C

2

7

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

Clinic answered 3/11, 2014 at 20:27 Comment(0)
K
2

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

Kiki answered 29/10, 2019 at 12:24 Comment(0)
H
7

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

Humic answered 4/11, 2014 at 11:20 Comment(2)
I didn't get the FAIL message; I got [ ok ] Starting qemu-kvm (via systemctl): qemu-kvm.service. Does that mean KVM support has been added?Levins
Considering the rate the platform has been developing since its inception, it wouldn't surprise me. As long as you have a positive KVM support output, it's as you read it. :-) Consider the answer's date: a lot has happened since then.Humic
K
2

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

Kiki answered 29/10, 2019 at 12:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.