2007年9月16日星期日

emerge kvm-37及其配置

用google.cn搜kvm和linux这两个关键词,列出来的中文链接几乎全是2.6.20内核将包括KVM这篇报道。除了赵珂网志上还有些内容外就没什么中文资料了。人云亦云似乎快成一种民族性了。下面讲讲我的安装过程:
我的内核版本是gentoo-sources-2.6.22-r5内核编译时加上下面的选项:

 <M>   Universal TUN/TAP device driver support 
 <*>   KVM for AMD processors support
kvm-37的ebuild好象只支持module里加kvm。后来我只好在portage.use里也加了kvm。

 * If you don't have kvm compiled into the kernel, make sure you have the kernel
 * module loaded before running kvm. The easiest way to ensure that the kernel
 * module is loaded is to load it on boot:
 * For AMD CPUs:
 * echo kvm-amd >> /etc/modules.autoload.d/kernel-2.6
 * For Intel CPUs:
 * echo kvm-intel >> /etc/modules.autoload.d/kernel-2.6

 * Make sure your user is in the 'kvm' group
 * Just run 'gpasswd -a <USER> kvm', then have <USER> re-login.

 * If qemu complains about not having a 1024hz timer, then run this:
 * echo dev.rtc.max-user-freq=1024 >> /etc/sysctl.conf

 * If you want network support in the guest OS, you'll need to make
 * sure you compile in support for 802.1d Ethernet Bridging in the
 * kernel, set up a bridge network interface and make sure you
 * compile Universal TUN/TAP device driver support as a kernel module
 * and make it load on boot:
 * echo tun >> /etc/modules.autoload.d/kernel-2.6
参考下面这篇指南:
http://kvm.qumranet.com/kvmwiki/HOWTO
配置网络
网络配置我走了不少弯路,最后的解决简单地不能再简单了。
要配一个tap0, 配置方法参见相关文档,这个tap0就相当于跟虚拟机连接的端口。做了个kvm脚本,内容如下:
kvm-system-x86_64 . -hda vdisk.img -cdrom /dev/sr0  -m 512 -localtime -net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=no
虚拟机中的网卡与tap0要在一个网段。网关设成tap0的地址。
仍然有个错误:
Could not configure '/dev/rtc' to have a 1024 Hz timer. This is not a fatal
error, but for better emulation accuracy either use a 2.6 host Linux kernel or
type 'echo 1024 > /proc/sys/dev/rtc/max-user-freq' as root.
我按这个提示做了也不管用。
初步试了一下几个软件,似乎除了招商银行网上银行之外基本上都能用。





没有评论: