Building packages through emulation by Sean Bruno

16
QEMU Assisted Jails for Ports and Packages Sean Bruno, [email protected]

Transcript of Building packages through emulation by Sean Bruno

Page 1: Building packages through emulation by Sean Bruno

QEMU Assisted Jails for Ports and

PackagesSean Bruno, [email protected]

Page 2: Building packages through emulation by Sean Bruno

Overview and Presentation Goals

● Kernel Components (11-Current)○ Image Activators

● Userland Components (11-Current)○ binmiscctl(8)○ qemu-static-user○ poudriere-devel

● Nullfs and Chroot○ Treat the environments as normal jails.

Page 3: Building packages through emulation by Sean Bruno

Contributors and Generally Awesome People

Stacey Son - binmiscctl(8) and imgact_binmisc(4) authorJuergen Lock - QEMU maintainer for BSD, many, many patchesEd Maste - QEMU patches and cat herderPeter Wemm - Sigtramp patch, because wow.Alexander Kabaev - QEMU patchesAdrian Chadd - Ignored my pleading for help with kern_imgact.cBaptiste Daroussin - Inflicting me with a ports commit bit

Page 4: Building packages through emulation by Sean Bruno

Contributors and Generally Awesome People

Dimitry Andric - CLANG Help and UpdatesAndrew Turner - GCC and Ports PatchesMikael Urankar - Mysql PatchesBryan Drewery - Taking me on a journey through poudriereWarner Losh - Created the native-xtools target (doubled speed)Ian Lapore - ARMv6 Assembly HelpBrooks Davis - Inspiration and initial guidance

Page 5: Building packages through emulation by Sean Bruno

Kernel Components (11-Current)

imgact_binmisc.ko● Kernel Hook to redirect execution● Examines ELF Header● If match on preconfigured setting, modifes

ARGV[0] with emulator helper

Page 6: Building packages through emulation by Sean Bruno

Kernel Components - Continued

binmiscctl(8) will load and configure settings, e.g.binmiscctl add armv6 --interpreter "/usr/local/bin/qemu-arm" --magic "\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00"--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"--size 20 --set-enabledbinmiscctl add mips --interpreter "/usr/local/bin/qemu-mips" --magic "\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08" --mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff" --size 20 --set-enabled

Page 7: Building packages through emulation by Sean Bruno

Kernel Components - Continued

binmisctl listname: mipsinterpreter: /usr/local/bin/qemu-mipsflags: ENABLED USE_MASKmagic size: 20magic offset: 0magic: 0x7f 0x45 0x4c 0x46 0x01 0x02 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x02 0x00 0x08mask: 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xfe 0xff 0xff

Page 8: Building packages through emulation by Sean Bruno

Userland Components (11-Current)

QEMU● Use emulators/qemu-static-user● Installs statically linked binaries● Emulation is a journey not a destination● IOCTL emulation is still in progress

Page 9: Building packages through emulation by Sean Bruno

Userland Components - Continued

Poudriere-devel● Easiest way to get started building jails● Knows how to to understand binmiscctl(8)● Knows to copy QEMU into jails● Creates clean backup, in case of accident● Use ZFS, save yourself some pain

Page 10: Building packages through emulation by Sean Bruno

Build the jail -- poudriere-devel

● poudriere jail -c -j 11armv632 -m svn -v head -a arm.armv6 -x

● poudriere jail -c -j 11mips32 -m svn -v head -a mips.mips -x

● poudirere jail -c -j 11mips64 -m svn -v head -a mips.mips64 -x

● poudriere ports -c -m svn (so you have something to build)

Page 11: Building packages through emulation by Sean Bruno

Configure the jail and mount

poudriere will create:zroot/poudriere/jails/11armv632 112176079 1096098 111079980 1%/usr/local/poudriere/jails/11armv632

zroot/poudriere/ports/default 118616467 7536487 111079980 6% /usr/local/poudriere/ports/default

Manually mount devfs/ports:mount -t devfs devfs <path to jail/devmount -t nullfs /usr/local/poudriere/ports/default <path to jail>/usr/ports

Page 12: Building packages through emulation by Sean Bruno

Chroot and [email protected]:/home/sbruno/fbsd_head # uname -aFreeBSD dirty.ysv.freebsd.org 11.0-CURRENT FreeBSD 11.0-CURRENT #0 r271414: Thu Sep 11 02:48:22 UTC 2014 [email protected]:/usr/obj/usr/src/sys/DIRTY amd64

[email protected]:~ # chroot /usr/local/poudriere/jails/11armv632

root@dirty:/ # uname -aFreeBSD dirty.ysv.freebsd.org 11.0-CURRENT FreeBSD 11.0-CURRENT #0 r271414: Thu Sep 11 02:48:22 UTC 2014 [email protected]:/usr/obj/usr/src/sys/DIRTY arm

Page 13: Building packages through emulation by Sean Bruno

Poudriere Demo

● poudriere bulk -a -j 11armv632● nginx rendering of status● sharp edges remain, signal handling

Page 14: Building packages through emulation by Sean Bruno

Building and testing - DEMO

● chroot and build, its magic● needs better documentation● man page updates● binmiscctl(8) syntax is precise and you will

always copy/paste it from somewhere

Page 15: Building packages through emulation by Sean Bruno

Future Development

● CLANG for MIPS will make more ports build● AARCH64 (ARM64) support will start soon,

or send me patches for QEMU now.● IOCTL debug handling, human readable

format

Page 16: Building packages through emulation by Sean Bruno

Questions?

There’s plenty of things that I’ve probably skipped, what do you want to do with this feature?