一昔前はビッグエンディアン・マシンが秋葉原にたくさん転がってた。Apple PowerPC Mac、Sun Blade、SGI O2 等々。でも今どきは、IntelとARMばっかり。ビットフィールドのオーダーを確認したいとか、ビット演算が正しく動作するかとか、ただただ機械語を眺めたいとか、そういうときに手頃なビッグエンディアンの環境が欲しい。
よろしい、ならばエミュレーションだ。
- 準備
- ホストの環境
- パッケージを更新
- QEMU、tunctl、brctlをインストール
- ネットワーク設定
- VMイメージ
Arch: AMD64
OS: Debian 8.0 Jessie
Emulator: QEMU emulator version 2.1.2
更新しない方がよい心当たりがなければ、しておくこと。
# apt-get update # apt-get upgrade
QEMUとネットワーク関連パッケージをインストールする。ネットワーク機能が不要なら、tunclt、brctl は不要。「4. ネットワーク設定」も不要。
# apt-get install uml-utilities bridge-utils qemu
エミュレータが使う仮想ブリッジを設定する。ブリッジの設定は debian.org: Bridging Network Connections が詳しかった。例えばこんな感じ。
# vi /etc/network/interfaces ~~~~~~~~~~~~~~~~ # The loopback network interface auto lo iface lo inet loopback # Set up interfaces manually, avoiding conflicts with, e.g., network manager iface eth0 inet manual # Bridge setup auto br0 iface br0 inet dhcp bridge_ports eth0 bridge_stp off bridge_maxwait 0 bridge_fd 0
QEMUに使用を許可するブリッジインタフェースの設定を書いておく。
# vi /etc/qemu/bridge.conf ~~~~~~~~~~~~~~~~ allow br0
設定ファイルに適切なパーミッションを付与する。誰でも書込みできてはいけない。
# chmod 0644 /etc/qemu/bridge.conf
qemu-bridge-helperのsetuidビットを立てておく。
# chmod u+s /usr/lib/qemu/qemu-bridge-helper
qemu-bridge-helperは setuid root で起動したら、直ちにcap_net_adminに降格するらしい。詳しくは qemu.org: HelperNetworking を参照のこと。
DebianのサーバにいろいろなアーキテクチャのVMイメージがある。今回はこのなかから、PowerPCとSPARCとMIPS64のVM起動方法を紹介する。Merci, Aurélien.
- PowerPC
Debian Wheezy ディスクイメージをダウンロード。
$ wget https://people.debian.org/~aurel32/qemu/powerpc/debian_wheezy_powerpc_standard.qcow2
VMを起動。
$ qemu-system-ppc -hda debian_wheezy_powerpc_standard.qcow2 -nographic
VMをブリッジに繋いで起動。
$ qemu-system-ppc -hda debian_wheezy_powerpc_standard.qcow2 -nographic -net nic -net bridge,br=br0
詳細: https://people.debian.org/~aurel32/qemu/powerpc/README.txt
- SPARC
Debian Etch ディスクイメージをダウンロード。
$ wget https://people.debian.org/~aurel32/qemu/sparc/debian_etch_sparc_small.qcow2
VMを起動。
$ qemu-system-sparc -hda debian_etch_sparc_small.qcow2 -nographic
VMをブリッジに繋いで起動。
$ qemu-system-sparc -hda debian_etch_sparc_small.qcow2 -nographic -net nic -net bridge,br=br0
詳細: https://people.debian.org/~aurel32/qemu/sparc/README.txt
- MIPS64
MIPS64用のカーネルイメージと、Debian Wheezy ディスクイメージをダウンロード。
$ wget https://people.debian.org/~aurel32/qemu/mips/vmlinux-3.2.0-4-5kc-malta $ wget https://people.debian.org/~aurel32/qemu/mips/debian_wheezy_mips_standard.qcow2
VMを起動。
$ qemu-system-mips64 -M malta -kernel vmlinux-3.2.0-4-5kc-malta -hda debian_wheezy_mips_standard.qcow2 -append "root=/dev/sda1 console=ttyS0" -nographic
VMをブリッジに繋いで起動。
$ qemu-system-mips64 -M malta -kernel vmlinux-3.2.0-4-5kc-malta -hda debian_wheezy_mips_standard.qcow2 -append "root=/dev/sda1 console=ttyS0" -nographic -net nic -net bridge,br=br0