-
-
Notifications
You must be signed in to change notification settings - Fork 17
aarch64
You need to quickly test an aarch64 binary (or even one for another platform) and don’t want to spend a lot of resources deploying a virtual machine for it. You can use a jail along with qemu-user-static to create the environment with the former and emulate the binary with the latter in just a few steps.
Install qemu-user-static
pkg install -y qemu-user-staticEnable qemu_user_static service
This will run binmiscctl(8) to configure image activators for numerous platforms, allowing you to even emulate architectures other than aarch64.
service qemu_user_static enable
service qemu_user_static startCreating the release directory
It's time to create the release directory that our jail will use. It's no different from creating one for the host platform; you just need to specify a valid architecture.
appjail fetch pkgbase -a aarch64Install qemu-<arch>-static in the release directory
Binaries will call this program when they run, so it must be installed inside the jail directory.
mkdir -p /usr/local/appjail/releases/aarch64/15/default/release/usr/local/bin
cp -a /usr/local/bin/qemu-aarch64-static /usr/local/appjail/releases/aarch64/15/default/release/usr/local/bin
Create the aarch64 jail
appjail quick jaarch64 \
start \
overwrite=force \
alias \
virtualnet=":appjail0 default" \
nat \
ephemeral \
osarch=aarch64 \
type=thickIn this case, we are not using any of AppJail’s advanced networking features, since, at the time of writing, it is not possible to call ifconfig(8) from within the jail using the qemu-user-static approach. And the osarch=aarch64 and type=thick parameters are the most important, since the first specifies the architecture we want to use instead of the default specified by appjail.conf(5), and the second is used to copy the entire release directory, not just certain files (since, by default, a thinjail will be created, ignoring /usr/local/bin/qemu-<arch>-static).
$ appjail cmd jexec jaarch64 ifconfig
Unsupported setsockopt level=270 optname=11
ifconfig: unable to open netlink socket: Function not implemented
$ appjail pkg jail jaarch64 install sl
...
$ appjail cmd jexec jaarch64 sl
( ) (@@) ( ) (@) () @@ O @ O @ O
(@@@)
( )
(@@@@)
( )
==== ________ ___________
_D _| |_______/ \__I_I_____===__|_________|
|(_)--- | H\________/ | | =|___ ___| _________________
/ | | H | | | | ||_| |_|| _| \_____A
| | | H |__--------------------| [___] | =| |
| ________|___H__/__|_____/[][]~\_______| | -| |
|/ | |-----------I_____I [][] [] D |=======|____|________________________|_
__/ =| o |=-~~\ /~~\ /~~\ /~~\ ____Y___________|__|__________________________|_
|/-=|___|= || || || |_____/~\___/ |_D__D__D_| |_D__D__D_|
\_/ \O=====O=====O=====O_/ \_/ \_/ \_/ \_/ \_/