Testing FreeBSD PVHVM
This guide will explain how to setup a FreeBSD PVHVM for testing purposes. It is assumed that the user has a working Dom0 with the xl toolstack.
Setting up a FreeBSD HVM
To speed things, we will use a FreeBSD-HEAD snapshot ISO to install the guest, since the changes are based on FreeBSD-HEAD, this will prevent us from setting a stable version and then doing a full update to HEAD. First grab a FreeBSD-HEAD ISO, they can be found in FreeBSD ftp servers under the path snapshots/ISO-IMAGES/amd64/10.0/ (replace amd64 with i386 if you wish to test 32bit support). Fetch and save one of this ISOs.
Now we need to setup the guest config file, here is an example:
boot="cd" disk = [ 'phy:/dev/guests/freebsd,hda,w', 'file:/root/freebsd-10.iso,hdc:cdrom,r', ] vif = ['mac=00:AA:BB:CC:DD:EE,bridge=bridge0'] memory=4096 vcpus=7 name = "freebsd" xen_platform_pci=1 builder='hvm' vnc=1 vnclisten="0.0.0.0" serial='pty'
Setting serial='pty' is most critical to make the serial console access work!
Change the disk and vif options to match your paths.
Once done, the guest can be launched:
# xl create freebsd.cfg
Connect to the guest using a vnc client and follow the installation process. Once finished, we will configure FreeBSD to use the serial console, so we no longer need to use a vnc client. This process is detailed in The FreeBSD Handbook, we have to edit /boot/loader.conf and add the following lines:
boot_multicons="YES" boot_serial="YES" comconsole_speed="115200" console="comconsole,vidconsole"
This will allow us to get the boot output to the serial console, now we need to setup the seria tty, to do so edit /etc/ttys and search for the line that starts with:
ttyu0 "/usr/libexec/getty std.115200" dialup on secure
Set it to "on" as shown above and change the baudrate. We are done with the setup, on next reboot of the guest you should be able to get the boot output and a terminal using "xl console freebsd".
Fetching the sources and installing the PVHVM kernel
In order to test the new code, you will need git to fetch the sources, this can be installed using ports:
# cd /usr/ports/devel/git # make config-recursive install clean clean-depends
Once git is installed, you can fetch the source:
# git clone git://xenbits.xen.org/people/royger/freebsd.git # cd freebsd # git checkout pvhvm_v10
It is recommended to add the option "ALT_BREAK_TO_DEBUGGER" to the XENHVM config file, so you can easily break to KDB from the serial console. We can proceed with the kernel compilation and install now:
# make kernel-toolchain && make buildkernel KERNCONF=XENHVM && make installkernel KERNCONF=XENHVM
Before rebooting into the new XENHVM kernel, you should add the following line to /etc/rc.conf:
# echo ifconfig_xn0="DHCP" >> /etc/rc.conf
With this changes you can now reboot into the FreeBSD PVHVM, happy testing!