ラベル virtualization の投稿を表示しています。 すべての投稿を表示
ラベル virtualization の投稿を表示しています。 すべての投稿を表示

2011年5月19日木曜日

USB Storage iSerial for KVM

# on debian squeeze

## Apache WebDAV 調子芳しくなく... 
## 素直な設定のままでいろいろイジらん方が良さげ

また唐突、絶対に覚えられないのでメモ。地味に必要なヒトいるかも。KVM と言
うか QEMU の話で、-usbdevice オプションは古いから -device オプションを使
おう。調べたところ本家? に指定方法アリ。ドキュメント眺めたり debian git
のソース取ってきたりしたところ -drive 側で

    -drive id=usbmem,file=thinstick.img,serial=01234567890ABCDEF

でイケると思いきや、常に "1" に。また調べると、こんなパッチ があったけど
debian のソース - git://git.debian.org/git/collab-maint/qemu-kvm.git
ではバージョン 0.14.0+dfsg-1~tl からで squeeze にバックポートもないし、
このバージョンでバイナリパッケージ作るも依存関係、他パッケージのバージョ
ン合わずインストールできず。で、いつものよぉおーに...ムリヤリ

    --- hw/usb-msd.c.dpkg-dist 2011-05-19 22:52:54.000000000 +0900
    +++ hw/usb-msd.c 2011-05-19 22:53:00.000000000 +0900
    @@ -296,7 +296,11 @@
                     break;
                 case 3:
                     /* serial number */
    +                if (s->dinfo && s->dinfo->serial) {
    +                     ret = set_usb_string(data, s->dinfo->serial);
    +                } else {
                     ret = set_usb_string(data, "1");
    +                }
                     break;
                 default:
                     goto fail;

多分モニタからは指定できず、起動時のオプション指定のみしか有効にならない。
でもまぁ

    kvm -m 512M -net tap -net nic,model=e1000 \
    -device piix3-usb-uhci -device usb-storage,drive=usbmem \
    -drive id=usbmem,file=memstick.img,serial=0123456789ABCDEF

で動くことは動いてる。根性ナシで手抜き、こっちも忘れそうだけど

    $ dpkg-buildpackage -b -rfakeroot -us -uc
    ...
    $ su
    ...
    # mv /usr/bin/kvm /usr/bin/kvm.dpkg-dist
    # cp debian/qemu-kvm/usr/bin/kvm /usr/bin 

でゴマカシ。

2011年3月28日月曜日

TIPS: squeeze on raw format KVM

さっき作ったイメージ drbd1.img は最初に / 用の sda1 次が何も手を加えていない sda2。最後が swap の sda3。これをホスト側で見るには qcow2 の場合 nbd として扱えるらしけど -f raw でイメージを作成したので...要 root

# file drbd1.img 
drbd1.img: x86 boot sector; partition 1: ID=0x83, active, starthead 32, startsector 2048, 11716608 sectors; partition 2: ID=0x83, starthead 115, startsector 11718656, 3905536 sectors; partition 3: ID=0x82, starthead 143, startsector 15624192, 1150976 sectors, code offset 0x63
# losetup -o $((512 * 2048)) /dev/loop1 drbd1.img
# mkdir mnt_drbd1
# mount /dev/loop1 mnt_drbd1/
# ls mnt_drbd1/
bin boot dev etc home initrd.img lib lib32 lib64 lost+found media mnt opt proc root sbin selinux srv sys tmp usr var vmlinuz
# chroot mnt_drbd1/
root@parent:/# ls
bin boot dev etc home initrd.img lib lib32 lib64 lost+found media mnt opt proc root sbin selinux srv sys tmp usr var vmlinuz
root@parent:/# cat /etc/hostname
drbd1
root@parent:/# exit
exit
# umount mnt_drbd1
# losetup -d /dev/loop1
とまぁ、ホスト側でも操作可能。なので /etc/inittab 書き換え忘れたとか、/etc/default/grub 書き換えたけど update-grub 忘れたとかも後になってでもできる

他ネットワーク周りは...現況は tap 使うが良さげ。ホスト側で適当にブリッジ作っておいて...毎度手は面倒なので /etc/network/interface に

auto br0
iface br0 inet static
address 192.168.1.254
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255

bridge_ports none
bridge_fd 0
bridge_stp off
とか書いといて、KVM (に限らず、仮想ゲストマシン全て) 最初のブリッジに足のばすとすると /etc/kvm/kvm-ifup はこんな感じ
#! /bin/sh
BRCTL=/usr/sbin/brctl

uplinks=$(ip link ls | awk -F: '/^[1-9].*UP> / { print $2; }')
for switch in $uplinks; do
if [ -d /sys/class/net/$switch/bridge/. ]; then
$BRCTL addif $switch $1
break
fi
done

ip link set $1 up
でホスト側で isc-dhcp-server を動かすとゆー... 面倒だね

