Rafaelo
Rafaelo

Reputation: 153

Why nested virtualization for the Android emulator is very very slow?

Nested KVM virtualization should have a small overhead, but an Android emulator inside a VM should be usable.

When I launch the Android emulator inside ubuntu 20.04 guest (on ubuntu 20.04 host), it warns me that I'm on a nested virtualization and thus it will be slow. But it's painfully low, not just slow. It takes 10 minutes to boot into Android and yes, all the systems are x86_64, even the android image.

I thought this had to do with OpenGL so I enabled OpenGL virtualization on my virt-manager and things are still slow.

I tried the same thing on my Ryzen 7 2700x which has 16 cores, I gave all cores to the VM and passed an AMD gpu to it, and Android emulator is also painfully slow.

Why?

Upvotes: 7

Views: 2472

Answers (3)

Poperton
Poperton

Reputation: 2148

The problem is with QXL. Somehow it's slow on the new Ubuntu. Use VirtIO video and possibly 3D acceleration

Upvotes: 2

Martin Zeitler
Martin Zeitler

Reputation: 76679

For KVM one likely first has to enable nested virtualization; preferably with a x86 image:
https://docs.fedoraproject.org/en-US/quick-docs/using-nested-virtualization-in-kvm/
And even then, it's probably more effective to run a QEMU and connect through IP.

Upvotes: 3

Krischna Gabriel
Krischna Gabriel

Reputation: 146

You can try anbox instead of a VM. Performance overhead is much lower as anbox is less like a VM & works more like wine. To explain it with their own words:

The emulator(like a VM) creates an entire emulated system which has its own kernel etc whereas Anbox runs the Android system under the same kernel as the host operating system does. No emulation layer like QEMU is necessary. Everything runs directly on the hardware. This approach also allows a much better integration with the host operating system.

anbox.io

I gotta warn you tho, it's a bit chunky and software support is not the greatest. Had to manually install Kernel Modules from a github issue report as they didn't fix the focal ppa repository. Also some software runs barely or not at all so jeeaah...

Upvotes: 1

Related Questions