[tutorial] Virtualization, qemu/kvm, android-x86-7.1-r5

1,842 views
Skip to first unread message

Episteme PROMENEUR

unread,
Mar 31, 2021, 12:00:21 PM3/31/21
to Android-x86
0. General explanation

After many trials with Virtualbox. I abandonnned it.

Because there is  no guest additions for Android OS.

You get problems with mouse, keyboard, GUI. Even with the best mature android-x86-14.1-r5.

Thus, I went to explore qemu/kvm another virtualization technology.

I choose android-x86-7.1-r5 after trials with android-x86-14.1-r5 and android-x86-9.0-r2.

They are not mature to use them as a PC OS. 
There are :
- key problem ("Esc" for example), 
- battery reporting problem (reporting "weak level" instead of "charging,100 %" for example). This leads to some app refusing to run), 
- no freeform feature which is necessary to manage several app windows and the size of them.

I made a tutorial with this environment :

- openSuse 15.2
- Kde 20.12.3
- qemu 4.2.1 to 5.2.0
- using "networkmanager" and not "wicked" to manage host networking
- using Yast virtualization manager to install all about qemu, kvm

You must translate if your environment is different.

2. Why I made this tutorial ?

I made this tutorial because :

- there is no tool as Virtualbox to manage so easily a qemu/kvm machine with non root privileges.
- there is no doc [*] (very poor doc about qemu also at qemu site) for non techie persons.
- the solutions i found are spread among internet and the time (2010-2020) and all comes from users who face to the same problems and supply a solution in various forums.


[*] I read official sites as Arch (the best for everything), Readhat, openSuse, Suse, Ubuntu, libvirt, qemu. All the docs are massively about using virt-manager and virsh. All these tools need root privileges. Some docs are old, others are recent.

When there is a doc about qemu it is very poor and techie and does not answer directly to the questions : 
- How to create a vm .
- How to start a vm at login and to stop cleanly a vm at logout or shutdown ?
- how to get a vm which is a member of the lan ? [1]
- how to share dynamically usb devices as microphone or web cam ?
- how to get input and ouput sound ?
- how to use pulseaudio to get a good sound ?

3. Where is this tutorial ?


Beware : from the beginning to the end the invocation of qemu is step by step syntax optimized. The best one is the last one, at the end of the tutorial.

Enjoy :)

Chih-Wei Huang

unread,
Apr 2, 2021, 12:14:53 PM4/2/21
to Android-x86
Episteme PROMENEUR <episteme....@gmail.com> 於 2021年4月1日 週四 上午12:00寫道:
>
> 0. General explanation
>
> After many trials with Virtualbox. I abandonnned it.
>
> Because there is no guest additions for Android OS.
>
> You get problems with mouse, keyboard, GUI. Even with the best mature android-x86-14.1-r5.
>
> Thus, I went to explore qemu/kvm another virtualization technology.
>
> I choose android-x86-7.1-r5 after trials with android-x86-14.1-r5 and android-x86-9.0-r2.
>
> They are not mature to use them as a PC OS.
> There are :
> - key problem ("Esc" for example),

What's the problem exactly?

> - battery reporting problem (reporting "weak level" instead of "charging,100 %" for example). This leads to some app refusing to run),

Not sure why you saw the issue.
The battery status of my qemu is always 100% charging, as show in dmesg:
x86_64:/ # dmesg | grep healthd
[78319.763709] healthd: battery l=100 v=0 t=42.4 h=2 st=2 chg=a

> - no freeform feature which is necessary to manage several app windows and the size of them.

What feature did you mean exactly?
Freeform support is available in Android 7.
With the built-in Taskbar as the launcher you should be able
to run all built-in apps in freeform mode.
Isn't this what you want?

> I made a tutorial with this environment :
>
> - openSuse 15.2
> - Kde 20.12.3
> - qemu 4.2.1 to 5.2.0
> - using "networkmanager" and not "wicked" to manage host networking
> - using Yast virtualization manager to install all about qemu, kvm
>
> You must translate if your environment is different.
>
> 2. Why I made this tutorial ?
>
> I made this tutorial because :
>
> - there is no tool as Virtualbox to manage so easily a qemu/kvm machine with non root privileges.
> - there is no doc [*] (very poor doc about qemu also at qemu site) for non techie persons.
> - the solutions i found are spread among internet and the time (2010-2020) and all comes from users who face to the same problems and supply a solution in various forums.
>
>
> [*] I read official sites as Arch (the best for everything), Readhat, openSuse, Suse, Ubuntu, libvirt, qemu. All the docs are massively about using virt-manager and virsh. All these tools need root privileges. Some docs are old, others are recent.
>
> When there is a doc about qemu it is very poor and techie and does not answer directly to the questions :
> - How to create a vm .
> - How to start a vm at login and to stop cleanly a vm at logout or shutdown ?
> - how to get a vm which is a member of the lan ? [1]
> - how to share dynamically usb devices as microphone or web cam ?
> - how to get input and ouput sound ?
> - how to use pulseaudio to get a good sound ?
>
> 3. Where is this tutorial ?
>
> https://forums.opensuse.org/showthread.php/551824-qemu-kvm-user-management-create-launch-create-a-bridge-use-a-bridge
>
> Beware : from the beginning to the end the invocation of qemu is step by step syntax optimized. The best one is the last one, at the end of the tutorial.

Thank you for the sharing.

At a glance, you're using -vga qxl as the vga card.
That means it's running in non hardware-accelerated mode.
If you're using a recent qemu with virglrenderer support,
you should be able to enable OpenGLES hardware acceleration
with the option: -vga virtio -display sdl,gl=on

BTW, the project has provided a script to run android-x86 in qemu.
You can refer to it :

https://git.osdn.net/view?p=android-x86/bootable-newinstaller.git;a=blob_plain;f=rpm/qemu-android;hb=0da684c43a7d9df9cea1c3c76dd76baf9f641fa0

If you install android-x86 by rpm(deb), it's installed to
/usr/bin/qemu-android


--
Chih-Wei
Android-x86 project
http://www.android-x86.org

Episteme PROMENEUR

unread,
Apr 2, 2021, 12:46:19 PM4/2/21
to Android-x86
android-x86-8.1-r5, android-x86-9.0-r2

type "esc" instead of clicking the "back arrow" of a window then no action. 

Episteme PROMENEUR

unread,
Apr 2, 2021, 12:55:13 PM4/2/21
to Android-x86
android-x86-8.1-r5, android-x86-9.0-r2

no freeform. when you try to enable freeform you get a message saying that freeform does not run well with this version of android.

In fact :
- no contextual menu in the grid of taskbar. you must maintain a click to get it
- if you select "large" to get a large window you don't get a large window

In the doc of task bar it is said that in 8 and 9 versions of android google abandoned freeform. freeform is re-enabled with android 10.

Chih-Wei Huang

unread,
Apr 2, 2021, 1:11:21 PM4/2/21
to Android-x86
Episteme PROMENEUR <episteme....@gmail.com> 於 2021年4月3日 週六 上午12:46寫道:
>
> android-x86-8.1-r5, android-x86-9.0-r2
>
> type "esc" instead of clicking the "back arrow" of a window then no action.

Oh, I thought you talked about 7.1-r5...

ESC still works as BACK in 8.1, but not work in 9.0.
I think that's changed by AOSP.

Episteme PROMENEUR

unread,
Apr 2, 2021, 1:13:33 PM4/2/21
to Android-x86
android-x86-9.0-r2

you get a battery icon with a red "!". this is interpreted by whatsapp as a weak battery.

Episteme PROMENEUR

unread,
Apr 2, 2021, 1:30:07 PM4/2/21
to Android-x86
"-vga virtio -display sdl,gl=on"

i first used this option then i get a black screen when android start after the grub menu.

So i choose "-vga qxl" if you know a way to get graphical acceleration which works. I will be glad to use it.
i must say that i get no problem with the few apps i use with android. whatsapp, skype, "SNCF", OUI.sncf.

With openSuse 15.2, kde plasma 5.21.3, kde frameworks 5.80.0, qt 5.15.2 i get opengl 3.0 with Mesa 19.3.4
but in kde environment i get only opengl 2.0. 3.0 is not stable.

Episteme PROMENEUR

unread,
Apr 2, 2021, 1:31:43 PM4/2/21
to Android-x86
I will try using rpm

Episteme PROMENEUR

unread,
Apr 2, 2021, 1:33:11 PM4/2/21
to Android-x86
I have just tried 8.1-r5. Esc does not work.

Episteme PROMENEUR

unread,
Apr 2, 2021, 2:33:03 PM4/2/21
to Android-x86
Some notes about qemu.android.

1.

"-usb -device usb-tablet,bus=usb-bus.0 "

is deprecated and will be removed

the recent syntax is

-device usb-ehci \
-device usb-mouse \
-device usb-kbd \
-device usb-tablet \

You must use "-device usb-tablet"" to get a seamless capture of the mouse by the host and the guest.

2.

"-soundhw ac97"

is deprecated and will be removed

the recent syntax is

-device ich9-intel-hda \
-device hda-duplex,audiodev=snd0 \    <<<<<  this is my choice there are several choices
-audiodev pa,id=snd0 \                            <<<<<  the virtual sound card "snd0" uses the pulseaudio server of the host

"-device hda-duplex,audiodev=snd0"     this defines a sound card "snd0" with intel hda codecs and which uses the host  line in where a jack micro is plugged and the host line out where host speakers are plugged. Micro and speakers are dynamically shared between host and guest.

I did not find any generic syntax to define a sound card using intel hda codecs with recent syntax.

3. 

"-net user,"

with this the vm gets an ip address like 10.0.0.5 because using the dhcp of the vm net.
you can't establish any connection between host and guest.

the better way is to use a host bridge. this way the vm gets an ip address of your lan and is a member of your lan.

i advise the following generic syntax

"-nic bridge" <<<<< this means the vm uses the first host bridge it finds.

Chih-Wei Huang

unread,
Apr 3, 2021, 2:23:32 PM4/3/21
to Android-x86
Episteme PROMENEUR <episteme....@gmail.com> 於 2021年4月3日 週六 上午2:33寫道:
>
> Some notes about qemu.android.
>
> 1.
>
> "-usb -device usb-tablet,bus=usb-bus.0 "
>
> is deprecated and will be removed

You probably misread it. It's the new syntax.

> the recent syntax is
>
> -device usb-ehci \
> -device usb-mouse \
> -device usb-kbd \
> -device usb-tablet \
>
> You must use "-device usb-tablet"" to get a seamless capture of the mouse by the host and the guest.
>
> 2.
>
> "-soundhw ac97"
>
> is deprecated and will be removed

Hmm? I didn't see any word that this is deprecated, at least
in man page of my qemu 4.2.1.

Checking the latest qemu doc, it's said
-soundhw is deprecated since 5.1. OK...

> the recent syntax is
>
> -device ich9-intel-hda \
> -device hda-duplex,audiodev=snd0 \ <<<<< this is my choice there are several choices
> -audiodev pa,id=snd0 \ <<<<< the virtual sound card "snd0" uses the pulseaudio server of the host
>
> "-device hda-duplex,audiodev=snd0" this defines a sound card "snd0" with intel hda codecs and which uses the host line in where a jack micro is plugged and the host line out where host speakers are plugged. Micro and speakers are dynamically shared between host and guest.

Are these options generic enough?
I meant, they shouldn't depend on qemu version
and sound cards configurations of the host.
If yes, I can consider to use these in the future.
Note the script could be run in very different distributions or
environments so it should be generic as possible.

> I did not find any generic syntax to define a sound card using intel hda codecs with recent syntax.
>
> 3.
>
> "-net user,"
>
> with this the vm gets an ip address like 10.0.0.5 because using the dhcp of the vm net.
> you can't establish any connection between host and guest.
>
> the better way is to use a host bridge. this way the vm gets an ip address of your lan and is a member of your lan.
>
> i advise the following generic syntax
>
> "-nic bridge" <<<<< this means the vm uses the first host bridge it finds.