ターミナルで kvm, debian squeeze

obs600 休憩。間違いもあるので、後日直すコト > 自分

で、唐突めいているけど、あちこち調べながら X なしで squeeze を KVM にてインストールする方法。あちこち調べたのは良いけど、ポロポロ忘れるので...

目的としては DRBD や heartbeat 試したく lxc 使おうとしたけど、今々は lxc 上で DRBD 動かず。ちょっと挑戦した けど、8.4 で connector 止めて genetlink 使う予定だそうなので、素直に? 挫折、待たせてもらうことに。d-i をイジる手もあるそうだけど、素の netinst.iso で何度か試してみて忘れがちなコト
  • 真っ黒画面でスペース & linux test
  • /etc/default/grub の編集 & update-grub
  • /etc/inittab の編集
イメージの作成
$ kvm-img create -f raw drbd1.img 8G
Formatting 'drbd1.img', fmt=raw size=8589934592
$ ls
debian-6.0.0-amd64-netinst.iso drbd1.img

-f qcow2 が正統? なのだろうけど、後々ホスト側からイジるにあたって
kvm-nbd とか面倒なので...で起動
$ kvm -cdrom debian-6.0.0-amd64-netinst.iso -hda drbd1.img -boot d -curses
真っ黒画面の真ん中に
    640x480
で、何も表示されないけどスペース一回押した後に (ここ何押下するかよく忘れる)
    linux text
とすると...
                           Welcome to Debian GNU/Linux!                                F1


This is a Debian 6.0 (squeeze) installation CD-ROM.
It was built 20110205-14:31; d-i 20110106+b1.

HELP INDEX

KEY TOPIC

<F1> This page, the help index.
<F2> Prerequisites for installing Debian.
<F3> Boot methods for special ways of using this CD-ROM
<F4> Additional boot methods; rescue mode.
<F5> Special boot parameters, overview.
<F6> Special boot parameters for special machines.
<F7> Special boot parameters for selected disk controllers.
<F8> Special boot parameters for the install system.
<F9> How to get help.
<F10> Copyrights and warranties.



Press F2 through F10 for details, or ENTER to boot:
こんな画面。ここで F8
            SPECIAL BOOT PARAMETERS - INSTALLATION SYSTEM                                 F8


You can use the following boot parameters at the boot: prompt,
in combination with the boot method (see <F3>). These parameters
control how the installer works.

RESULT PARAMETER
Disable framebuffer vga=normal fb=false
Don't start PCMCIA hw-detect/start_pcmcia=false
Force static network config netcfg/disable_dhcp=true
Set keyboard map bootkbd=es
Select the kde or xfce desktops desktop=kde

Accessibility options (last 2 options not available for all images):
Use high contrast theme theme=dark
Use Braille tty brltty=driver,device,texttable
Use Speakup speakup.synth=driver


For example:
boot: install vga=normal fb=false

Press F1 for the help index, or ENTER to boot:
For example そのまま
    install vga=normal fb=false
で進む。イメージファイル名の通り DRBD を試したかったのでパーティションは 6G を / に 2G は何もせず残りを swap として。Software Selection では Standard と SSH。GRUB のインストールまで終ってリブートするから CD 外してね。になったところ
               [!!] Finish the installation

Installation complete
Installation is complete, so it is time to boot into your new system.
Make sure to remove the installation media (CD-ROM, floppies), so
that you boot into the new system rather than restarting the
installation.

<Go Back> <Continue>
で Go Back。Execute Shell を選択して、ちょっと面倒だけど
BusyBox v1.17.1 (Debian 1:1.17.1-8) built-in shell (ash)
Enter 'help' for a list of built-in commands.

~ # mount
rootfs on / type rootfs (rw)
none on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
tmpfs on /dev type tmpfs (rw,relatime,mode=755)
none on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000)
none on /sys/kernel/debug type debugfs (rw,relatime)
/dev/sda1 on /target type ext3 (rw,relatime,errors=remount-ro,data=ordered)
/dev/sda1 on /dev/.static/dev type ext3 (rw,relatime,errors=remount-ro,data=orde
red)
tmpfs on /target/dev type tmpfs (rw,relatime,mode=755)
~ # chroot /target
# cd /etc/default
# cp grub grub.dpkg-dist
# vi grub
....
# diff -uw grub.dpkg-dist grub
--- grub.dpkg-dist 2011-03-28 11:49:36.000000000 +0900
+++ grub 2011-03-28 11:45:39.000000000 +0900
@@ -4,8 +4,8 @@
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
-GRUB_CMDLINE_LINUX_DEFAULT="quiet"
-GRUB_CMDLINE_LINUX=""
+GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8r"
+GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200 --word=8 --parity=no --stop
=1"

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
@@ -13,7 +13,7 @@
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
-#GRUB_TERMINAL=console
+GRUB_TERMINAL="serial console"

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# update-grub
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.32-5-amd64
Found initrd image: /boot/initrd.img-2.6.32-5-amd64
done
もう一つ /etc/inittab も

