Version 8 (modified by 13 years ago) ( diff ) | ,
---|
Building A VM host
External3 was rebuilt into a VM host.
BASE OS: Ubunut 11.04 Bridge: Open V Switch Emulator: KVM Packages: OpenVSwitch (via-debs), qemu-kvm
Building the Host
It was built using the following steps:
- Install Ubuntu 11.04 from CD (with stock kernel): Had to switch to version 11.04 for kernel compatibly with openvswitch.
The running Kernel Version is:
root@external3:~# uname -r 2.6.38-8-server root@external3:~# uname -a Linux external3 2.6.38-8-server #42-Ubuntu SMP Mon Apr 11 03:49:04 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
- run kvm-ok.
You might need to run
apt-get install cpu-checker
Check for a message like this one:INFO: /dev/kvm does not exist HINT: sudo modprobe kvm_intel INFO: Your CPU supports KVM extensions INFO: KVM (vmx) is disabled by your BIOS HINT: Enter your BIOS setup and enable Virtualization Technology (VT), and then hard poweroff/poweron your system KVM acceleration can NOT be used
If disabled, you will need to enter the bios to enable it. - Install the openvswitch packages. Do not use the Ubuntu repositories since the install the incorrect versions of the package, instead download the
packages that match your kernel version from here
I downloaded:
openvswitch-datapath-module-2.6.38-8-server_1.2.2.10448_amd64.deb openvswitch-common_1.2.2.10448_amd64.deb openvswitch-switch_1.2.2.10448_amd64.deb
and then Installed them in that order with "dpkg -i". It will recommend a restart.
NOTE: The package openvswitch-brcompat_1.2.2.10448_amd64.deb was removed because we are not using bridge compatability. - Once these are installed and the system freshly restarted, you can query the module.
root@external3:~# ovs-vsctl show d03e1847-34f4-4129-8821-63fff3403553 ovs_version: "1.2.2.10448"
lsmod should also show the running openvswitch_mod. - The readme refrenced here recomends installing
the uml utilities, I didn't need them but I installed them any way.
apt-get install uml-utilities
- After these components were installed I added a bridge and got it an address:
ovs-vsctl add-br br0 ovs-vsctl add-port br0 eth0 ifconfig eth0 up dhclient br0
- Make the ovs-ifup and ovs-ifdown scripts as referenced here.
Make sure to chmod +x them.
/etc/ovs-ifup -------------------------------------------------------------------- #!/bin/sh switch='br0' /sbin/ifconfig $1 0.0.0.0 up ovs-vsctl add-port ${switch} $1 -------------------------------------------------------------------- /etc/ovs-ifdown -------------------------------------------------------------------- #!/bin/sh switch='br0' /sbin/ifconfig $1 0.0.0.0 down ovs-vsctl del-port ${switch} $1 --------------------------------------------------------------------
- Now we're ready to install the KVM packages documented here, all but the bridge-utils:
sudo apt-get install qemu-kvm
- Next we will build a vm using the command line tools.
- if you get the error
kvm - .... kvm: pci_add_option_rom: failed to find romfile "pxe-rtl8139.bin"
Install the package kvm-pxe as referenced here.
Building the client OS
This process is clubbed together from a collection of references listed at the bottom. The crux of the process is that instead of using libvirt based tools (e.g. virsh/virt-manager), we will use the qemu/kvm tools directly. A Virtual machine is really only two components, a running process that is spawned via the kvm exectuable (an alias form qemu), and a disk image that is the state of the running VM. To get the virtual machine up we need to build the disk and then start the process. One the process is spawned, a vnc session will begin listening on the proper port (usually 5900). You can connect a vnc client to this port, and thus get "console" access to the VM.
- Building the disk: We use the kvm-img tool to build the disk image. there are many formats but we will used the qcow2 type since it supports snapshots.
kvm-img create -f qcow2 filename size
- Spawing the process: This can be as simple as:
kvm filename
However we'll want to add a few parameters to get the machine in a usable mode.kvm -daemonize -vnc :0 -m 2048 -smp 2 -net nic,model=e1000,macaddr=00:11:22:EE:EE:EE -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -drive file=/root/test_mac.img -cdrom /root/ubuntu-11.04-server-amd64.iso -boot order=dc
The paramenters are:- -vnc - specify which vnc session to spawn, this argument can be specified in several diffrent ways.
- -m - Memeory
- -snp - #of cpus
- -net nic,model=e1000,.. - specify the mac of the first interface. more can be added but the flags will be diffrent. NOTE the model flag is required other wise it defaults to 10/100 with the requisite degradation in performance.
- -net tap,… - specify how the other end of the nic gets connected. In this case we used the vswitch start up scripts
- -drive - the name of the disk drive (there are many ways to specify this flag, include -hda,etc …)
- -cdrom - location of the iso to use as a cd-rom (alternatively you could use /dev/cdrom)
- -boot order=dc - specify boot params like boot order, splash screen, etc… If omitted will default to the first disk
- Once this done you can point your vnc client (locally, or if you specified the parameters correctly remotely) to the specfied port and answer the prompts to
preform an installation. Rember to press f4 at the start screen and choose the minimal vm install option. You will get a machine with a "virtual" kernel.
native@clientvm:~$ uname -r 2.6.38-8-virtual
- After the os is installed, it will try to reboot and fail. At this point you can "shut down" the machine by kill -9 the process.
- Next "remove" the cdrom and start the vm again. It should boot appropriately. Note the missing -boot param.
kvm -daemonize -vnc :0 -m 2048 -smp 2 -net nic,model=e1000,macaddr=00:11:22:EE:EE:EE -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -drive file=/root/test_mac.img
- On external3 I've made 2 scripts to start the VM. Their contents are very simple:
start_vm: kvm -daemonize -vnc :$2 -m 2048 -smp 2 -net nic,model=e1000,macaddr=00:11:22:EE:EE:E$2 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -drive file=$1 install_vm: kvm -daemonize -vnc :0 -m 2048 -smp 2 -net nic,model=e1000,macaddr=00:11:22:EE:EE:E0 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -cdrom $2 -boot order=dc -drive file=$1 root@external3:/root#
install_vm takes 1 parameter, the name of the disk image to install on (the image created earlier via kvm-img), it takes the default vnc port :0 (tcp port 5900), and also mounts a cdrom. The vnc port number is also the last digit of the mac address. start_vm has two arguments, the first is also the image name, the second is which vnc port to take (1-9). It also follows the last digit mac convention.
refrences:
- http://translate.googleusercontent.com/translate_c?hl=en&ie=UTF8&rurl=translate.google.de&sl=de&tl=en&u=http://qemu-buch.de/de/index.php/QEMU-KVM-Buch/_Inhaltsverzeichnis&usg=ALkJrhir9hvb8x9SA1RJNnNapZstHXVYGg
- http://en.wikibooks.org/wiki/QEMU
- http://www.crashcourse.ca/wiki/index.php/QEMU
- http://wiki.qemu.org/Manual#User_Documentation
- https://help.ubuntu.com/community/KVM
- http://openvswitch.org/releases/binaries/1.2.2.10448/natty_amd64/
- http://openvswitch.org/cgi-bin/gitweb.cgi?p=openvswitch;a=blob_plain;f=INSTALL.bridge;hb=HEAD
- http://openvswitch.org/cgi-bin/gitweb.cgi?p=openvswitch;a=blob_plain;f=INSTALL.KVM;hb=HEAD
- https://help.ubuntu.com/community/KVM/Installation
- https://help.ubuntu.com/community/KVM/Networking
- http://www.moe.co.uk/2011/01/07/pci_add_option_rom-failed-to-find-romfile-pxe-rtl8139-bin/
Attachments (3)
-
virtmanager.jpg
(21.5 KB
) - added by 13 years ago.
Virt-Manager
-
virtmannet.jpg
(24.1 KB
) - added by 13 years ago.
Virt-manager Network Config of new VM
-
KVM-MULTI-NETWORK.pdf
(583.2 KB
) - added by 13 years ago.
http://publib.boulder.ibm.com/infocenter/lnxinfo/v3r0m0/index.jsp?topic=%2Fliaat%2Fliaatbptap.htm
Download all attachments as: .zip