osstest: add a FreeBSD host
v3 cover osstest: add a FreeBSD host
Hello,
The following series enables setting up a FreeBSD PVH Dom0 host. Although this is marked as "v3" it should clearly have the RFC tag, I just haven't added it because previous "v2" version was much reduced in functionality and didn't have it.
The following extract from an IRC conversation with Ian Jackson should set the basis of what I'm trying to accomplish:
< Roger> IanJ: how should I add new trees to OSSTest (like tree_xen), is it only a matter of adding it in the invocation of cs-job-create in mfi-common? < IanJ> Roger: What kind of a tree ? I mean, what are you trying to do ? < IanJ> Perhaps this thing (whatever it is) needs a push gate. Is it cloned by the Makefiles inside xen.git ?
< Roger> IanJ: something similar to what is done for pvops, but with FreeBSD, but I'm not sure I'm getting it right...
< IanJ> Roger: So you're trying to make a new kind of build job ? < IanJ> ts-freebsd-build or something ?
< Roger> IanJ: yup, I think I already have that
< Roger> ts-freebsd-host-build
< IanJ> So how does that obtain the source code ?
< Roger> it doesn't compile itself yet, it just installs from a base image < IanJ> Does it use build_clone ?
< IanJ> But you want to change it to build ?
< Roger> IanJ: OK, let me explain the whole picture because you will be able to understand it better
< IanJ> The way we do it with Linux is we install a distro kernel on the build host, and build the kernel we are going to want to use using our distro's binary packages for compiler etc.
< IanJ> Then for the test hosts we install the OS with a distro kernel and then put our own kernel on afterwards.
< Roger> IanJ: in order to install FreeBSD from bare metal I use something called mfsBSD, which generates an image that can be booted by pxelinux and contains the FreeBSD installer
< Roger> IanJ: in order to bootstrap it, I have placed a stable mfsBSD image on the tftp server, that installs the last stable release 10.1
< IanJ> Roger: How do you run mfsBSD if you don't already have a BSD box ? < Roger> IanJ: you can't
< Roger> that's the thing...
< IanJ> Ah right.
< Roger> IanJ: then I fetch the sources for FreeBSD and mfsBSD, and build an updated image, that I reinstall using pxelinux again...
< IanJ> So this is a kind of bootstrap image which performs roughly the same role as our debian-installer image files ?
< Roger> IanJ: yes, but we need a FreeBSD box in order to generate up to date images
< IanJ> And the osstest test runner VM isn't BSD. I see the problem. < Roger> IanJ: so ideally I was thinking that this job should only run once a week, and generate a new image from upstream, test it, and mark it as OK, so that regular OSStest use it straigh away
< IanJ> Roger: That sounds plausible.
< Roger> IanJ: now, I have no idea how to implement this, is there something half-similar I can look at?
< IanJ> The difficulty is that osstest's push gate is designed to push vcs revisions, not images.
< IanJ> I think in fact that most of what's in cr-daily-branch would be stuff which gets in the way.
< Roger> IanJ: so you for example rebuild the pvops kernel every time, even if the vcs revision is the same?
< IanJ> Yes (except that the bisector can reuse builds).
< IanJ> What form is the upstream in ?
< Roger> IanJ: I was using git (although the master FreeBSD repo is svn) < IanJ> So you have something which automatically updates the git source ? So we can treat it as git from osstest's pov.
< Roger> IanJ: I mean, I was using an official git mirror
< IanJ> Right, jolly good.
< Roger> IanJ: that's the plan, so we get bisection and a push gate also < IanJ> Roger: So how about this: we somehow make cr-daily-branch, if it decides to push the freebsd branch, also copy the generated image somewhere where other things will pick it up.
< Roger> IanJ: that sounds OK to me, I think I should send my OSSTest patches so you can see the mess I did and continue this on email
The crappy way I'm currently testing this is by doing the following steps:
$ OSSTEST_FLIGHT=standalone OSSTEST_JOB=build-amd64-freebsd OSSTEST_HOST=dt51 ./ts-freebsd-host-install host=dt51 version=10.1-RELEASE $ OSSTEST_FLIGHT=standalone OSSTEST_JOB=build-amd64-freebsd OSSTEST_HOST=dt51 ./ts-freebsd-create-mfsbsd host=dt51 version=798d728a636c7efb6149c352a40e1173234a19e0 $ rm -rf tmp/t.known_hosts_standalone.build-amd64-freebsd # there's no way to tell mfsBSD to generate an image with preseed ssh-keys. $ OSSTEST_FLIGHT=standalone OSSTEST_JOB=build-amd64-freebsd OSSTEST_HOST=dt51 ./ts-freebsd-host-install host=dt51 version=798d728a636c7efb6149c352a40e1173234a19e0 $ OSSTEST_FLIGHT=standalone OSSTEST_JOB=build-amd64-freebsd OSSTEST_HOST=dt51 ./ts-xen-build-prep-freebsd host=dt51 $ OSSTEST_FLIGHT=standalone OSSTEST_JOB=build-amd64-freebsd OSSTEST_HOST=dt51 ./ts-xen-build host=dt51 $ ./cs-adjust-flight -v standalone runvar-set build-amd64-freebsd buildjob build-amd64-freebsd runvar-set build-amd64-freebsd xenbuildjob build-amd64-freebsd $ OSSTEST_FLIGHT=standalone OSSTEST_JOB=build-amd64-freebsd OSSTEST_HOST=dt51 ./ts-xen-install-freebsd host=dt51
PATCH v3 1/7 osstest: add routine to execute ssh with password
This is needed when bootstrapping FreeBSD, since the installer has ssh enabled with the root password set to 'root' by default.
---
Changes since RFC:
- Place the temp filename in a local variable.
- Add error checks.
--- Osstest/TestSupport.pm | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-)
Osstest/TestSupport.pm +38 -5
@@ -60,6 +60,7 @@ BEGIN { target_install_packages target_install_packages_norec target_jobdir target_extract_jobdistpath_subdir target_extract_jobdistpath target_guest_lv_name + target_cmd_root_with_password poll_loop tcpconnect await_tcp contents_make_cpio file_simple_write_contents
@@ -314,12 +315,11 @@ END #---------- running commands eg on targets ---------- sub cmd { - my ($timeout,$stdout,@cmd) = @_; + my ($timeout,$child_sub,@cmd) = @_; my $child= fork; die $! unless defined $child; if (!$child) { - if (defined $stdout) { - open STDOUT, '>&', $stdout - or die "STDOUT $stdout $cmd[0] $!"; + if (defined $child_sub) { + $child_sub->(); } exec @cmd; die "$cmd[0]: $!";
@@ -578,9 +578,42 @@ sub tcmd { # $tcmd will be put between '' but not escaped sub target_cmd ($$;$) { tcmd(undef,'osstest',@_); } sub target_cmd_root ($$;$) { tcmd(undef,'root',@_); } +sub target_cmd_root_with_password { + my ($ho,$tcmd,$timeout,$password) = @_; + my $temp_name = "tmp/t.ssh-password-helper.$flight.$job"; + + open(my $temp_fh, '>', $temp_name) + or die "Cannot open $temp_name: $!"; + print $temp_fh "#!/bin/sh\n\necho \"$password\"\n" + or die "Cannot write to $temp_name: $!"; + chmod 0755, $temp_name + or die "Cannot chmod $temp_name: $!"; + close $temp_fh + or die "Cannot close $temp_name: $!"; + + my $child_sub = sub { + $ENV{DISPLAY} = ":0"; + $ENV{SSH_ASKPASS} = "tmp/t.ssh-password-helper.$flight.$job"; + setsid or die "Can't start a new session: $!"; + }; + + my $ssh_opts = [qw(-o BatchMode=no + -o PasswordAuthentication=yes + -o ChallengeResponseAuthentication=yes), + @{ sshopts() }]; + + tcmdex($timeout,$child_sub, + 'ssh', $ssh_opts, + sshuho("root",$ho), $tcmd); + + unlink $temp_fh; +} + sub tcmdout { my $stdout= IO::File::new_tmpfile(); - tcmd($stdout,@_); + my $stdout_sub = sub { open STDOUT, '>&', $stdout + or die "STDOUT $stdout $!"; }; + tcmd($stdout_sub,@_); $stdout->seek(0,0) or die "$stdout $!"; my $r; { local ($/) = undef;
Signature · 7 lines
1.9.3 (Apple Git-50) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v3 2/7 osstest: add support for installing bare metal FreeBSD
In reply to Roger Pau MonneThis is done using mfsBSD, which can be booted from pxelinux and contains a script to automatically install FreeBSD using ZFS on root. After the install the host is set to boot from the local disk.
---
Changes since RFC:
- Set the bridge to use the MAC from the first added interface instead of generating a random one.
- Launch DHCP on the bridge instead of the nic.
- Add a list of FreeBSD ftp mirrors and iterate over them in order to find a working one.
- Add support for finding the primary disk and nic automatically.
- Switch shell to sh (instead of the default csh), and use set -e in order to exit if a command fails.
- Replace echo "-Dh" with printf "%s" "-Dh".
- Copy installer keys into the installed system in order to prevent it from generating new keys on the first boot.
--- ts-freebsd-host-install | 237 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 237 insertions(+) create mode 100755 ts-freebsd-host-install
ts-freebsd-host-install new file +237 -0
@@ -0,0 +1,237 @@ +#!/usr/bin/perl -w +# This is part of "osstest", an automated testing framework for Xen. +# Copyright (C) 2009-2014 Citrix Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +use strict qw(vars); +use DBI; +use POSIX; + +use Osstest; +use Osstest::TestSupport; +use Osstest::Logtailer; + +tsreadconfig(); + +our ($whhost) = grep /host=/, @ARGV; +$whhost ||= 'host'; +our $ho= selecthost($whhost); +exit 0 if $ho->{Flags}{'no-reinstall'}; +exit 0 if $ho->{SharedReady}; + +our %timeout= qw(ReadPreseed 350 + Sshd 2400); + +# TODO: this should be runvars +our ($version) = grep /version=/, @ARGV; +$version =~ s/version=//; +logm("Installing FreeBSD version: $version"); + +# List of FreeBSD mirrors, obtained from: +# http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/mirrors-ftp.html +# 13/08/2014 +our @ftp_hosts = qw(ftp.freebsd.org ftp1.freebsd.org ftp2.freebsd.org + ftp3.freebsd.org ftp4.freebsd.org ftp5.freebsd.org + ftp6.freebsd.org ftp7.freebsd.org ftp10.freebsd.org + ftp11.freebsd.org ftp13.freebsd.org ftp14.freebsd.org + ftp1.am.freebsd.org ftp.au.freebsd.org ftp2.au.freebsd.org + ftp3.au.freebsd.org ftp.at.freebsd.org ftp2.br.freebsd.org + ftp3.br.freebsd.org ftp4.br.freebsd.org ftp.ca.freebsd.org + ftp2.ca.freebsd.org ftp.cn.freebsd.org ftp.cz.freebsd.org + ftp2.cz.freebsd.org ftp.dk.freebsd.org ftp.ee.freebsd.org + ftp.fi.freebsd.org ftp.fr.freebsd.org ftp1.fr.freebsd.org + ftp3.fr.freebsd.org ftp5.fr.freebsd.org ftp6.fr.freebsd.org + ftp7.fr.freebsd.org ftp8.fr.freebsd.org ftp.de.freebsd.org + ftp1.de.freebsd.org ftp2.de.freebsd.org ftp4.de.freebsd.org + ftp5.de.freebsd.org ftp7.de.freebsd.org ftp8.de.freebsd.org + ftp.gr.freebsd.org ftp2.gr.freebsd.org ftp.hk.freebsd.org + ftp3.ie.freebsd.org ftp.jp.freebsd.org ftp2.jp.freebsd.org + ftp3.jp.freebsd.org ftp4.jp.freebsd.org ftp5.jp.freebsd.org + ftp6.jp.freebsd.org ftp7.jp.freebsd.org ftp8.jp.freebsd.org + ftp9.jp.freebsd.org ftp.kr.freebsd.org ftp2.kr.freebsd.org + ftp.nl.freebsd.org ftp2.nl.freebsd.org ftp.nz.freebsd.org + ftp.no.freebsd.org ftp.pl.freebsd.org ftp.ru.freebsd.org + ftp2.ru.freebsd.org ftp4.ru.freebsd.org ftp5.ru.freebsd.org + ftp6.ru.freebsd.org ftp.si.freebsd.org ftp.za.freebsd.org + ftp2.za.freebsd.org ftp4.za.freebsd.org ftp.es.freebsd.org + ftp3.es.freebsd.org ftp.se.freebsd.org ftp2.se.freebsd.org + ftp.ch.freebsd.org ftp.tw.freebsd.org ftp2.tw.freebsd.org + ftp4.tw.freebsd.org ftp5.tw.freebsd.org ftp.ua.freebsd.org + ftp6.ua.freebsd.org ftp7.ua.freebsd.org ftp.uk.freebsd.org + ftp2.uk.freebsd.org ftp3.uk.freebsd.org ftp4.uk.freebsd.org + ftp5.uk.freebsd.org ftp1.us.freebsd.org ftp2.us.freebsd.org + ftp3.us.freebsd.org ftp4.us.freebsd.org ftp5.us.freebsd.org); + +# TODO: this has to be set on a per-host basis. +# It should probably come from $ho? +our @disk_names = qw(ada0 da0 ad0); + +sub install () { + my $authkeys= authorized_keys(); + my $disk = ""; + my $nic = ""; + my $ftp = ""; + + power_state($ho, 0); + + setup_pxeboot_firstboot(); + + logm('Booting into mfsBSD'); + + sleep(power_cycle_time($ho)); + + power_state($ho, 1); + + logm('Waiting for host to boot'); + await_tcp(get_timeout($ho,'boot',$timeout{Sshd}), 22, $ho); + + logm('Setting host to boot from local disk on next boot'); + setup_pxeboot_local($ho); + + logm('Switching root shell to /bin/sh'); + target_cmd_root_with_password($ho, 'chsh -s /bin/sh', 900, "root"); + + logm('Setting up ssh keys for remote access'); + target_cmd_root_with_password($ho, <<END, 900, "root"); + set -e + mkdir -p ~/.ssh + cat <<ENDKEYS >~/.ssh/authorized_keys +$authkeys +ENDKEYS +END + + foreach my $test_disk (@disk_names) { + logm("Probing for $test_disk existence"); + my $output = target_cmd_output_root($ho, + 'test -c /dev/'.$test_disk.' >/dev/null 2>&1 && echo "yes" || echo "no"', + 200); + if ($output eq "yes") { + logm("Found a valid disk device: $test_disk"); + $disk = $test_disk; + last; + } + } + length($disk) or die "Unable to find a valid disk, exiting"; + + logm("Searching for a mirror"); + foreach my $test_ftp (@ftp_hosts) { + logm("Probing mirror $test_ftp"); + # Test from the target system. + my $output = target_cmd_output_root($ho, + 'nc -zw 10 '.$test_ftp.' 21 >/dev/null 2>&1 && echo "yes" || echo "no"', + 200); + if ($output eq "yes") { + logm("Found a valid mirror: $test_ftp"); + $ftp = $test_ftp; + last; + } + } + length($ftp) or die "Unable to find a valid ftp mirror, exiting"; + + logm('Install of base system using ZFS on root'); + target_cmd_root($ho, <<END,2400); + set -e + gpart destroy -F $disk || true + zfsinstall -d $disk -u ftp://$ftp/pub/FreeBSD/releases/$r{arch}/$version -s 4g +END + + logm('Setting up ssh and keys for the installed system'); + target_cmd_root($ho, <<END, 900); + set -e + echo 'sshd_enable="YES"' >> /mnt/etc/rc.conf + echo 'PermitRootLogin yes' >> /mnt/etc/ssh/sshd_config + mkdir -p /mnt/root/.ssh + cat <<ENDKEYS >/mnt/root/.ssh/authorized_keys +$authkeys +ENDKEYS +END + + logm('Setting up serial console'); + target_cmd_root($ho, <<END, 900); + set -e + printf "%s" "-Dh" >> /mnt/boot.config + cat <<ENDB >>/mnt/boot/loader.conf +boot_multicons="YES" +boot_serial="YES" +comconsole_speed="$c{Baud}" +console="comconsole,vidconsole" +boot_verbose="YES" +ENDB +END + + logm("Trying to figure out primary nic device name"); + $nic = target_cmd_output_root($ho, + 'ifconfig | grep -B3 '.$ho->{Ip}.' | head -n1 | awk \'{print $1}\'|sed s/://', + 200); + length($nic) or die "Unable to find primary network interface"; + + logm("Using $nic as primary nic interface"); + + logm('Setting up network'); + target_cmd_root($ho, <<END, 900); + set -e + echo "net.link.bridge.inherit_mac=1" >> /mnt/boot/loader.conf + echo 'cloned_interfaces="bridge0"' >> /mnt/etc/rc.conf + echo 'ifconfig_bridge0="addm $nic SYNCDHCP"' >> /mnt/etc/rc.conf + echo 'ifconfig_$nic="up"' >> /mnt/etc/rc.conf +END + + logm('Setting up miscellaneous settings'); + target_cmd_root($ho, <<END, 900); + set -e + cp /mnt/usr/share/zoneinfo/Europe/London /mnt/etc/localtime + echo 'sendmail_enable="NONE"' >> /mnt/etc/rc.conf +END + + logm('Copying installer keys into the system'); + target_cmd_root($ho, 'cp /etc/ssh/*_key* /mnt/etc/ssh/', 900); + + logm('Rebooting into the installed system'); + target_reboot($ho); + + logm('Setting root shell to /bin/sh'); + target_cmd_root($ho, 'chsh -s /bin/sh', 900); + logm('Adding osstest user'); + target_cmd_root($ho, 'pw useradd osstest -m', 900); + target_cmd_root($ho, <<END, 900); + set -e + chsh -s /bin/sh osstest + mkdir -p /home/osstest/.ssh + cat <<ENDKEYS >/home/osstest/.ssh/authorized_keys +$authkeys +ENDKEYS +END + + logm('OK: install completed'); +} + +sub setup_pxeboot_firstboot() { + my $mfs= 'freebsd/'.$version.'/'.$r{arch}.'/'.'mfsbsd-'.$version.'-'.$r{arch}.'.img'; + + logm('Using mfsBSD image: ' . $mfs); + + setup_pxeboot($ho, <<END); +serial 0 $c{Baud} +timeout 5 +label overwrite + menu label ^Overwrite + menu default + kernel memdisk + append initrd=$mfs +default overwrite +END +} + +install();
Signature · 7 lines
1.9.3 (Apple Git-50) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v3 3/7 osstest: prepare FreeBSD host for Xen build
In reply to Roger Pau MonneInstall pkg (the binary package management tool) and the dependencies needed to build Xen.
---
Changes since RFC:
- Add the tools necessary in order to build the man pages and markdown documents.
--- ts-xen-build-prep-freebsd | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 ts-xen-build-prep-freebsd
ts-xen-build-prep-freebsd new file +48 -0
@@ -0,0 +1,48 @@ +#!/usr/bin/perl -w +# This is part of "osstest", an automated testing framework for Xen. +# Copyright (C) 2009-2014 Citrix Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +use strict qw(vars); +use DBI; +use POSIX; + +use Osstest; +use Osstest::TestSupport; +use Osstest::Logtailer; + +tsreadconfig(); + +our ($whhost) = @ARGV; +$whhost ||= 'host'; +our $ho= selecthost($whhost); +exit 0 if $ho->{SharedReady}; + +#TODO: should be a runvar +our $compiler = 'gcc47'; +our $deps = "mercurial git bash python bcc glib pkgconf yajl gmake pixman ". + "perl5 markdown bison gettext gawk $compiler"; + +sub install_depends () { + logm('Installing Xen build dependencies'); + target_cmd_root($ho, <<END, 2400); + set -e + export ASSUME_ALWAYS_YES="YES" + pkg install -y $deps + ln -s /usr/local/bin/$compiler /usr/local/bin/gcc +END +} + +install_depends();
Signature · 7 lines
1.9.3 (Apple Git-50) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v3 4/7 osstest: create a new job called build-<arch>-freebsd
In reply to Roger Pau MonneThis job is very similar to build-<arch> but it doesn't enable ovmf because it doesn't compile on FreeBSD yet.
--- mfi-common | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
mfi-common +14 -0
@@ -153,6 +153,20 @@ create_build_jobs () { revision_qemuu=$REVISION_QEMU_UPSTREAM \ revision_seabios=$REVISION_SEABIOS + ./cs-job-create $flight build-$arch-freebsd build \ + arch=$arch enable_xend=false enable_ovmf=false \ + tree_qemu=$TREE_QEMU \ + tree_qemuu=$TREE_QEMU_UPSTREAM \ + tree_xen=$TREE_XEN \ + tree_seabios=$TREE_SEABIOS \ + $RUNVARS $BUILD_RUNVARS $BUILD_XEN_RUNVARS $arch_runvars \ + $suite_runvars \ + host_hostflags=$build_hostflags \ + revision_xen=$REVISION_XEN \ + revision_qemu=$REVISION_QEMU \ + revision_qemuu=$REVISION_QEMU_UPSTREAM \ + revision_seabios=$REVISION_SEABIOS + if [ $build_extraxend = "true" ] ; then ./cs-job-create $flight build-$arch-xend build \ arch=$arch enable_xend=true enable_ovmf=$enable_ovmf \
Signature · 7 lines
1.9.3 (Apple Git-50) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v3 5/7 osstest: make ts-xen-build work on FreeBSD
In reply to Roger Pau MonneThis patch contains a new subroutine that guesses the right make command to use (gmake on BSDs, make otherwise).
--- ts-xen-build | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
ts-xen-build +12 -1
@@ -28,6 +28,16 @@ selectbuildhost(\@ARGV); # remaining arguments are passed as targets to "make" builddirsprops(); +sub get_make_cmd() { + my $uname = target_cmd_output_root($ho, 'uname -a', 200); + + if ($uname =~ m/BSD/) { + return "gmake"; + } else { + return "make"; + } +} + sub checkout () { prepbuilddirs();
@@ -91,6 +101,7 @@ END } sub build () { + my $make_cmd = get_make_cmd(); my $xend_opt= $r{enable_xend} =~ m/true/ ? "--enable-xend" : "--disable-xend"; my $ovmf_opt= $r{enable_ovmf} =~ m/true/ ? "--enable-ovmf" : "--disable-ovmf";
@@ -112,7 +123,7 @@ END END #/; buildcmd_stamped_logged(9000, 'build', '',<<END,''); - $make_prefix make $makeflags @ARGV + $make_prefix $make_cmd $makeflags @ARGV END }
Signature · 7 lines
1.9.3 (Apple Git-50) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v3 6/7 osstest: add script for building custom mfsBSD images
In reply to Roger Pau MonneIn order to test FreeBSD HEAD we need to build a mfsBSD installer based on the version that we want to test. This patch adds support for building such mfsBSD image, and modifies the previously introduced ts-freebsd-host-install script in order to use those custom mfsBSD images.
In order to build the images sources from two different repositories are needed. The first ones of course are the FreeBSD sources which can be fetched from the official github mirror at:
https://github.com/freebsd/freebsd.git
And the mfsBSD sources which can be downloaded from:
https://github.com/royger/mfsbsd.git
I'm using a custom fork because there's one patch needed for mfsBSD which has not yet been merged into the master repository, once that's done we can switch to:
https://github.com/mmatuska/mfsbsd.git
Anyway, we would need to have a local copy of them in order to have a push gate like we do for Linux, Qemu or SeaBIOS.
The workflow of this would be:
1. Setup a FreeBSD host using a RELEASE image (10.1 right now).
2. Fetch upstream FreeBSD sources and compile a fresh FreeBSD world + kernel.
3. Generate a mfsBSD image using the output from the FreeBSD build process.
4. Upload the mfsBSD image into the TFTP boot directory, the nomenclature
is: freebsd/mfsbsd-{git-hash}-{arch}.img.
5. Upload the install sets generated by the build process to an http server accesible from the test hosts, the following hierarchy is used:
freebsd/{arch}/{git-hash}/
6. Use the newly created mfsBSD image in order to boot and the uploaded install sets with zfsinstall.
--- ts-freebsd-create-mfsbsd | 145 +++++++++++++++++++++++++++++++++++++++++++++++ ts-freebsd-host-install | 54 +----------------- 2 files changed, 148 insertions(+), 51 deletions(-) create mode 100755 ts-freebsd-create-mfsbsd
ts-freebsd-create-mfsbsd new file +145 -0
@@ -0,0 +1,145 @@ +#!/usr/bin/perl -w +# This is part of "osstest", an automated testing framework for Xen. +# Copyright (C) 2009-2014 Citrix Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +use strict qw(vars); +use DBI; +use POSIX; + +use Osstest; +use Osstest::TestSupport; +use Osstest::Logtailer; + +tsreadconfig(); + +our ($whhost) = grep /host=/, @ARGV; +$whhost ||= 'host'; +our $ho= selecthost($whhost); +exit 0 if $ho->{Flags}{'no-reinstall'}; +exit 0 if $ho->{SharedReady}; + +our %timeout= qw(ReadPreseed 350 + Sshd 2400); + +# TODO: this should be runvars +our ($version) = grep /version=/, @ARGV; +$version =~ s/version=//; +logm("Generating mfsBSD image version: $version"); + +our $freebsd_git = "https://github.com/freebsd/freebsd.git"; +our $mfsbsd_git = "https://github.com/royger/mfsbsd.git"; + +our $public_html = "/home/rogerpau/public_html/"; +our $http_folder = "http://cbg-cloud-vm33.xs.citrite.net/~rogerpau/"; + +sub pkg_install { + + logm("Installing git"); + target_cmd_root($ho, <<END, 1000); + set -e + export ASSUME_ALWAYS_YES="YES" + pkg install -y git +END +} + +sub fetch_source { + my ($git_url, $id, $dest) = @_; + + logm("Fetching FreeBSD sources from $git_url"); + # TODO: this needs to be done using build_clone + target_cmd_root($ho, <<END, 4800); + chflags -R noschg $dest/* + rm -rf $dest + git clone $git_url $dest + cd $dest + git checkout $id +END +} + +sub build_freebsd { + my ($dest) = @_; + + logm("Building FreeBSD wold"); + target_cmd_root($ho, <<END, 4800); + set -e + cd $dest + make -j12 buildworld +END + + logm("Building FreeBSD kernel"); + target_cmd_root($ho, <<END, 2400); + set -e + cd $dest + make -j12 buildkernel +END + + logm("Packing release files"); + target_cmd_root($ho, <<END, 2400); + set -e + cd $dest/release + make ftp +END +} + +sub build_mfsbsd { + my ($freebsd_dest, $mfsbsd_dest, $id) = @_; + + target_cmd_root($ho, <<END, 900); + set -e + cd $mfsbsd_dest + printf "%s" "-Dh" > conf/boot.config + cp conf/loader.conf.sample conf/loader.conf + cp conf/ttys.sample conf/ttys + sed -i .bak 's/std.[^"]*/std.$c{Baud}/' conf/ttys + cat <<ENDB >> conf/loader.conf +mfsbsd.rootpw="root" +boot_multicons="YES" +boot_serial="YES" +comconsole_speed="$c{Baud}" +console="comconsole,vidconsole" +boot_verbose="YES" +ENDB +END + + target_cmd_root($ho, <<END, 2400); + cd $mfsbsd_dest + make BASE=$freebsd_dest/release/ftp RELEASE=$id PKG_STATIC=`which pkg-static` +END +} + +sub copy_sets { + my ($freebsd_dir, $mfsbsd_dir, $id) = @_; + + target_getfile_root($ho, 2400, "$mfsbsd_dir/mfsbsd-$id-$r{arch}.img", + "$ho->{Tftp}{Path}/freebsd/mfsbsd-$id-$r{arch}.img"); + + ensuredir("$public_html/freebsd/$r{arch}/$id/"); + target_getfile_root($ho, 2400, "$freebsd_dir/release/ftp/kernel.txz", + "$public_html/freebsd/$r{arch}/$id/kernel.txz"); + target_getfile_root($ho, 2400, "$freebsd_dir/release/ftp/base.txz", + "$public_html/freebsd/$r{arch}/$id/base.txz"); + target_getfile_root($ho, 2400, "$freebsd_dir/release/ftp/MANIFEST", + "$public_html/freebsd/$r{arch}/$id/MANIFEST"); + +} + +pkg_install(); + +fetch_source($freebsd_git, $version, "/root/freebsd"); +build_freebsd("/root/freebsd"); +fetch_source($mfsbsd_git, "HEAD", "/root/mfsbsd"); +build_mfsbsd("/root/freebsd", "/root/mfsbsd", $version); +copy_sets("/root/freebsd", "/root/mfsbsd", $version);
ts-freebsd-host-install +3 -51
76 lines not on this page · raw message
Signature · 7 lines
1.9.3 (Apple Git-50) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v3 7/7 osstest: add a script to install Xen on FreeBSD hosts
In reply to Roger Pau MonneThis scripts takes care of installing the run-time dependencies, unpacking the Xen files and setup the right configuration in order to boot a FreeBSD PVH Dom0.
--- ts-xen-install-freebsd | 128 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 ts-xen-install-freebsd
ts-xen-install-freebsd new file +128 -0
@@ -0,0 +1,128 @@ +#!/usr/bin/perl -w +# This is part of "osstest", an automated testing framework for Xen. +# Copyright (C) 2009-2015 Citrix Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +use strict qw(vars); +use DBI; +use Osstest; +use POSIX; +use Osstest::TestSupport; + +my $checkmode= 0; + +tsreadconfig(); + +our @hos; + +if (@ARGV and $ARGV[0] eq '--check') { + $checkmode= 1; + shift @ARGV; + logm("checking builds are done..."); +} else { + if (!@ARGV) { + push @ARGV, 'host'; + } + foreach my $k (@ARGV) { + push @hos, selecthost($k); + } +} + +our $ho; + +my %distpath; + +our $run_deps = "yajl python curl glib gettext pixman libiconv"; + +sub packages () { + logm('Installing Xen runtime dependencies'); +target_cmd_root($ho, <<END, 2400); + set -e + export ASSUME_ALWAYS_YES="YES" + pkg install -y $run_deps +END +} + +sub extract () { + my @parts = ('', 'xen'); + + foreach my $part (@parts) { + target_extract_jobdistpath($ho, $part, "path_${part}dist", + $r{"${part}buildjob"}, \%distpath); + } + target_cmd_root($ho, 'gunzip -c `readlink -f /boot/xen.gz` > /boot/xen', 100); +} + +sub adjustconfig () { + target_cmd_root($ho, <<END, 100); + set -e + mkdir -p /usr/local/etc/rc.conf.d + echo 'XENCONSOLED_TRACE=guest' >> /usr/local/etc/rc.conf.d/xencommons + mkdir -p /var/log/xen/console + mkdir -p /var/lock + mkdir -p /var/run/xen + echo 'vm.max_wired=-1' >> /etc/sysctl.conf + echo 'xc0 "/usr/libexec/getty Pc" xterm on secure' >> /etc/ttys + echo 'xencommons_enable="YES"' >> /etc/rc.conf +END +} + +sub setupboot () { + my $xenhopt = "dom0pvh=1"; + + my $cons= get_host_property($ho, 'XenSerialConsole', 'com1'); + + if ( $cons eq "com1" ) { + $xenhopt .= " com1=$c{Baud},8n1 console=com1,vga gdb=com1"; + } elsif ( $cons eq "dtuart" ) { + $xenhopt .= " console=dtuart"; + my $dtuart= get_host_property($ho, 'XenDTUARTPath', undef); + $xenhopt .= " dtuart=$dtuart" if $dtuart; + } else { + logm("No Xen console device defined for host"); + } + if (toolstack()->{Dom0MemFixed}) { + $xenhopt .= " dom0_mem=2048M,max:2048M"; + } + my $append= $r{xen_boot_append}; + $xenhopt .= " $append" if defined $append; + $append = get_host_property($ho, 'xen-commandline-append', undef); + $xenhopt .= " $append" if defined $append; + + die "pci-passthrough is not supported" if host_involves_pcipassthrough($ho); + + target_cmd_root($ho, <<END, 100); + set -e + cat <<ENDB >>/boot/loader.conf +vfs.zfs.arc_max="1G" +xen_cmdline="$xenhopt" +xen_kernel="/boot/xen" +ENDB +END + + logm("ready to boot Xen"); +} + +if ($checkmode) { + extract(); +} else { + die if @hos > 1; + $ho= $hos[0]; + + packages(); + extract(); + adjustconfig(); + setupboot(); +}
Signature · 7 lines
1.9.3 (Apple Git-50) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel