Sangoma Xen Configuration
Unsupported Configuration
This documents provide a step by step guide for running Sangoma Hardware on a paravirtualized guest OS under the Xen hypervisor. Since Debian provides Xen 4.0 in package management, Debian Lenny has been used as GNU/Linux distribution for the Host operating System.
If you have any problems please contact http://support.sangoma.com
Tutorial Created By:
Bruno Salzano (bruno@brunosalzano.com)
We sincerely appreciate Bruno Salzano assistance in this project.
1. Install Xen 4.0 on Debian Lenny
At the moment we wrote this tutorial, Xen 4.0 is only availabe in Sid (unstable repository). So, it's necessary to enable Sid repositories to install Xen 4.0.
Another choice is to build Xen4 from sources following the instructions from Xen wiki, but this goes outside of the goals of this tutorial. We'll show how to install using Sid repositories.
Add “deb Index of /debian/ unstable main contrib non-free” in /etc/apt/sources.list
Sample: /etc/apt/sources.list
------------------------------------------------------------------------
#
# deb cdrom:[Debian GNU/Linux 5.0.6 _Lenny_ - Official i386 NETINST Binary-1 20100905-11:24]/ lenny main
#deb cdrom:[Debian GNU/Linux 5.0.6 _Lenny_ - Official i386 NETINST Binary-1 20100905-11:24]/ lenny main
deb http://ftp.ca.debian.org/debian/ lenny main
deb-src http://ftp.ca.debian.org/debian/ lenny main
deb Debian -- Security Information lenny/updates main
deb-src Debian -- Security Information lenny/updates main
deb http://volatile.debian.org/debian-volatile lenny/volatile main
deb-src http://volatile.debian.org/debian-volatile lenny/volatile main
deb http://ftp.us.debian.org/debian/ unstable main contrib non-free
----------------------------------------------------------------------------
Run following command to sync repository.
root@lenny# apt-get update
Note: if you get an error like "E: Wow, you exceeded the number of descriptions this APT is capable of." from apt-get update command, you may want to give a look at this link. Anyway, try to run "export LANG=C" and run apt-get update again.
Install Xen 4.0 and Xen-tools running the following command:
root@lenny# apt-get install xen-hypervisor-4.0-amd64 linux-image-2.6.32-5-xen-amd64 xen-tools xen-linux-system-2.6.32-5-xen-amd64
Note: For 32 bit OS use "non -amd64" packages (ex. linux-image-2.6.32-5-xen-amd64 2.6.32-15 and xen-hypervisor-4.0-amd64 4.0.0-2 instead of linux-image-2.6.32-5-xen-686 and xen-linux-system-2.6.32-5-xen-686)
Once Xen 4.0 is installed, disable sid repositories by adding a pound sign (#) in front of the line "deb http://ftp.us.debian.org/debian/ unstable main contrib non-free" in /etc/apt/sources.list. You may want to use it again, but it's safe to leave it disabled.
To apply changes run following command:
root@lenny# apt-get update
Now reboot the system.
root@lenny# reboot
2. Create domU image using xen-create-image
Before all, we have to enable network bridge for xend. This will require to un-comment the line “(network-script network-bridge)” in /etc/xen/xend-config.sxp by removing “#” from front of the line.
Restart xend by running following command:
root@lenny# xend restart
Now, you should be able to see a bridge:
root@lenny# brctl show
bridge name bridge id STP enabled interfaces
eth0 8000.0022195825c8 no peth0
Create local directory for VM image.
root@lenny# mkdir /home/xen
For a test system VM is created with following specifications:
boot partition space = 4GB
swap pace = 512MB
hostname = sangomatest
distro type = lenny
4GB of boot partition space, 512 MB swap space and 512M of RAM using host name “sangomatest” and mirror "http://ftp.ca.debian.org/debian/". If You prefer, a mirror nearest your location can be used. For production systems You may increase ram, swap and disk space as You prefer.
root@lenny# xen-create-image --dhcp --mirror=http://ftp.ca.debian.org/debian/ --passwd --hostname=sangomatest --dist=lenny --size=4G --swap=512M --dir=/home/xen/ --memory=256M --role=udev
(Be patient this might take some time)
This will create configuration file sangomatest.cfg in /etc/xen directory
Start VM in console mode by running command:
root@lenny# xm create sangomatest.cfg -c
You should see you domU booting. At the prompt, after login, run following commands to have your domU Lenny updated:
root@sangomatest# apt-get update && apt-get upgrade
To switch back to your Dom0 Xen OS, use key combination: Ctrl + ]
To get back to guest OS sangomatest console run command “xm console sangomatest”.
Tip: If you've correctly setup networking and sshd daemon is running on DomU you can connect to your DomU through network and ssh client.
3. Find Sangoma Hardware and Make it available for PV Guest DomU VM
Since version 3.0, on Xen You can use PCI passthru to assign a PCI device to a virtual machine guest, giving it full and direct access to the PCI device. For more informations you can read this link.
On Dom0 find out Sangoma’s hardware PCI ID. Run following command.
root@lenny# lspci | grep -i sangoma
or
root@lenny# lspci -n | grep 1923
For example:
---------------------------------------------
root@lenny# lspci | grep -i sangoma
06:04.0 Network controller: Sangoma Technologies Corp. A200/Remora FXO/FXS Analog AFT card
---------------------------------------------
In above example PCI ID of Sangoma hardware is 06:04.0. PCI ID can be different on your machine.
Now edit /boot/grub/menu.lst configuration file and add "irqpoll xen-pciback.hide=(06:04:0)" in the end of “module/boot...” line of Xen 4.0 section.
For example:
-----------------------------------------------------------------------------------------------------------------
title Xen 4.0-amd64 / Debian GNU/Linux, kernel 2.6.32-5-xen-amd64
root (hd0,0)
kernel /boot/xen-4.0-amd64.gz
module /boot/vmlinuz-2.6.32-5-xen-amd64 root=UUID=41b96025-ba58-4938-b118-a492542ac786 ro console=tty0 irqpoll xen-pciback.permissive xen-pciback.hide=(0000:06:04.0) pci=resource_alignment=0000:06:04.0
-----------------------------------------------------------------------------------------------------------------
Tip: for verbose logging of the xen kernel, you may add "loglvl=all guest_loglvl=all" on kernel line of the above configuration. Once booted, from Dom0 you may read xen boot messages invoking the "xm dmesg" command.
Add Sangoma Hardware PCI ID to VM by adding “pci=['06,04,0']” and “extra = 'swiotlb=force iommu=soft'” in /etc/xen/sangomatest.cfg
Example:
-----------------------------------------------------------------------------------------------------------------
#
# Configuration file for the Xen instance sangomatest, created
# by xen-tools 4.2rc1 on Mon Sep 13 13:13:06 2010.
#
#
# Kernel + memory size
#
kernel = '/boot/vmlinuz-2.6.32-5-xen-amd64'
ramdisk = '/boot/initrd.img-2.6.32-5-xen-amd64'
vcpus = '1'
memory = '512'
#
# Disk device(s).
#
root = '/dev/xvda2 ro'
disk = [
'file:/home/xen//domains/sangomatest/disk.img,xvda2,w',
'file:/home/xen//domains/sangomatest/swap.img,xvda1,w',
]
pci=['06,04,0']
#
# Hostname
#
name = 'sangomatest'
#
# Networking
#
dhcp = 'dhcp'
vif = [ 'mac=00:16:3E:C3:C3:95' ]
#
# Behaviour
#
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
extra = 'swiotlb=force iommu=soft'
-----------------------------------------------------------------------------------------------------------------
Shutdown domU (guest OS) and reboot dom0 (host machine).
root@lenny# xm destroy sangomatest
root@lenny# reboot
Once Xen system is restarted run the command “xm pci-list sangomatest” to check PCI passthrough for VM.
For example:
root@lenny# xm pci-list sangomatest
domain bus slot func
0x0000 0x06 0x04 0x0
Note: Please stop here if you cannot see pci back device. Please check “xm demsg” or /var/log/xen/xend.log .
4. Install development tools and kernel-headers on PV Guest DomU VM
Start the DomU (PV Guest OS) with hostname sangomatest
root@lenny# xm create sangomatest.cfg
Install PCI utils package to see pci devices.
root@sangomatest# apt-get install pciutils
Run “lspci” to confim that VM can see the Sangoma Hardware.
For example:
--------------------------------------------------------
# lspci
00:00.0 Network controller: Sangoma Technologies Corp. A200/Remora FXO/FXS Analog AFT card
-------------------------------------------------------
Update /etc/apt/sources.list file on VM to install linux-header files for the installed xen kernel. Header files are required to compile wanpipe drivers and dahdi-linux.
So, add “deb http://ftp.us.debian.org/debian/ unstable main contrib non-free” in /etc/apt/sources.list as you've already done when installing xen4 on dom0.
Save your sources.list file and run “apt-get update” to sync with Sid repository .
root@sangomatest# apt-get update
Install linux-headers files by running following command.
root@sangomatest# apt-get install linux-headers-$(uname -r)
Once kernel-headers are installed disable sid repositories by adding a pound sign (#) in front of the line "deb http://ftp.us.debian.org/debian/ unstable main contrib non-free" in /etc/apt/sources.list. You may want to use it again, but it's safe to leave it disabled.
To apply changes run following command:
root@sangomatest# apt-get update
Install required packages to install wanpipe drivers, dahdi-linux and asterisk:
root@sangomatest# apt-get install build-essential automake autoconf bison flex libtool libncurses5-dev libssl-dev subversion svn-buildpackage sox curl libsox-fmt-all libxml2-dev doxygen
5.Install Sangoma drivers and applications
Sangoma added Xen support in Wanpipe TDM driver from version 3.5.16 and above. Please make sure to use latest version of the driver.
For Asterisk follow wiki instructions at Telephony Cards for Asterisk
For FreeSWITCH follow wiki instructions at Telephony Cards for FreeSWITCH