Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
qemu-debootstrap
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
NOKUBI Takatsugu
October 08, 2016
93
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
qemu-debootstrap
第12回 カーネル/VM探検隊での発表資料
NOKUBI Takatsugu
October 08, 2016
More Decks by NOKUBI Takatsugu
See All by NOKUBI Takatsugu
10年ぶりの ニューラルネットワーク
knok
0
120
テキスト生成とGPT-2
knok
0
88
論文「時系列数値データにおける変化要因の記述」の再現
knok
0
100
LanguageToolを触ってみる
knok
0
19
自由ソフトウェアによるライブストリーミング
knok
0
41
自由なデータ
knok
0
37
Featured
See All Featured
Tell your own story through comics
letsgokoyo
1
1.1k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
780
ラッコキーワード サービス紹介資料
rakko
1
5.3M
Chasing Engaging Ingredients in Design
codingconduct
0
360
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
990
We Are The Robots
honzajavorek
0
400
Fantastic passwords and where to find them - at NoRuKo
philnash
53
4k
How to Think Like a Performance Engineer
csswizardry
28
2.9k
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
Automating Front-end Workflow
addyosmani
1369
210k
My Coaching Mixtape
mlcsv
0
360
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
620
Transcript
2016/10/8 第12回kernel/vm探検隊
[email protected]
/ @knok https://goo.gl/38GEqR qemu-debootstrap
qemu-debootstrapで 始める異世界生活 2016/10/8 第12回kernel/vm探検隊
[email protected]
/ @knok
Debianでよく困ること 多数のアーキテクチャに対応 amd64/i386/armel/armhf/arm64/mips/mipsel/powerpc/ppc64el/s390x kFreeBSD-amd64/i386/Hurd-i386 特定アーキテクチャ限定のバグ報告 FTBFS Fail to Build from
Source 所持していないアーキテクチャ対応をどうするか arm … ok mips … ? sparc … ? ia64 ?????
物理 or 仮想 porterbox https://db.debian.org/machines.cgi 開発者向けに提供される物理マシン 条件が揃えばDebian開発者以外の人でも使える http://www.clear-code.com/blog/2016/2/24.html qemu 誰でも使えるOSSな仮想マシン
debootstrap Debian/Ubuntu最小環境を構築するコマンド Debianにおいてほとんどのファイルはパッケージ管理下またはパッケージが生成 大昔はbase.tgzというファイルが必要だった 必要なパッケージをリポジトリから取得、展開 (first stage) アーキテクチャにかかわらず実行できる部分 設定スクリプトの起動 (second
stage) {pre|post}instスクリプトを実行 対象アーキテクチャのインタプリタバイナリが解釈 invoke-policy.dを一時的に無効にする
qemu-user-static qemu user modeのパッケージ 同じOSの異なるCPUエミュレーションを提供 ライブラリはすべてstatic linkされている このファイルだけで他のCPUのバイナリを実行できる dynamic link
binaryは然るべき場所にshared libraryが必要 http://www.irasutoya.com/2015/01/blog-post_517.html
binfmt_misc Linux kernelの機能 拡張子あるいはバイナリのシグネチャを元に、指定したコマンドを呼び出す ユーザーからはデータなどが透過的に実行可能に見える 近代のfileコマンドのmagic(5)ほど複雑なシグネチャは扱えない 2.1.43以降の機能 Documentation/binfmt_misc.txt 利用例 Wine,
Mono
qemu-debootstrap qemu-user-staticを利用するdebootstrapのラッパー ファイルの取得、展開までは通常と同じ qemu-$(arch)-staticをusr/binにコピー これを経由してsecond stageを処理 /bin/sh等がqemu経由で実行される {pre|post}instスクリプト等を処理 qemu-user-staticパッケージに同梱 出来上がった環境も普通にchrootできる
execve(2)実行 /sbin /bin /bin/sh /usr/bin /usr/bin/qemu-armhf-static /usr/sbin /proc /dev :
armhf chroot環境 ./root/ # chroot ./chroot /bin/sh chroot(2)実行 /usr/bin/qemu-armhf-static 経由で/bin/sh 実行 実行バイナリハンドラー探索 search_binary_handler chroot内で、その外部のshared library → は参照できない static link
注意点 十分にこなれていない arm - そこそこ動く (たまにunsupported syscall) mips - そこそこ動くがバグも結構ある
(libcでの名前解決ができない) powerpc - instruction error がそこそこ発生 - buildが完遂しない OS層のエミュレーションはしない qemuのシステムエミュレーションを使いましょう Hurd kFreeBSD
パフォーマンス chasenのビルド時間を計測 emulator qemu-user qemu-user qemu-system arch armv7l armv7l armv7l(vexpress)
storage chroot qcow2+chroot qcow2 real 9:45.553 9:39.006 15:30.793 user 9:32.860 9:23.464 12:27.250 sys 0:11.612 0:12.100 2:08.660
パフォーマンスグラフ
*BSD support (FreeBSD) pkg install qemu-user-static get FreeBSD-10.3-RELEASE-arm-armv6-RPI-B.img.xz xz -d
mount mdconfig -a -t vnode -f FreeBSD-10.3-RELEASE-arm-armv6-RPI-B.img -u 0 mount /dev/md0s2a /mnt execute qemu-arm-static /mnt/rescue/ls
FreeBSDでchroot binmiscctl add armelf --interpreter "/usr/local/bin/qemu-arm-static" \ --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-enabled mkdir /mnt/usr/local/bin cp /usr/local/bin/qemu-arm-static /mnt/usr/local/bin/ chroot /mnt /bin/sh uname -a FreeBSD freebsd 10.3-RELEASE FreeBSD 10.3-RELEASE #0 r297264: Fri Mar 25 02:10:02 UTC 2016
[email protected]
:/usr/obj/usr/src/sys/GENERIC arm
*BSD support (NetBSD/OpenBSD) … 対応しているはずだが動かない segfault pkgsrc (2.6) 2.7 util/log.c
NULLに対してstrstrを行っているのが原因 アドホックな処置をしても何も表示せずに終了 OpenBSDは未確認
LXCと組み合わせる LXC 1.0: Some more advanced container usage [4/10] |
Stéphane Graber's website - https://www.stgraber.org/2013/12/23/lxc-1-0-some-m ore-advanced-container-usage/ dockerで動かしている人もいる模様
さらなる異世界へ RPM系distroで使えるツール rinse http://collab-maint.alioth.debian.org/rinse/ rpmstrap https://github.com/blipvert/rpmstrap 数年更新なし *BSDのlinux emulationでchroot FreeBSD
10-REL + linux.ko + Debian lennyで動作確認
参考 Debian Chroot - Crypto++ Wiki - https://cryptopp.com/wiki/Debian_Chroot ArmHardFloatChroot -
Debian Wiki - https://wiki.debian.org/ArmHardFloatChroot QemuUserModeHowTo - FreeBSD Wiki - https://wiki.freebsd.org/QemuUserModeHowTo かわいいフリー素材集 いらすとや - http://www.irasutoya.com/