Kvm
Revision as of 06:05, 11 July 2008 by 10.111.222.9 (talk)
prepare environment
Create disk image.
qemu-img create -f qcow2 f8_1_x86_64.img 10G
Install software.
yum install -y qemu kvm SDL bridge-utils tunctl
Prepare vitual environment and create bridge with eth0
load modules.
modprobe kvm-intel modprobe tun
Create bridge.
tunctl -t tap0 ip addr flush eth0 ifconfig eth0 0.0.0.0 promisc ifconfig tap0 0.0.0.0 promisc brctl addbr br0 ifconfig br0 hw ether 62-f0-dc-95-c4-c9 brctl addif br0 eth0 brctl addif br0 tap0 dhclient br0
Prepare vitual environment and create bridge with wlan0
sudo sysctl net.ipv4.ip_forward=1
modprobe kvm-intel modprobe tun
Create bridge.
tunctl -t tap0 ip addr flush wlan0 ifconfig wlan0 0.0.0.0 promisc ifconfig tap0 0.0.0.0 promisc brctl addbr br0 ifconfig br0 hw ether 62:f0:dc:95:c4:c9 brctl addif br0 wlan0 brctl addif br0 tap0 dhclient br0
Load modules.
sudo modprobe kvm-intel sudo modprobe tun
Paravirtulazied network interface.
qemu-system-x86_64 -hda windowsxp.img -net nic,model=virtio
Start install
sudo qemu-kvm -no-acpi -hda /storage/kvm/windows-xp.img -boot d -cdrom /storage/install/system/winxp/xpsp2/winxpsp2.iso
Start virtual machine.
qemu-kvm -no-acpi -hda /storage/kvm/windows-xp.img -boot c -net nic -net tap,ifname=tap0,script=no
Some startscript
#!/bin/sh PATH=$PATH:/usr/sbin:/sbin sudo brctl addbr br0 sudo ifconfig wlan0 0.0.0.0 sudo brctl addif br0 wlan0 sudo ifconfig br0 10.111.222.8 netmask 255.255.255.0 up sudo route add -net 10.111.222.0 netmask 255.255.255.0 br0 sudo route add default gw 10.111.222.1 br0 sudo tunctl -b sudo ifconfig tap0 up sudo brctl addif br0 tap0 qemu-kvm ~/win2k.img -m 512 -net nic -net tap,ifname=tap0,script=no qemu-kvm -hda winxp.vmd -m 512 -net nic -net tap,ifname=tap0,script=no
Ip forwarding.
sudo sysctl net.ipv4.ip_forward=1
error checking
Create virtual bridge.
sudo brctl addbr br0
Are interfaces connected.
sudo brctl show
Create tun interface.
sudo tunctl
Activate interfaces.
sudo ifconfig tap0 up sudo ifconfig br0 up
Add interfaces to bridge.
sudo brctl addif br0 eth0 sudo brctl addif br0 wlan0 sudo brctl addif br0 tap0