[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Running qemu-aarch64 emulator inside Termux
From: |
Eboubaker |
Subject: |
Re: Running qemu-aarch64 emulator inside Termux |
Date: |
Tue, 4 Jun 2024 12:26:14 +0100 |
Hi Peter, Sorry for my ignorance in advance. I am new to qemu. You
were absolutely right, I was using the wrong binary to run aarch64.
Now I used qemu-system-aarch64 and cortex-a45 cpu(that's one of my
phone's architectures i saw with cpu-z utility), the image did run
fine. But I was disappointed to see there is no difference in I/O
performance as you have stated.
This is the command I did:
```shell
pkg install qemu-system-aarch64
qemu-img create -f raw alpine-arch64.img 2G
wget
https://dl-cdn.alpinelinux.org/alpine/v3.20/releases/aarch64/alpine-virt-3.20.0-aarch64.iso
qemu-system-aarch64 -cpu cortex-a55 \
-machine virt \
-m 1024 \
-smp cpus=2 \
-drive
if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-aarch64-code.fd
\
-netdev user,id=n1,dns=8.8.8.8,hostfwd=tcp::2222-:22 \
-device virtio-net,netdev=n1 \
-cdrom alpine-virt-3.20.0-aarch64.iso -nographic alpine-arch64.img
```
Now here's some background why I am doing this: I have restaurant
clients where they have tablets installed as the kiosk menu. I wanted
my application backend to run in the same machine as the app frontend
(interface for ordering meals). Now I want to be able to run docker on
the tablet so I installed termux https://termux.dev/en (the one in
google play is deprecated). Then I installed qemu to run docker on the
tablet without root or kvm(these kernel modules are not available in
consumer tablets).
Then I tried to build the docker image in qemu but it was taking a lot
of time (I waited like 5 hours) and when it was finally running the
server response time was very high(700ms).
I did some benchmarking. It seems that disk I/O inside Termux directly
is 100Mb/s but when I tested it inside qemu I got like 4Mb/s which I
think is definitely why I experienced The slow building time and the
long response time. Here Is the full Issue that led me to write to
this mailing list:
https://github.com/cyberkernelofficial/docker-in-termux/issues/13
somone said that I should use aarch64 instead of x86_64 so that it
matches the smart phone architecture.
Now I am kind of stuck here, What can I do to increase the I/O
performance? because a drop from 100Mb/s to 4Mb/s is a lot(25 times
reduction). I have tried different disk caching options I saw on the
manpage without success too.
On Mon, Jun 3, 2024 at 4:46 PM Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Mon, 3 Jun 2024 at 16:41, Eboubaker <gpscrambor.4862500@gmail.com> wrote:
> > Then I noticed I can get better performance by using aarch64 instead of
> > x86_64 since my phone is using arm64 CPU This is what i tried:
> > ```shell
> >
> > pkg install qemu-system-arm
> > qemu-img create -f raw alpine-arch64.img 2G
> > wget
> > https://dl-cdn.alpinelinux.org/alpine/v3.20/releases/aarch64/alpine-virt-3.20.0-aarch64.iso
> > qemu-system-arm \
>
> qemu-system-arm is for 32-bit CPUs...
>
> > -machine virt \
> > -m 1024 \
> > -smp cpus=2 \
> > -drive
> > if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-aarch64-code.fd
> > \
>
> ...but this is a 64-bit BIOS image. It will never boot on this
> QEMU command line.
>
> You need to use qemu-system-aarch64 and specify a -cpu option
> that is a 64-bit CPU.
>
> If you want to actually get the speed improvement from the
> fact you're running a 64-bit guest on a 64-bit host then you
> will also need to tell QEMU to use the KVM accelerator,
> with eg '-enable-kvm'. Your phone's kernel will also
> need to support KVM, of course. I don't know how likely that
> is but I would not be too optimistic.
>
> For pure emulation, there is no particular advantage to having
> the host and target CPU architetures the same.
>
> thanks
> -- PMM