ソースからxen-toolsを入れてxen-create-imageを使ってDomUを入れた覚書
xen-create-imageを使ってDomUを作るのが楽らしい、とのことでxen-toolsをソースから入れたい。
ここを読む。http://xen-tools.org/software/xen-tools/
The scripts require:
The rpmstrap tool if you wish to install RPM based distributions
The debootstrap tool if you wish to install Debian-based distributions
Perl.
The Text::Template Perl module
The Config::IniFiles Perl module.
GNU Bash
と書いてある。Perl moduleの追加方法がわからないので調べる。これに関しては正しい方法なのかよくわからない。
perl -e'use CPAN; install "Text::Template"'
sudo perl -e'use CPAN; install "Config::IniFiles"'
apt-get install deboootstrap
perlは最新版がすでに入ってるとのことだった。
cd xen-tools
make install
さて、これで入ったか確認するために適当なオプションでxen-create-imageを行う。オプションは /etc/xen-tools/xen-tools.conf でも設定できるようだが、まずは動くことを確認したいので一度放置。
root@munou:/home/munou/xen-tools# xen-create-image --hostname=VM1 \--memory=128mb \--vcpus=2 \--dir=/home/xenimage \--dhcp \--pygrub \--mirror=http://cdn.debian.net/debian \--dist=wheezy \ --arch=amd64
Can't locate File/Slurp.pm in @INC (you may need to install the File::Slurp module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.20.2 /usr/local/share/perl/5.20.2 /usr/lib/x86_64-linux-gnu/perl5/5.20 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.20 /usr/share/perl/5.20 /usr/local/lib/site_perl .) at /usr/bin/xen-create-image line 806.
BEGIN failed--compilation aborted at /usr/bin/xen-create-image line 806.
なんか足りないらしい。怒られなくなるまでモジュールを追加。
perl -e'use CPAN; install "File::Slurp"'
cpan File::Slurpperl -e'use CPAN; install "Sort::Versions"'
cpan Sort::Versions
これで一応xen-create-imageのコマンドが通るようになった。
略
一応できたらしい。で、xl create VM1.cfgの時間だ!ってなったんですけど
root@munou:/etc/xen# xl create /etc/xen/VM1.cfg
Parsing config from /etc/xen/VM1.cfg
/etc/xen/VM1.cfg:11: config parsing error near `Program': lexical error
warning: Config file looks like it contains Python code.
warning: Arbitrary Python is no longer supported.
warning: See http://wiki.xen.org/wiki/PythonInXlConfig
Failed to parse config: Invalid argument
おかしいのでVM1.cfgをみる。
#
# Configuration file for the Xen instance VM1, created
# by xen-tools 4.6 on Tue Jul 5 14:34:29 2016.
##
# Kernel + memory size
#Program fragment delivered error ``pygrub not found at /etc/xen-tools/xm.tmpl line 33.''
vcpus = '2'
memory = '128'#
# Disk device(s).
#
root = '/dev/xvda2 ro'
disk = [
'file:/home/xenimage/domains/VM1/disk.img,xvda2,w',
'file:/home/xenimage/domains/VM1/swap.img,xvda1,w',
]#
# Physical volumes
##
# Hostname
#
name = 'VM1'#
# Networking
#
dhcp = 'dhcp'
vif = [ 'mac=00:16:3E:79:44:A7' ]#
# Behaviour
#
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
どうやらProgram fragment delivered error ``pygrub not found at /etc/xen-tools/xm.tmpl line 33.''の部分らしい。bootloaderオプションの--pygrubがだめっぽい(不明)。
ちゃんと生成されたcfgファイルを確認したいので安直に--pygrubを消したらどうなるかを確認してみる。
#
# Configuration file for the Xen instance VM1, created
# by xen-tools 4.6 on Tue Jul 5 15:36:36 2016.
##
# Kernel + memory size
#
kernel = '/boot/vmlinuz-3.16.0-4-amd64'
extra = 'elevator=noop'
ramdisk = '/boot/initrd.img-3.16.0-4-amd64'vcpus = '2'
memory = '1024'#
# Disk device(s).
#
root = '/dev/xvda2 ro'
disk = [
'file:/home/xenimage/domains/VM1/disk.img,xvda2,w',
'file:/home/xenimage/domains/VM1/swap.img,xvda1,w',
]#
# Physical volumes
##
# Hostname
#
name = 'VM1'#
# Networking
#
dhcp = 'dhcp'
vif = [ 'mac=00:16:3E:79:44:A7' ]#
# Behaviour
#
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
それっぽくなった。が、今度はまたエラーを吐き始めた。今度はなんだなんだ・・・
root@munou:/home/munou# xl create /etc/xen/VM1.cfg
Parsing config from /etc/xen/VM1.cfg
xc: error: panic: xc_dom_bzimageloader.c:372: xc_try_xz_decode: XZ decompress support unavailable: Internal error
xc: error: panic: xc_dom_bzimageloader.c:733: xc_dom_probe_bzimage_kernel unable to XZ decompress kernel: Invalid kernel
xc: error: panic: xc_dom_core.c:676: xc_dom_find_loader: no loader found: Invalid kernel
libxl: error: libxl_dom.c:706:libxl__build_pv: xc_dom_parse_image failed: No such file or directory
libxl: error: libxl_create.c:1142:domcreate_rebuild_done: cannot (re-)build domain: -3
libxl: error: libxl.c:1591:libxl__destroy_domid: non-existant domain 1
libxl: error: libxl.c:1549:domain_destroy_callback: unable to destroy guest with domid 1
libxl: error: libxl.c:1476:domain_destroy_cb: destruction of domain 1 failed
エラー文読みたくない・・・そのままググる。
http://permalink.gmane.org/gmane.comp.emulators.xen.devel/234563
それっぽいものを発見。
After installing liblzma-dev and recompiling from source I was able to launch domU with no issues. なるほど?と、とりあえずliblzma-devを入れて全コンパイルし直す.
同時にネットワーク設定を忘れていたことも思い出し、/etc/network/interfacesを編集。
そろそろ嫌になってきてる。すると・・・
Debian GNU/Linux 7 VM1 hvc0
VM1 login: root
Password:
Linux VM1 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2+deb8u3 (2016-07-02) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
root@VM1:~#
おっ?
root@munou:/home/munou# xl list
Name ID Mem VCPUs State Time(s)
Domain-0 0 15121 4 r----- 80.7
VM1 2 1024 2 -b---- 3.3
おお!!!
ってことで一応起動したっぽい。長い戦いだった。