Site Tools


kvm

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
kvm [2011/08/03 23:15] paulsmithkvm [2011/08/03 23:18] (current) – [Check vde management] paulsmith
Line 1: Line 1:
 +====== KVM ======
 +
 +===== References =====
 +<code>
 +[HOWTO] kvm with vde instead of bridging
 +http://forums.gentoo.org/viewtopic-t-760751.html?sid=518518c59c7bd5933e3bc301ad2fda43
 +http://forums.gentoo.org/viewtopic-p-5467295-highlight-vlan0.html#5467295
 +
 +Gentoo QEMU/KVM ethernet bridging nano HOWTO 
 +http://wangbj.blogspot.com/2009/02/gentoo-qemukvm-ethernet-bridging-nano.html
 +
 +Bridge
 +http://www.linuxfoundation.org/collaborate/workgroups/networking/bridge
 +
 +Gentoo KVM wiki
 +http://en.gentoo-wiki.com/wiki/KVM
 +
 +libvirt
 +http://libvirt.org/drvqemu.html
 +
 +</code>
 +
 +===== VDE =====
 +
 +==== Create switch ====
 +# /etc/vde2/vde_switch.rc 
 +<code>
 +vlan/create 1 
 +vlan/addport 1 1 
 +port/create 2 
 +port/allocatable 2 1 
 +port/create 3 
 +port/allocatable 3 1 
 +port/create 4 
 +port/allocatable 4 1 
 +port/setvlan 4 1 
 +port/create 5 
 +port/allocatable 5 1 
 +port/setvlan 5 1 
 +</code>
 +==== Add management to vde ====
 +# /etc/init.d/vde 
 +<code>
 +... 
 +start() { 
 +        ebegin "Starting vde" 
 +        [ "${VDE_MODPROBE_TUN}" == "yes" ] && modprobe tun 
 +        start-stop-daemon --start --quiet \ 
 +                --exec /usr/bin/vde_switch -- -tap ${VDE_TAP} -daemon \ 
 +                -mgmt /var/run/vde.ctl/ctl.mgmt 
 +        eend $? "Failed to start vde" 
 +        chmod -R ${VDE_SOCK_CHMOD} /var/run/vde.ctl 
 +        chown -R ${VDE_SOCK_CHOWN} /var/run/vde.ctl 
 +
 +... 
 +</code>
 +
 +==== Check vde management ====
 +# unixterm /var/run/vde.ctl/ctl.mgmt
 +
 +<code>
 +VDE switch V.2.2.2 
 +(C) Virtual Square Team (coord. R. Davoli) 2005,2006,2007 - GPLv2 
 +
 +vde$ vlan/allprint 
 +0000 DATA END WITH '.' 
 +VLAN 0000 
 + -- Port 0001 tagged=0 active=1 status=Forwarding 
 + -- Port 0002 tagged=0 active=0 status=Learning 
 + -- Port 0003 tagged=0 active=0 status=Learning 
 +VLAN 0001 
 + -- Port 0001 tagged=1 active=1 status=Forwarding 
 + -- Port 0004 tagged=0 active=0 status=Learning 
 + -- Port 0005 tagged=0 active=0 status=Learning 
 +
 +1000 Success 
 +
 +vde$ logout 
 +</code>
 +
 +
 +===== Working Notes =====
 +<code>
 +
 +
 +qemu-img create -f raw gentoo-i386.img 10G
 +
 +ifconfig tap0 10.1.1.1 broadcast 10.1.1.255 netmask 255.255.255.0 
 +ifconfig tap0 up 
 +
 +//does pick up the tap0 interface after being started
 +/etc/init.d/dhcpd restart
 +
 +qemu-kvm -name base -daemonize -vnc 192.168.99.5:1 -monitor unix:/var/run/kvm/base.sock,server,nowait -m 1024 -localtime -hda /usr/local/vmware/gentoo-i386.img -cdrom /usr/local/samba/iso/install-amd64-minimal-20090813.iso -boot d -net vde,vlan=0 -net nic,vlan=0,macaddr=52:54:00:00:EE:03
 +
 +
 +qemu-kvm -name test -smp 2 -m 1024 -localtime -hda /usr/local/vmware/gentoo-i386.img -cdrom /usr/local/samba/iso/install-amd64-minimal-20090813.iso -boot d -net vde,vlan=0 -net nic,vlan=0,macaddr=52:54:00:00:EE:03
 +
 +
 +//wsus
 +qemu-kvm -name test -smp 2 -m 1024 -localtime -hda /usr/local/vmware/WSUS/WIN2K3R2-flat.vmdk -hdb /usr/local/vmware/WSUS/WIN2K3R2-0-flat.vmdk -hdc /usr/local/vmware/WSUS/WIN2K3R2-1-flat.vmdk -boot c -net vde,vlan=0 -net nic,vlan=0,macaddr=00:0c:29:86:94:f4 -uuid 564d934f-2783-e60a-97b1-089af88694f4
 +
 +//printer
 +qemu-kvm -name test -smp 2 -m 1024 -localtime -hda /usr/local/vmware/XPSP3_Printer/XPSP3_Printer.vmdk  -boot c -net vde,vlan=0 -net nic,vlan=0,macaddr=00:0c:29:86:94:f4 -uuid 564d2fcb-b8d5-ad17-a9de-77d16bacf48e
 +
 +//lachlan
 +qemu -enable-kvm -drive file=/dev/sdb,if=ide,media=disk,format=host_device,cache=none -name 'win 7' -m 2000M -smp 2 -vga std -localtime -net nic,macaddr=00:50:56:12:34:56 -net tap,vlan=0,ifname=tap0,script=/etc/qemu/qemu-ifup
 +
 +
 +random mac address:
 +echo $(echo -n DE:AD:BE:EF ; for i in `seq 1 2` ; do echo -n `echo ":$RANDOM$RANDOM" | cut -n -c -3` ;done)
 +
 +
 +qemu-kvm -name WSUSR2 -m 1536 -smp 2 -vga std -localtime -hda /usr/local/vmware/WSUSR2/WSUSR2_0_flat.img -cdrom /usr/local/samba/iso/WIN2003R2/64BIT_X64/standard/DISC1_VLP/EN_WINDOWS_SERVER_2003_R2_STANDARD_DISC1_x64_VLP.iso -boot d -net vde,vlan=0 -net nic,vlan=0,macaddr=DE:AD:BE:EF:25:56 -uuid df88f770-3b1d-11df-9879-0800200c9a66
 +
 +</code>
 +
 +===== Control the virtual machine =====
 +<code>
 +
 +Ctrl-Alt-2 Console
 +Ctrl-Alt-1 Return to virtual
 +
 +sendkey ctrl-alt-delete
 +
 +
 +find out your device names:
 +info block
 +
 +depending on the name of the cdrom:
 +eject ide1-cd0
 +change ide1-cd0 isofilename.iso
 +or
 +eject cdrom
 +change cdrom isofilename.iso
 +
 +</code>
 +
 +
 +====== OLD ======
 +
 +=== example start ===
 +<code>
 +/usr/local/kvm/bin/qemu-system-x86_64 -hda /usr/local/vmware/qemutest/winxpprosp2-flat.vmdk -boot c -m 512 -vnc localhost:1 -net nic,model=rtl8139 -no-kvm
 +/usr/local/kvm/bin/qemu-system-x86_64 -hda /usr/local/vmware/vdisk.img -boot c -cdrom /home/paul/downloads/ubuntu-7.04-server-amd64.iso -m 512 -vnc localhost:1 -net nic,model=rtl8139 -no-kvm
 +</code>
 +
 +=== kvm-33.tar.gz ===
 +<code>
 +tar xzf kvm-release.tar.gz 
 +cd kvm-release 
 +./configure --prefix=/usr/local/kvm 
 +make 
 +make install 
 +</code>
 +
 +=== Qemulator-0.5.tar.gz ===
 +<code>
 +http://qemulator.createweb.de/index.php4?modname=Downloads
 +
 +tar xzf Qemulator-0.5.tar.gz
 +cd Qemulator-0.5
 +./setup.py
 +</code>