# cd /etc
# cp inittab inittab.dpkg-dist
# vi inittab
...

# diff -uw inittab.dpkg-dist inittab | head
--- inittab.dpkg-dist 2011-03-28 11:52:02.000000000 +0900
+++ inittab 2011-03-28 11:53:16.000000000 +0900
@@ -52,15 +52,15 @@
# so if you want to add more getty's go ahead but skip tty7 if you run X.
#
1:2345:respawn:/sbin/getty 38400 tty1
-2:23:respawn:/sbin/getty 38400 tty2
-3:23:respawn:/sbin/getty 38400 tty3
-4:23:respawn:/sbin/getty 38400 tty4
-5:23:respawn:/sbin/getty 38400 tty5
-6:23:respawn:/sbin/getty 38400 tty6
+#2:23:respawn:/sbin/getty 38400 tty2
+#3:23:respawn:/sbin/getty 38400 tty3
+#4:23:respawn:/sbin/getty 38400 tty4
+#5:23:respawn:/sbin/getty 38400 tty5
+#6:23:respawn:/sbin/getty 38400 tty6

# Example how to put a getty on a serial line (for a terminal)
#
-#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
+T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100

# Example how to put a getty on a modem line.
# sync
# exit
~ # sync
~ # exit
でメニューの Finish the Inistallation & Continue... で再起動しないので、他コンソールから kill して再起動。今度は -curses じゃなくて -nographic で
kvm -nographic drbd1.img
でクライアントとして使う分にはソレナリ。

2008年3月27日木曜日

lguest on 2.6.25-rc

どこで見付たか忘れちゃったけど、2.6.25-rc7-git2 には未。
--- old/arch/x86/kernel/tsc_32.c.old    2008-03-27 23:28:27.000000000 +0900
+++ new/arch/x86/kernel/tsc_32.c 2008-03-27 23:29:51.000000000 +0900
@@ -394,13 +394,15 @@
int cpu;

if (!cpu_has_tsc)
- goto out_no_tsc;
+ return;

cpu_khz = calculate_cpu_khz();
tsc_khz = cpu_khz;

- if (!cpu_khz)
- goto out_no_tsc;
+ if (!cpu_khz) {
+ mark_tsc_unstable("could not calculate TSC khz");
+ return;
+ }

printk("Detected %lu.%03lu MHz processor.\n",
(unsigned long)cpu_khz / 1000,
@@ -433,9 +435,4 @@
tsc_enabled = 1;

clocksource_register(&clocksource_tsc);
-
- return;
-
-out_no_tsc:
- setup_clear_cpu_cap(X86_FEATURE_TSC);
}
ぷらっとホームさんの SSD/Linux を lguest で動かすにあたってスワップを加えようかと思ったところ /dev/vdb とか出来ない。udev とか動いていないから?

mknod するにもメジャー、マイナ番号わからない。と悩んでいたら、こんな方法もあった。いや、最初は CONFIG_VIRTIO_BLK=m とかしちゃって調べていたんだけど。/proc/partitions ですか。

2008年3月25日火曜日

VMWare Workstation on 2.6.25-rc

やっぱり web から。any-any-update の 116 展開した後は、この辺りから。書かれている通り vmblock-only が.... iget()read_inode() が良くわからんので通らないけど (私は) 実害なし。でパッチ
diff -ubBr old/vmmon-only/common/task.c new/vmmon-only/common/task.c
--- old/vmmon-only/common/task.c 2007-11-28 19:58:17.000000000 +0900
+++ new/vmmon-only/common/task.c 2008-03-24 22:39:29.000000000 +0900
@@ -25,7 +25,7 @@
* we do not need asm/page.h anymore in this file - not surprising, this
* is common file, yes? And Windows do not have page.h, do they?
*/
-#define _I386_PAGE_H
+#define _ASM_X86_PAGE_H
/* On Linux, must come before any inclusion of asm/page.h --hpreg */
#include "hostKernel.h"
#ifdef linux
diff -ubBr old/vmnet-only/filter.c new/vmnet-only/filter.c
--- old/vmnet-only/filter.c 2007-11-28 19:11:12.000000000 +0900
+++ new/vmnet-only/filter.c 2008-03-24 22:41:08.000000000 +0900
@@ -12,6 +12,11 @@
#include
#include "compat_skbuff.h"
#include
+
+#define NF_IP_LOCAL_OUT NF_INET_LOCAL_OUT
+#define NF_IP_LOCAL_IN NF_INET_LOCAL_IN
+#define NF_IP_POST_ROUTING NF_INET_POST_ROUTING
+
/*
* All this makes sense only if NETFILTER support is configured in our kernel.
*/
diff -ubBr old/vmnet-only/vmnetInt.h new/vmnet-only/vmnetInt.h
--- old/vmnet-only/vmnetInt.h 2007-11-28 19:25:06.000000000 +0900
+++ new/vmnet-only/vmnetInt.h 2008-03-16 21:05:28.000000000 +0900
@@ -78,8 +78,10 @@
*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 65)
# define SET_SK_DEAD(_sk, _val) (_sk)->dead = (_val)
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
# define SET_SK_DEAD(_sk, _val) sock_valbool_flag(_sk, SOCK_DEAD, _val)
+#else
+# define SET_SK_DEAD(_sk, _val) sock_set_flag(_sk, SOCK_DEAD)
#endif
あれ? vmnetInt.h はいじった覚えが無いけど....

2007年11月6日火曜日

using lguest - 3

先日のネットワーク絵の設定。debian パッケージでは bridge-utils と vlan あたり。vlan パッケージ入れて vlan-interfaces (5) を見ると /etc/network/interfaces で vlan の設定ができるらしい。そうそう先日の絵で eth1.1 なんて書いていたが

/opt/lguest# vconfig add eth1 1
Added VLAN with VID == 1 to IF -:eth1:-
WARNING: VLAN 1 does not work with many switches,
consider another number if you have problems.
なんて言われるので eth1.10 と eth1.11 にしてしまった。肝心の /etc/network/interfaces は以下の通り
auto eth1.10
iface eth1.10 inet static
# vlan-raw-device eth1
address 172.27.129.1
broadcast 172.27.129.255
netmask 255.255.255.0
iface eth1.10 inet6 static
address fec0:0:0:1b81:201:8eff:feb3:84d8
netmask 64

auto br0
iface br0 inet static
pre-up brctl addbr $IFACE
address 192.168.0.3
netmask 255.255.255.0
post-down brctl delbr $IFACE

auto br1
iface br1 inet manual
pre-up brctl addbr $IFACE
post-up ip link set $IFACE up
pre-down ip link set $IFACE down
post-down brctl delbr $IFACE
auto br2
iface br2 inet manual
pre-up brctl addbr $IFACE
post-up ip link set $IFACE up
pre-down ip link set $IFACE down
post-down brctl delbr $IFACE

auto eth1.11
iface eth1.11 inet manual
post-up brctl addif br1 $IFACE
post-up ip link set $IFACE up
pre-down ip link set $IFACE down
pre-down brctl delif br1 $IFACE
まぁ IPv6 はご愛嬌。これで lguest を
./lguest 64m /usr/src/stable/vmlinux --block=FW1.img --block=FW1.swap root=/dev/lgba \
--tunnet=bridge:br0 --tunnet=bridge:br1 --tunnet=bridge:br2
と起動するとゲスト FW1 FW2 では eth0 eth1 eth2 が見える。こちらも以前書いたが、これらに対応するホスト側は (ユーザスペースコマンドの) lguest で tap# を作って、それぞれのブリッジインターフェースに addif してくれる。

通信できることはできるのだけど、とっても気になるのが eth1 での 802.1q。ホント喋っているのか tcpdump で確認できず。もう少々要確認ってトコ。

2007年11月1日木曜日

ネットワーク絵


目指すはっ。と構えるほど大それたものではないが、絵としては この辺り に近い構成を host と guest で作成して色々試そうかと。大きな四角がホストで中の小さな二つの四角がゲスト。赤太字がインターフェースで○はアドレスを持つ。実際の設定は....後日。

2007年10月30日火曜日

using lguest - 2

ちょっと使えるようになるまで、また jot。
/opt/lguest# mount -t ext3 -o loop FW1.img tmp
/opt/lguest# chroot tmp
/# apt-get install udev iproute less
Reading package lists... Done
Building dependency tree... Done
....
/# cat >> /etc/fstab
proc /proc proc defaults 0 0
/dev/lgba / ext3 defaults,errors=remount-ro 0 1
/dev/lgbb none swap sw 0 0
/# cat > /etc/resolv.conf
nameserver 192.168.0.3
/# cat >> /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.0.1
netmask 255.255.255.0
gateway 192.168.0.3
/#
/# cat > /etc/hostname
fw1
/# exit
/opt/lguest# dd if=/dev/zero of=FW1.swap bs=1 count=1 seek=$((1024 * 1024 * 128 - 1))
1+0 records in
1+0 records out1+0 records in
1+0 records out
1 byte (1 B) copied, 0.000128516 seconds, 7.8 kB/s
/opt/lguest# mkswap FW1.swap
Setting up swapspace version 1, size = 134213 kB
no label, UUID=69713635-6d63-4cd9-b0da-96d1eb7fe561
/opt/lguest# brctl addbr br0
/opt/lguest# ip addr add 192.168.0.3/24 dev br0
/opt/lguest# ip link set br0 up
/opt/lguest# umount tmp
/opt/lguest# ./lguest 64m /usr/src/stable/vmlinux --block=FW1.img --block=FW1.swap root=/dev/lgba --tunnet=bridge:br0
....
Debian GNU/Linux lenny/sid fw1 /dev/hvc0