Using bridge mode is much more complex than using -net user.
Configuring bridge mode is far beyond the mission of our rpm.
The script should just work -- people don't need to do step 1,2,3,... to use it.
So there is no plan to use the bridge mode by default.
People who need bridge mode could configure that themselves.

Actually there is no problem to make connection from the guest to host
in the net user mode. You just can't make connection from host to the guest
directly. If you need that, probably using hostfwd= is simpler.

> Le vendredi 2 avril 2021 à 19:33:11 UTC+2, Episteme PROMENEUR a écrit :
>> I have just tried 8.1-r5. Esc does not work.
>> Le vendredi 2 avril 2021 à 19:11:21 UTC+2, Chih-Wei Huang a écrit :
>>> Episteme PROMENEUR <episteme....@gmail.com> 於 2021年4月3日 週六 上午12:46寫道:
>>> >
>>> > android-x86-8.1-r5, android-x86-9.0-r2
>>> >
>>> > type "esc" instead of clicking the "back arrow" of a window then no action.
>>>
>>> Oh, I thought you talked about 7.1-r5...
>>>
>>> ESC still works as BACK in 8.1, but not work in 9.0.
>>> I think that's changed by AOSP.
>>>
>>> > Le vendredi 2 avril 2021 à 18:14:53 UTC+2, Chih-Wei Huang a écrit :
>>> >> Episteme PROMENEUR <episteme....@gmail.com> 於 2021年4月1日 週四 上午12:00寫道:
>>> >> >
>>> >> > 0. General explanation
>>> >> >
>>> >> > After many trials with Virtualbox. I abandonnned it.
>>> >> >
>>> >> > Because there is no guest additions for Android OS.
>>> >> >
>>> >> > You get problems with mouse, keyboard, GUI. Even with the best mature android-x86-14.1-r5.
>>> >> >
>>> >> > Thus, I went to explore qemu/kvm another virtualization technology.
>>> >> >
>>> >> > I choose android-x86-7.1-r5 after trials with android-x86-14.1-r5 and android-x86-9.0-r2.
>>> >> >
>>> >> > They are not mature to use them as a PC OS.
>>> >> > There are :
>>> >> > - key problem ("Esc" for example),
>>> >>
>>> >> What's the problem exactly?


Ottavio Caruso

unread,
Apr 3, 2021, 2:57:22 PM4/3/21
to andro...@googlegroups.com
On Sat, 3 Apr 2021 at 19:24, Chih-Wei Huang <cwh...@android-x86.org> wrote:
>
> Episteme PROMENEUR <episteme....@gmail.com> 於 2021年4月3日 週六 上午2:33寫道:
> >
> > the better way is to use a host bridge. this way the vm gets an ip address of your lan and is a member of your lan.
> >
> > i advise the following generic syntax
> >
> > "-nic bridge" <<<<< this means the vm uses the first host bridge it finds.
>
> Using bridge mode is much more complex than using -net user.
> Configuring bridge mode is far beyond the mission of our rpm.
> The script should just work -- people don't need to do step 1,2,3,... to use it.
> So there is no plan to use the bridge mode by default.
> People who need bridge mode could configure that themselves.
>
> Actually there is no problem to make connection from the guest to host
> in the net user mode. You just can't make connection from host to the guest
> directly. If you need that, probably using hostfwd= is simpler.

I agree. Please leave it as -netdev user. Some users cannot
access/activate a bridge because they don't have root permissions.

By the way, what is the port 5555 passthrough for?

--
Ottavio Caruso

Chih-Wei Huang

unread,
Apr 3, 2021, 8:44:14 PM4/3/21
to Android-x86
'Ottavio Caruso' via Android-x86 <andro...@googlegroups.com> 於
2021年4月4日 週日 上午2:57寫道:
For adb -- connect to port 5555 of the host will be forwarded
to port 5555 of the guest. Try:

$ adb kill-server
$ adb devices
List of devices attached
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
emulator-5554 device
Reply all
Reply to author
Forward
0 new messages