fw1 login: root
Last login: Tue Oct 30 14:08:48 UTC 2007 on hvc0
Linux fw1 2.6.23.1 #1 Wed Oct 17 13:58:03 JST 2007 i686

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.
fw1:~#
fw1:~# ping -c3 192.168.0.3
PING 192.168.0.3 (192.168.0.3) 56(84) bytes of data.
64 bytes from 192.168.0.3: icmp_seq=1 ttl=64 time=7.64 ms
64 bytes from 192.168.0.3: icmp_seq=2 ttl=64 time=0.266 ms
64 bytes from 192.168.0.3: icmp_seq=3 ttl=64 time=0.262 ms

--- 192.168.0.3 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.262/2.724/7.644/3.478 ms
fw1:~# mount
/dev/lgba on / type ext3 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
fw1:~# swapon -s
Filename Type Size Used Priority
/dev/lgbb partition 131064 0 -1
fw1:~# apt-get update
Get:1 http://ring.asahi-net.or.jp lenny Release.gpg [189B]
Hit http://ring.asahi-net.or.jp lenny Release
Get:2 http://ring.asahi-net.or.jp lenny/main Packages/DiffIndex [2038B]
Fetched 2227B in 2s (989B/s)
Reading package lists... Done
fw1:~# apt-get dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
fw1:~# apt-get install ssh deborphan
....
fw1:~# useradd -d /home/chamaken -G users chamaken -m
fw1:~# passwd chamaken
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
fw1:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/lgba 2.0G 266M 1.7G 14% /
tmpfs 30M 0 30M 0% /lib/init/rw
udev 10M 20K 10M 1% /dev
tmpfs 30M 4.0K 30M 1% /dev/shm
fw1:~# shutdown -h now
Saving the system clock..
hwclock[1215] general protection eip:804aacb esp:bff53fc4 error:0
/etc/rc0.d/K25hwclock.sh: line 48: 1215 Segmentation fault /sbin/hwclock --systohc $GMT $HWCLOCKPARS $BADYEAR
....
lguest: CRASH: Power down
と、まぁまぁ使えるようになりましたっと。``さて'' という字は尻へんに長いと書く。と言っているおじさんがいました。

2007年10月22日月曜日

using lguest - 1

とりあえずの起動までを、ちょっと jot。
/opt/lguest# dd if=/dev/zero of=FW1.img bs=1 count=1 seek=$((1024 * 1024 * 1024 * 2 - 1))
1+0 records in
1+0 records out
1 byte (1 B) copied, 0.000126002 seconds, 7.9 kB/s
/opt/lguest# ls -l
total 16
-rw-r--r-- 1 root root 2147483648 2007-10-22 20:28 FW1.img
/opt/lguest# mkfs.ext3 FW1.img
mke2fs 1.40-WIP (14-Nov-2006)
FW1.img is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
....snip....
This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
/opt/lguest# mkdir tmp
/opt/lguest# mount -t ext3 -o loop FW1.img tmp
/opt/lguest# debootstrap --arch i386 lenny tmp http://ring.asahi-net.or.jp/archives/linux/debian/debian
I: Retrieving Release
....snip....
I: Base system installed successfully.
/opt/lguest# chroot tmp
/# cp /etc/inittab oldtab
/# vi /etc/inittab
....
/# diff -ubB oldtab /etc/inittab
--- oldtab 2007-10-22 11:54:48.000000000 +0000
+++ /etc/inittab 2007-10-22 11:54:12.000000000 +0000
@@ -51,12 +51,12 @@
# Note that on most Debian systems tty7 is used by the X Window System,
# so if you want to add more getty's go ahead but skip tty7 if you run X.
#
-1:2345:respawn:/sbin/getty 38400 tty1
-2:23:respawn:/sbin/getty 38400 tty2
-3:23:respawn:/sbin/getty 38400 tty3
-4:23:respawn:/sbin/getty 38400 tty4
-5:23:respawn:/sbin/getty 38400 tty5
-6:23:respawn:/sbin/getty 38400 tty6
+1:2345:respawn:/sbin/getty 38400 /dev/hvc0
+#2:23:respawn:/sbin/getty 38400 tty2
+#3:23:respawn:/sbin/getty 38400 tty3
+#4:23:respawn:/sbin/getty 38400 tty4
+#5:23:respawn:/sbin/getty 38400 tty5
+#6:23:respawn:/sbin/getty 38400 tty6

# Example how to put a getty on a serial line (for a terminal)
#
/# cat >> /etc/securetty

# lguest console
hvc0
/# mknod /dev/hvc0 c 229 0
/# exit
exit
/opt/lguest# umount tmp
/opt/lguest# cd /usr/src/stable/Documentation/lguest/
/usr/src/stable/Documentation/lguest# make
cc -Wall -Wmissing-declarations -Wmissing-prototypes -O3 -Wl,-T,lguest.lds -static lguest.c -lz -o lguest
/usr/src/stable/Documentation/lguest# cp lguest /opt/lguest/
/usr/src/stable/Documentation/lguest# cd !$
cd /opt/lguest/
/opt/lguest# modprobe lg
/opt/lguest# ./lguest 64m /usr/src/stable/vmlinux --block=FW1.img root=/dev/lgba
いや、実のところ、途中途中しくじっているけどね。

2007年9月10日月曜日

lguest64

[ANNOUNCE] Lguest64 - fatter puppies! This is a formal announcement of Lguest64. だそうだ。
git://git.et.redhat.com/kernel-lguest-64.git だそうだ (T_T)

2007年8月15日水曜日

lguest のネットワーク

(ユーザスペースの) lguest のオプションは、何も指定しないと
lguest: Usage: lguest [--verbose] [--sharenet=<filename>|--tunnet=(<ipaddr>|bridge:<bridgename>)
|--block=<filename>|--initrd=<filename>]...
<mem-in-mb> vmlinux [args...]
となる。この内ネットワークに関する部分は
--sharenet=<filename>
どうもゲスト間のインターフェース。ファイル名だし

--tunnet
TUN/TAPを使う。TUN と TAP って linux で区別されているのか知らない...
<ipaddr>
よくある? peer to peer のインターフェース。試していないが一番てっとり早いと思われる

bridge:<bridgename>
これが本題。README にはホストと同じセグメントにすべく例があるけど、別共有ネットワークも簡単に作れる。当初個々ゲストに上の ipaddr を指定して、後で tap# をブリッジに加えてあげれば良いかな。と考えていたが、良く考えてくれてあってブリッジだけ作っておけば、勝手に tap# 作って加えてくれる。
なので conntrack-tools のテストケースであればホストを A として
# brctl addbr lguest
# ... ブリッジいろいろ
# lguest 64m --block FW1.img --tunnet bridge:lgbr --sharenet ether0 --sharenet ether2 vmlinux root=/dev/lgba
# lguest 64m --block FW2.img --tunnet bridge:lgbr --sharenet ether0 --sharenet ether2 vmlinux root=/dev/lgba
# lguest 64m --block B.img --sharenet ether0 vmlinux root=/dev/lgba
でイケそうな感じ。eth0 eth2 のパケットも見たいのであれば、取り急ぎ sharenet 止めてブリッジ作ってあげれば良い?

2007年8月14日火曜日

lguest のコンソール

2.6.23-rc に入ったので lguest 再度試してみる。まだ FAQ には反映されていないけど、patch の中にこんな記述があった。
Q: Why don't I have a console when I boot my image?

A: Most images are set up to create a console virtual consoles (/dev/tty0 etc), but the lguest console is /dev/hvc0: look for a line like "1:2345:respawn:/sbin/getty 38400 tty1" in /etc/inittab and change "tty1" to o "hvc0".
debootstrap でイメージ作った後にゲストの /dev に移動して
mknod hvc0 c 229 0
上記通り inittab を書き換えて... root でログインできん。で /etc/securetty に hvc0 を追記。やっと最初の一歩。

2007年7月12日木曜日

lguest for 2.6.22

コンパイルでエラーになってしまったので、2.6.21 の頃のものと比較。
--- arch/i386/kernel/asm-offsets.c.orig 2007-07-12 00:06:33.000000000 +0900
+++ arch/i386/kernel/asm-offsets.c 2007-07-12 00:17:51.000000000 +0900
@@ -16,6 +16,10 @@
#include <asm/processor.h>
#include <asm/thread_info.h>
#include <asm/elf.h>
+#ifdef CONFIG_LGUEST_GUEST
+#include <linux/lguest.h>
+#include "../../../drivers/lguest/lg.h"
+#endif

#define DEFINE(sym, val) \
asm volatile("\n->" #sym " %0 " #val : : "i" (val))
@@ -115,4 +119,17 @@
OFFSET(PARAVIRT_iret, paravirt_ops, iret);
OFFSET(PARAVIRT_read_cr0, paravirt_ops, read_cr0);
#endif
+#ifdef CONFIG_LGUEST_GUEST
+ BLANK();
+ OFFSET(LGUEST_DATA_irq_enabled, lguest_data, irq_enabled);
+ OFFSET(LGUEST_PAGES_host_gdt_desc, lguest_pages, state.host_gdt_desc);
+ OFFSET(LGUEST_PAGES_host_idt_desc, lguest_pages, state.host_idt_desc);
+ OFFSET(LGUEST_PAGES_host_cr3, lguest_pages, state.host_cr3);
+ OFFSET(LGUEST_PAGES_host_sp, lguest_pages, state.host_sp);
+ OFFSET(LGUEST_PAGES_guest_gdt_desc, lguest_pages,state.guest_gdt_desc);
+ OFFSET(LGUEST_PAGES_guest_idt_desc, lguest_pages,state.guest_idt_desc);
+ OFFSET(LGUEST_PAGES_guest_gdt, lguest_pages, state.guest_gdt);
+ OFFSET(LGUEST_PAGES_regs_trapnum, lguest_pages, regs.trapnum);
+ OFFSET(LGUEST_PAGES_regs_errcode, lguest_pages, regs.errcode);
+ OFFSET(LGUEST_PAGES_regs, lguest_pages, regs);
+#endif
}
とりあえず通るは通った。

2007年6月20日水曜日

VMware workstation 6.0

Open Tech Press の記事 に VMWare6 すばらしい。らしき書かれていて眺めると
今回のWorkstation 6では、ユーザインタフェースなしでVMを実行できる。Workstationのウィンドウを閉じると、VMを電源オフにするかバックグラウンドで実行を続けるかの選択肢が表示される。これは、Webサーバなど、後で接続したいサービスをVMが実行している場合に便利だ。
と私にとって魅力的なものが。# もしかして Server でもできていた?

しかも x86_64 もあったので、早速 Upgrade して試してみたところ、まぁ上記通りライブラリ含めて 64bit になっていたし、ウィンド閉じようとすると daemon で稼働させるか聞いてくる。

2.6.22-rc をホストとした場合 sk_buff 周りの変更に vmnet が対応しておらず、ここから patch 持ってきてあてておく。cvut.cz にあった any-any-update が最近更新されていないのが少々恐い。

あとは個人的にネットワークは hostonl のインターフェースのみとして /usr/lib/vmware/net-services.sh いじって dhcp 止めるのとインターフェースのアップを vmware_bg_exec から vmware_exec へ。他 /etc/rc2.d/S19 番目。これやっておかないと dhcp の relay が動かんから。

# lguest が 32bit のみだから試すにあたって? 目的のための手段のための手段のための...

2007年5月29日火曜日

kqemu

仮想化で使ったことが無かった qemu に挑戦。debian 使っているので、DebianでQEMUを高速化する(kqemuモジュール)がとっても参考になった。細かな話だけど module-assistant の部分はどこかの madwifi のコンパイル方法にもあったが
m-a a-i kqemu
かな。QEMUのサイトにあるlinux-0.2.img.bz2 (8 MB)でも良いけど。debian であれば qemu-make-debian-root なるものがあったり qemu-img もあるけど。その後 ここここを参照しつつ

# dd if=/dev/zero of=disk.img bs=1M seek=2047 count=1
# losetup /dev/loop0 disk.img
# cfdisk -s 63 -h 16 /dev/loop0
....(1つのパーティションで bootable に)
# losetup -o 32256 /dev/loop0 disk.img
# mkfs -t ext3 /dev/loop0
# losetup -d /dev/loop0
# mkdir rootfs
# mount -o offset=32256,loop disk.img rootfs
# debootstrap --arch amd64 etch rootfs http://ring.asahi-net.or.jp/archives/linux/debian/debian
....
# chroot rootfs /bin/bash
# apt-get install kernel-image-2.6-amd64-generic grub
....
# mkdir /boot/grub
# update-grub
# cp /usr/lib/grub/x86_64-pc/* .
# exit
# umount root
# exit
# /usr/sbin/grub --no-floppy
# grub --no-floppy
Probing devices to guess BIOS drives. This may take a long time.

GNU GRUB version 0.97 (640K lower / 3072K upper memory)

[ Minimal BASH-like line editing is supported. For
the first word, TAB lists possible command
completions. Anywhere else TAB lists the possible
completions of a device/filename. ]
grub> device (hd0) disk.img
device (hd0) disk.img
grub> root (hd0,0)
root (hd0,0)
Filesystem type is ext2fs, partition type 0x83
grub> setup (hd0)
setup (hd0)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/boot/grub/stage2 /
Done.
grub> quit
quit
# qemu-system-x86_64 disk.img
おぉ...と思ったら slashdot に こんな 記事が。さて...

# 目的のための手段のための手段のための...が目的に

2007年5月28日月曜日

Virtualizationいろいろ

順序間違えてしまった...conntrackd 試すがためにホスト 2台準備するのはツライので何か流行の仮想化を使おうと画策。Vmware Server で試したところ keepalived までは OK。でも肝心の conntrackd の挙動が怪しかったので UML に。と考えていたら、こんな比較が

TechComparison

流行? の上良さげなのは KVM だけど VT, Pacifica 対応の PC ないしぃ。Xen は vanilla に組込まれそうな気配が無さそうとの話だし、Vmware もう一度試してみようか。そうそう Workstation の 6 って良い? version up した方が良い?

2007年2月6日火曜日

UML の環境 その 2

udev入れたのに MACアドレス指定していなかった。で eth# が無いとエラー。 /etc/udev/rules.d/z25_persistent-net.rules を消すという姑息な手段で逃げる。ちょっと長くなるけど uml_switch の起動スクリプト。debian のものをちょこっと変更しただけ。

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/uml_switch
NAME=uml_switch
DESC="User-mode networking switch"

PIDFILE_0=/var/run/uml-utilities/$NAME.0.pid
PIDFILE_1=/var/run/uml-utilities/$NAME.1.pid
PIDFILE_2=/var/run/uml-utilities/$NAME.2.pid

test -x $DAEMON || exit 0

set -e

UML_SWITCH_USER="uml-net"

UML_SWITCH_CTL_0="/var/run/uml-utilities/switch.0"
UML_SWITCH_CTL_1="/var/run/uml-utilities/switch.1"
UML_SWITCH_CTL_2="/var/run/uml-utilities/switch.2"

OPTIONS_0="-tap tap0 -hub -unix $UML_SWITCH_CTL_0"
OPTIONS_1="-hub -unix $UML_SWITCH_CTL_1"
OPTIONS_2="-hub -unix $UML_SWITCH_CTL_2"


case "$1" in
start)
echo -n "Starting $DESC: "
if [ "x$UML_SWITCH_START" = "xfalse" ] ; then
echo " Disabled."
exit 0
else
echo -n " $NAME"
fi

for i in 0 1 2; do
eval start-stop-daemon --start --quiet --pidfile \$PIDFILE_${i} \
--make-pidfile --background --chuid \$UML_SWITCH_USER \
--exec $DAEMON -- \$OPTIONS_${i}

WAIT=5
while ! eval test -e \$UML_SWITCH_CTL_${i}; do
sleep 1
WAIT=$(($WAIT - 1))
if [ $WAIT -le 0 ]; then
eval echo "\$DAEMON never created control socket \$UML_SWITCH_CTL_${i}" >&2
exit 1
fi
done

eval chmod 777 \$UML_SWITCH_CTL_${i}
done
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
for i in 0 1 2; do
eval start-stop-daemon --stop --quiet --pidfile \$PIDFILE_${i} \
--oknodo --exec \$DAEMON
eval rm -f \$PIDFILE_${i} \$UML_SWITCH_CTL_${i}
done
echo "."
done
echo "."
;;
restart|force-reload)
$0 stop
$0 start
;;
*)
N=/etc/init.d/$NAME
# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac

exit 0
更に同じディレクトリに linux というバイナリがある前提の起動用

if [ -z $1 ]; then
echo "what number?" 1>&2
exit
fi

nohup ./linux \
ubda=rootfs_$1 \
ubdb=swap_$1 \
mem=64m \
eth0=daemon,26:4b:fb:b7:fb:0${1},,/var/run/uml-utilities/switch.0 \
eth1=daemon,26:4b:fb:b7:fb:1${1},,/var/run/uml-utilities/switch.1 \
eth2=daemon,26:4b:fb:b7:fb:2${1},,/var/run/uml-utilities/switch.2 \
con0=null > uml_${1}.log 2>&1 &
いや、こんなこと や dhcp の冗長とかやってみたくて...

2007年1月30日火曜日

UML の環境 その 1

何やってんのか...目的のための手段が目的になってばっかり。NFS 扱いちょっと不満。ネットワーク周りは debian で楽だから。と書かれていたので uml_switch を使っているのだけど autofs で mount している /home を hostfs では mount できんし、そもそも NFS 経由で mount できん。NFS ERR パケット多発。あと 2.6.19.2 i386 でコンパイルする場合は

--- stub.h.orig 2007-01-30 19:43:19.000000000 +0900
+++ stub.h.patched 2007-01-30 19:43:46.000000000 +0900
@@ -9,6 +9,7 @@
#include <sys/mman.h>
#include <asm/ptrace.h>
#include <asm/unistd.h>
+#include <asm/page.h>
#include "stub-data.h"
#include "kern_constants.h"
#include "uml-config.h"

が必要になるかも。で持ってきた debian の rootfs イメージは shadow になっていないらしいので passwd を reconfigure。あとは uml_switch で -hub を指定してあげないと UML 同士で接続できない...ってとこか。そうそう udev をインストールしておかないと swap でハマる。

2007年1月29日月曜日

UML の build

ソースから UML をコンパイルしようとしたら、エラーで止まってしまった。よくドキュメントを読んでみたら

make ARCH=um mrproper
make ARCH=um defconfig

あたりが抜けてた。忘れないよーに。

2007年1月22日月曜日

open("~/")

User-Mode-Linux の時に書いたバイナリとか root fs とか置いて下さっているサイト から 2.6.19.2 のバイナリとか持ってきたけど動かん... strace すると open("~/.uml", , O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) が ENOENT になる。で x86_64 では、この部分 /home/hoge/.uml になっている様だが...自分でコンパイルしろっ。ってコトですね。