Skip to contentSkip to conversation

osstest: initial FreeBSD support

PATCH Superseded Roger Pau Monne 2 participants 44 messages Jul 6, 2017 – Jul 7, 2017

v4 of 17 Superseded Latest is v17 →

lore
Share & tools
lore
#0 lore raw

v4 cover osstest: initial FreeBSD support

Hello,

This series introduces initial FreeBSD host support to osstest. The current series allow installing a bare-metal host with FreeBSD and building FreeBSD on it in order to generate new install media that can be fed into the installer script.

This is still very limited, since no Xen testing is done on those hosts, however it sets the base to add a Xen build test for FreeBSD.

Note that it should be quite easy to add more steps to the build script so that FreeBSD VM images are also generated, that could be used by osstest.

I've tried to add a detailed commit log at each relevant patch, so not much more to add here in the cover letter.

The series can also be found on my git repo:

git://xenbits.xen.org/people/royger/osstest.git freebsd_v4

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#1 lore raw

PATCH v4 1/16 osstest: make built_stash_file store a path_ runvar for each file

And introduce built_stash_debugfile in order the keep the previous behavior of built_stash_file.

---
 Osstest/TestSupport.pm | 14 ++++++++++++--
 ts-kernel-build        |  4 ++--
 ts-xen-build           |  8 ++++----
 3 files changed, 18 insertions(+), 8 deletions(-)
Osstest/TestSupport.pm +12 -2
index 6e19b28a..83f24005 100644
@@ -85,7 +85,7 @@ BEGIN {
                       get_stashed open_unique_stashfile compress_stashed
                       dir_identify_vcs
                       build_url_vcs build_clone
-                      built_stash built_stash_file
+                      built_stash built_stash_file built_stash_debugfile
                       built_compress_stashed
                       hg_dir_revision git_dir_revision vcs_dir_revision
                       store_revision store_vcs_revision
@@ -1495,7 +1495,7 @@ END
     store_runvar("path_$item", $stashleaf);
 }
 
-sub built_stash_file ($$$$;$) {
+sub built_stash_debugfile ($$$$;$) {
     my ($ho, $builddir, $item, $fname, $optional) = @_;
     my $build= "build";
     my $stashleaf= "$build/$item";
@@ -1508,6 +1508,16 @@ sub built_stash_file ($$$$;$) {
                    "$stash/$stashleaf");
 }
 
+sub built_stash_file ($$$$;$) {
+    my ($ho, $builddir, $item, $fname, $optional) = @_;
+    my $build= "build";
+    my $stashleaf= "$build/$item";
+
+    built_stash_debugfile($ho, $builddir, $item, $fname, $optional);
+    store_runvar("path_$item", $stashleaf);
+}
+
+
 sub built_compress_stashed($) {
     my ($path) = @_;
     compress_stashed("build/$path");
ts-kernel-build +2 -2
index 94e67a47..5b87f5a7 100755
@@ -438,9 +438,9 @@ if ($r{tree_linuxfirmware}) {
     fwinstall();
 }
 built_stash($ho, $builddir, 'dist', 'kerndist');
-built_stash_file($ho, $builddir, 'vmlinux', 'linux/vmlinux');
+built_stash_debugfile($ho, $builddir, 'vmlinux', 'linux/vmlinux');
 built_compress_stashed('vmlinux');
-built_stash_file($ho, $builddir, 'config', 'linux/.config');
+built_stash_debugfile($ho, $builddir, 'config', 'linux/.config');
 
 sub enable_xen_config () {
     return <<'END';
ts-xen-build +4 -4
index 097ac0a5..3a4bcfa3 100755
@@ -232,10 +232,10 @@ sub stash () {
     }
     built_stash($ho, $builddir, "xen/dist/xenlpt", "xenlptdist")
 	if $enable_livepatch;
-    built_stash_file($ho, $builddir, "xen-syms", "xen/xen/xen-syms", 1);
-    built_stash_file($ho, $builddir, "xen-config", "xen/.config", 1);
-    built_stash_file($ho, $builddir, "xen-hv-config", "xen/xen/.config", 1);
-    built_stash_file($ho, $builddir, "seabios-config",
+    built_stash_debugfile($ho, $builddir, "xen-syms", "xen/xen/xen-syms", 1);
+    built_stash_debugfile($ho, $builddir, "xen-config", "xen/.config", 1);
+    built_stash_debugfile($ho, $builddir, "xen-hv-config", "xen/xen/.config", 1);
+    built_stash_debugfile($ho, $builddir, "seabios-config",
 		     "xen/tools/firmware/seabios-dir-remote/.config", 1);
     built_compress_stashed("xen-syms");
 }
Signature · 7 lines
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#2 lore raw

PATCH v4 2/16 osstest: move known_hosts generation to TestSupport

In reply to Roger Pau Monne

This is equivalent to the already existing authorized_keys function, and generates the contents of the known_hosts file that should be installed on targets.

---
 Osstest/Debian.pm      | 36 +-----------------------------------
 Osstest/TestSupport.pm | 41 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 41 insertions(+), 36 deletions(-)
Osstest/Debian.pm +1 -35
index 845027a3..f3e7582b 100644
@@ -714,41 +714,7 @@ sub preseed_ssh ($$) {
     my ($ho,$sfx) = @_;
 
     my $authkeys_url= create_webfile($ho, "authkeys$sfx", authorized_keys());
-
-    my $hostkeyfile= "$c{OverlayLocal}/etc/ssh/ssh_host_rsa_key.pub";
-    my $hostkey= get_filecontents($hostkeyfile);
-    chomp($hostkey); $hostkey.="\n";
-    my $knownhosts= '';
-
-    my $hostsq= $dbh_tests->prepare(<<END);
-        SELECT val FROM runvars
-         WHERE flight=? AND name LIKE '%host'
-         GROUP BY val
-END
-    $hostsq->execute($flight);
-    while (my ($node) = $hostsq->fetchrow_array()) {
-        my $defaultfqdn = $node;
-        $defaultfqdn .= ".$c{TestHostDomain}" unless $defaultfqdn =~ m/\./;
-
-        my %props;
-        $mhostdb->get_properties($node, \%props);
-
-        my $longname= $props{Fqdn} // $defaultfqdn;
-        my (@hostent)= gethostbyname($longname);
-        if (!@hostent) {
-            logm("skipping host key for nonexistent host $longname");
-            next;
-        }
-        my $specs= join ',', $longname, $node, map {
-            join '.', unpack 'W4', $_;
-        } @hostent[4..$#hostent];
-        logm("adding host key for $specs");
-        $knownhosts.= "$specs ".$hostkey;
-    }
-    $hostsq->finish();
-
-    $knownhosts.= "localhost,127.0.0.1 ".$hostkey;
-    my $knownhosts_url= create_webfile($ho, "known_hosts$sfx", $knownhosts);
+    my $knownhosts_url= create_webfile($ho, "known_hosts$sfx", known_hosts());
 
     preseed_hook_command($ho, 'late_command', $sfx, <<END);
 #!/bin/sh
Osstest/TestSupport.pm +40 -1

53 lines not on this page · raw message

Signature · 7 lines
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#3 lore raw

PATCH v4 3/16 osstest: introduce helper to get per-host tftp prefix

In reply to Roger Pau Monne

This is used in order to get the per-host tftp prefix, used to store the host initrd file.

---
Changes since v1:
- New in this version.

---
 Osstest/TestSupport.pm | 8 +++++++-
 ts-host-install        | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)
Osstest/TestSupport.pm +7 -1
index 88606b04..e30e5759 100644
@@ -69,7 +69,7 @@ BEGIN {
                       target_run_apt
                       target_install_packages target_install_packages_norec
                       target_jobdir target_extract_jobdistpath_subdir
-                      target_extract_jobdistpath
+                      target_extract_jobdistpath target_tftp_prefix
                       lv_create lv_dev_mapper
 
                       poll_loop tcpconnect await_tcp
@@ -2337,6 +2337,12 @@ sub target_extract_jobdistpath ($$$$$) {
     target_cmd_root($ho, "cd / && tar -hzxf $distcopy", 300);
 }
 
+sub target_tftp_prefix ($) {
+    my ($ho) = @_;
+
+    return "$ho->{Tftp}{TmpDir}/" . hostnamepath($ho);
+}
+
 sub guest_find_domid ($$) {
     my ($ho,$gho) = @_;
     return if defined $gho->{Domid};
ts-host-install +1 -1
index 299eae48..9f9c84fd 100755
@@ -253,7 +253,7 @@ END
     push @initrds, "$initrd_overlay.cpio.gz";
 
     logm("using initrds: @initrds");
-    my $initrd= "$ho->{Tftp}{TmpDir}".hostnamepath($ho)."--initrd.gz";
+    my $initrd= target_tftp_prefix($ho) . "--initrd.gz";
     system_checked("cat -- @initrds >$ho->{Tftp}{Path}$initrd");
     
     push @dicmdline, "domain=$c{TestHostDomain}";
Signature · 7 lines
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#4 lore raw

PATCH v4 4/16 osstest: introduce a helper to calculate the sha256 of a given file

In reply to Roger Pau Monne

The helper is going to be used to calculate the sha256 of the FreeBSD installer images.

---
Changes since v3:
- New in this version.

---
 Osstest/TestSupport.pm | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Osstest/TestSupport.pm +13 -0
index e30e5759..12ebc32d 100644
@@ -32,6 +32,7 @@ use File::Copy;
 use File::Basename;
 use IO::Handle;
 use Carp;
+use Digest::SHA;
 
 BEGIN {
     use Exporter ();
@@ -132,6 +133,7 @@ BEGIN {
                       guest_editconfig_nocd
                       host_install_postboot_complete
                       target_core_dump_setup
+                      sha256file
                       );
     %EXPORT_TAGS = ( );
 
@@ -2769,4 +2771,15 @@ sub target_https_mitm_proxy_setup ($) {
     target_cmd_root($ho, 'update-ca-certificates', 300);
 }
 
+sub sha256file ($;$) {
+    my ($file,$truncate) = @_;
+    my $sha = Digest::SHA->new(256);
+    my $digest;
+
+    $sha->addfile($file);
+    $digest = $sha->hexdigest;
+
+    return $truncate ? substr($digest, 0, $truncate) : $digest;
+}
+
 1;
Signature · 7 lines
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Acked-by on v4 4/16
#5 lore raw

Re: [PATCH v4 04/16] osstest: introduce a helper to calculate the sha256 of a given file

Roger Pau Monne writes ("[PATCH v4 04/16] osstest: introduce a helper to calculate the sha256 of a given file"):

Quoted 4 lines

The helper is going to be used to calculate the sha256 of the FreeBSD installer images.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#6 lore raw

PATCH v4 5/16 osstest: introduce a helper to setup a host to boot using memdisk

In reply to Roger Pau Monne

The helper allows booting a host from pxelinux using an image compatible with memdisk.

Note that this requires having a copy of the memdisk binary (provided as part of pxelinux) in the root of the tftp server.

---
Changes since v3:
- New in this version (split from install patch).

---
 Osstest/TestSupport.pm | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
Osstest/TestSupport.pm +21 -1
index 12ebc32d..66790575 100644
@@ -122,7 +122,7 @@ BEGIN {
                       await_webspace_fetch_byleaf create_webfile
                       file_link_contents get_timeout
                       setup_netboot_di setup_netboot_local host_netboot_file
-		      subst_netboot_template
+                      subst_netboot_template setup_netboot_memdisk
 
                       ether_prefix
 
@@ -2629,6 +2629,26 @@ default local
 END
 }
 
+sub setup_netboot_memdisk ($$) {
+    my ($ho, $img) = @_;
+    setup_netboot_bootcfg($ho, <<END);
+serial 0 $c{Baud}
+timeout 5
+label overwrite
+        menu label ^Overwrite
+        menu default
+        kernel memdisk
+        initrd $img
+        # NB: according to the memdisk syslinux wikipage [0]
+        # adding "append raw" is required in order to boot on
+        # some boxes, and in fact some hardware will not boot
+        # without it.
+        # [0] http://www.syslinux.org/wiki/index.php?title=MEMDISK#Memory_access_method
+        append raw
+default overwrite
+END
+}
+
 # uboot emulates pxelinux, so reuse BIOS stuff
 sub setup_netboot_di_uboot ($$$$$;%) { return &setup_netboot_di_bios; }
 sub setup_netboot_local_uboot ($) { return &setup_netboot_local_bios; }
Signature · 7 lines
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Acked-by on v4 5/16
#7 lore raw

Re: [PATCH v4 05/16] osstest: introduce a helper to setup a host to boot using memdisk

Roger Pau Monne writes ("[PATCH v4 05/16] osstest: introduce a helper to setup a host to boot using memdisk"):

Quoted 5 lines

The helper allows booting a host from pxelinux using an image compatible with memdisk.

Note that this requires having a copy of the memdisk binary (provided as part of pxelinux) in the root of the tftp server.

Can you provide specific instructions ? Something like this:

Deployment note: A copy of the memdisk binary (from pxelinux) must be placed in the root of the tftp server. Eg:
ln -s /usr/lib/w3ossbnam,e/pxe/memdisk /tftp/root/

With suitable paths,

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#8 lore raw

PATCH v4 6/16 osstest: add a FreeBSD host install recipe

In reply to Roger Pau Monne

The installation is performed using the bsdinstall tool, which is part of the FreeBSD base system. The installer image is setup with the osstest ssh keys and sshd enabled by default, which allows the test harness to just ssh into the box, create the install config file and launch the scripted install.

Currently the installation is done with ZFS only, in stripe mode, and a single disk.

In order to support the FreeBSD installer the setup_netboot_memdisk helper is used, that allows setting the pxe boot of a host using a memdisk.

The install script either picks the binary images from the output of a previous FreeBSD buildjob (yet to be introduced), or from the folder pointed by freebsd_distpath. This folder should contain the installer image (install.img) and the compressed install sets (kernel.txz, base.txz) together with the MANIFEST file that contains the checksums.

---
Changes since v3:
- Use sha256file instead of the sha256sum clu.
- Shift parameters passed to the lock and copy script, so that parameter 0 is ignored.
- Copy to .tmp and then move the FreeBSD image.
- Use a single-line find rune to cleanup old images.
- Add some missing "set -e".
- Don't check the output of target_cmd_output_root against undefined, that's never going to be true.
- Split the setup_netboot_memdisk helper code into a pre-patch.

Changes since v2:
- Use sysrc instead of echo to modify rc.conf.

Changes since v1:
- Use pkg bootstrap instead of pkg update.
- Use freebsdbuildjob instead of freebsd_buildjob.
- add "append raw" to the memdisk command line.
- Use with-lock-ex instead of flock.
- Use system_checked and an array to hold the locked command to execute.
- Use an array to store the list of possible disk devices.
- Use target_putfilecontents_root_stash in order to upload the install script to the target.
- Remove the usage of TftpFreeBSDBase.
- Use target_tftp_prefix in order to get the prefix for the tftp target image path.
- Add a missing linewrap.
- Replace the split used to get the runvar paths with a regexp.
- Place the install sets at /root/osstest_sets instead of /tmp/osstest_sets.
- Pick the sets/installer image from the freebsdbuildjob path_freebsdist or from the runvar variable freebsd_distpath.
- Add a comment about which FreeBSD specific inputs the script consumes.

---
 ts-freebsd-host-install | 266 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 266 insertions(+)
 create mode 100755 ts-freebsd-host-install
ts-freebsd-host-install new file +266 -0
new file mode 100755
index 00000000..fcc185c8
@@ -0,0 +1,266 @@
+#!/usr/bin/perl -w
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2017 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/>.
+
+# The FreeBSD installer script consumes either one of the following
+# runvars:
+#
+# freebsd_distpath: points to a folder accessible by the controller that
+# should contain the installer image and the compressed install sets,
+# together with the MANIFEST file.
+#
+# freebsdbuildjob: points to a previous FreeBSD build job, that has
+# produced an installer image and compressed sets. The only runvar used
+# form the job pointed to by freebsdbuildjob is the path_freebsddist one,
+# that points to the folder containing the files described above.
+#
+# The installer image must be named 'install.img', and the sets
+# 'kernel.txz', 'base.txz' and finally the 'MANIFEST' file that contains
+# the checksums.
+
+use strict qw(vars);
+use DBI;
+use POSIX;
+
+unshift @INC, qw(.);
+use Osstest;
+use Osstest::TestSupport;
+
+tsreadconfig();
+
+our %xopts;
+
+our ($whhost) = @ARGV;
+$whhost ||= 'host';
+our $ho= selecthost($whhost);
+exit 0 if $ho->{Flags}{'no-reinstall'};
+exit 0 if $ho->{SharedReady};
+
+our $timeout = 1000;
+
+our @sets = qw(base.txz kernel.txz);
+
+our $path_prefix = $r{"freebsd_distpath"} ||
+                   get_stashed("path_freebsddist", $r{"freebsdbuildjob"});
+
+sub get_sets_path () {
+    my @paths;
+
+    foreach my $set (@sets, "MANIFEST") {
+        push @paths, { name => "$set", path => "$path_prefix/$set" };
+    }
+
+    return @paths;
+}
+
+sub create_ssh_overlay () {
+    my $url = create_webfile($ho, "ssh.tar", sub {
+        my ($fh) = @_;
+        contents_make_cpio($fh, 'ustar',  "$c{OverlayLocal}/etc/ssh/");
+    });
+
+    return $url;
+}
+
+sub setup_netboot_installer () {
+    my $image = "$path_prefix/install.img";
+    my $pxeimg = target_tftp_prefix($ho) . "--freebsd.img";
+    my $hash = sha256file($image, 16);
+    my $tftp_freebsd = "$ho->{Tftp}{Path}/$ho->{Tftp}{TmpDir}/freebsd-images/";
+    my $script = <<'END';
+basedir=$1
+imagepath=$2
+sharedpath=$3
+targetpath=$4
+cd $basedir
+mkdir -p `dirname $sharedpath`
+if [ ! -f $sharedpath ]; then
+    cp $imagepath $sharedpath.tmp
+    mv $sharedpath.tmp $sharedpath
+fi
+rm -f $targetpath
+ln $sharedpath $targetpath
+# Prune old images not used anymore
+find `dirname $sharedpath` -links 1 -ctime +7 -delete
+END
+    my @cmd = ( "with-lock-ex", "-w", "$tftp_freebsd/lock",
+                "bash", "-exc", "$script", "x",
+                "$tftp_freebsd", "$image", "by-hash/$hash.img",
+                "$ho->{Tftp}{Path}/$pxeimg" );
+
+    ensuredir($tftp_freebsd);
+    system_checked(@cmd);
+
+    # Setup the pxelinux config file
+    logm("Booting from installer image at $pxeimg");
+    setup_netboot_memdisk($ho, $pxeimg);
+}
+
+sub install () {
+    my $authkeys = authorized_keys();
+    my $knownhosts = known_hosts();
+    my $sshd_keys_url = create_ssh_overlay();
+    my @disk_names = qw(ada0 da0 ad0);
+    my $target_sets = "/root/osstest_sets";
+    my $disk;
+    my $nic;
+
+    target_cmd_root($ho, 'chsh -s /bin/sh', 10);
+
+    logm("Trying to find a disk to install to");
+    $disk = target_cmd_output_root($ho, <<END, 30);
+set -e
+for disk in @disk_names; do
+    if [ -c "/dev/\$disk" ]; then
+        echo \$disk
+        exit 0
+    fi
+done
+exit 1
+END
+    logm("Using $disk as destination disk device");
+
+    logm("Trying to figure out primary nic device name");
+    $nic = target_cmd_output_root($ho, <<END, 30);
+set -e
+nics=`ifconfig -l`
+for nic in \$nics; do
+    addr=`ifconfig \$nic inet|grep inet|awk {'print \$2'}`
+    if [ "\$addr" = "$ho->{Ip}" ]; then
+        echo \$nic
+        exit 0
+    fi
+done
+exit 1
+END
+    logm("Using $nic as primary network interface");
+
+    logm("Uploading the install sets to the system");
+    target_cmd_root($ho, <<END, 30);
+set -e
+mkdir -p $target_sets
+mount -o size=1G -t tmpfs tmpfs $target_sets
+END
+
+    foreach (get_sets_path()) {
+        target_putfile_root($ho, 600, $_->{path},
+                            "$target_sets/$_->{name}");
+    }
+
+    logm("Creating the installer script");
+    target_putfilecontents_root_stash($ho, 10, <<END, '~/installscript');
+set -a
+BSDINSTALL_DISTDIR="$target_sets"
+ZFSBOOT_DISKS="$disk"
+DISTRIBUTIONS="@sets"
+nonInteractive=1
+
+#!/bin/sh
+set -ex
+
+# Setup nic and sshd
+sysrc ifconfig_$nic=DHCP
+sysrc sshd_enable=YES
+
+# Use syncronious DHCP in case the server is slow
+sysrc synchronous_dhclient=YES
+
+# Disable sendmail
+sysrc sendmail_enable=NO
+sysrc sendmail_submit_enable=NO
+sysrc sendmail_outbound_enable=NO
+sysrc sendmail_msp_queue_enable=NO
+
+# Set proxy for the pkg manager
+mkdir -p /usr/local/etc/
+cat << ENDPKG >> /usr/local/etc/pkg.conf
+pkg_env: { http_proxy = $c{HttpProxy} }
+default_always_yes: true
+assume_always_yes: true
+ENDPKG
+
+# Bootstap the package manager
+export HTTP_PROXY=$c{HttpProxy}
+export ASSUME_ALWAYS_YES=yes
+pkg bootstrap
+
+# Allow root user login and setup ssh keys
+chsh -s /bin/sh root
+echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
+mkdir -p /root/.ssh
+cat << ENDKEYS > /root/.ssh/authorized_keys
+$authkeys
+ENDKEYS
+cat << ENDHOSTS > /root/.ssh/known_hosts
+$knownhosts
+ENDHOSTS
+
+# Fetch host keys
+fetch $sshd_keys_url -o - | tar -xf - -C /etc/ssh/
+# Set correct permissions
+chown root:wheel /etc/ssh/ssh_host_*_key*
+chmod 0600 /etc/ssh/ssh_host_*_key
+chmod 0644 /etc/ssh/ssh_host_*_key.pub
+
+# Add a osstest user
+pw useradd osstest -m
+chsh -s /bin/sh osstest
+mkdir -p /home/osstest/.ssh
+cat << ENDKEYS > /home/osstest/.ssh/authorized_keys
+$authkeys
+ENDKEYS
+cat << ENDHOSTS > /home/osstest/.ssh/known_hosts
+$knownhosts
+ENDHOSTS
+
+# Setup serial console
+printf "%s" "-h -S$c{Baud}" >> /boot.config
+cat << ENDBOOT >> /boot/loader.conf
+boot_serial="YES"
+comconsole_speed="$c{Baud}"
+console="comconsole"
+boot_verbose="YES"
+beastie_disable="YES"
+ENDBOOT
+END
+
+    logm("Launch the installer");
+    target_cmd_root($ho, 'bsdinstall script installscript', 1200);
+
+    target_reboot($ho);
+
+    logm("Waiting for the host to boot");
+    await_tcp(get_timeout($ho,'reboot',$timeout), 5, $ho);
+
+    logm("FreeBSD installed succesfully");
+}
+
+# Switch off, setup PXE and switch on to the installer
+power_state($ho, 0);
+setup_netboot_installer();
+power_cycle_sleep($ho);
+power_state($ho, 1);
+
+# Wait for the host to finish booting
+logm("Waiting for the installer to boot");
+await_tcp(get_timeout($ho,'reboot',$timeout), 5, $ho);
+
+# Next boot will be from local disk
+setup_netboot_local($ho);
+
+# Proceed with the install
+install();
+
Signature · 7 lines
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#9 lore raw

Re: [PATCH v4 06/16] osstest: add a FreeBSD host install recipe

Roger Pau Monne writes ("[PATCH v4 06/16] osstest: add a FreeBSD host install recipe"):

Quoted 5 lines

The installation is performed using the bsdinstall tool, which is part of the FreeBSD base system. The installer image is setup with the osstest ssh keys and sshd enabled by default, which allows the test harness to just ssh into the box, create the install config file and launch the scripted install.

...

ts-freebsd-host-install line 44

Quoted 8 lines
ts-freebsd-host-install new file +3 -0
new file mode 100755
index 00000000..fcc185c8
+tsreadconfig();
+
+our %xopts;

This variable seems never to be used.

ts-freebsd-host-install line 67

Quoted 12 lines
ts-freebsd-host-install new file +12 -0
+our $path_prefix = $r{"freebsd_distpath"} ||
+                   get_stashed("path_freebsddist", $r{"freebsdbuildjob"});
+
+sub get_sets_path () {
+    my @paths;
+
+    foreach my $set (@sets, "MANIFEST") {
+        push @paths, { name => "$set", path => "$path_prefix/$set" };
+    }
+
+    return @paths;
+}

You might want to consider abolishing this function (which has one call site) and simply transferring the "$path_prefix/$set" (which is the only knowledge that this function provides) to the call site.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#10 lore raw

Re: [PATCH v4 06/16] osstest: add a FreeBSD host install recipe

In reply to Roger Pau Monne

Roger Pau Monne writes ("[PATCH v4 06/16] osstest: add a FreeBSD host install recipe"):

Quoted 5 lines

The installation is performed using the bsdinstall tool, which is part of the FreeBSD base system. The installer image is setup with the osstest ssh keys and sshd enabled by default, which allows the test harness to just ssh into the box, create the install config file and launch the scripted install.

Oh, also this says it introduces a recipe, but it contains only a script.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#11 lore raw

PATCH v4 7/16 osstest: introduce build helpers for FreeBSD

In reply to Roger Pau Monne

Some steps of the FreeBSD build process need to be done as root, so introduce some helpers to perform those steps:
buildcmd_stamped_logged_root and target_cmd_build_root. They behave exactly the same as the non-root counterparts.

---
Changes since v3:
- New in this version.

---
 Osstest/BuildSupport.pm | 26 ++++++++++++++++++++++----
 Osstest/TestSupport.pm  | 27 +++++++++++++++++++++++----
 2 files changed, 45 insertions(+), 8 deletions(-)
Osstest/BuildSupport.pm +22 -4
index 4c2b658b..b96ce766 100644
@@ -36,7 +36,7 @@ BEGIN {
                       $whhost $ho
 
                       builddirsprops
-                      buildcmd_stamped_logged
+                      buildcmd_stamped_logged buildcmd_stamped_logged_root
                       $builddir $makeflags
 		      $buildcmd_global_prefix
 
@@ -60,9 +60,9 @@ our ($xendist);
 
 our $buildcmd_global_prefix //= '';
 
-sub buildcmd_stamped_logged ($$$$$$) {
-    my ($timeout, $component, $stampname, $prefix, $cmd, $suffix) = @_;
-    target_cmd_build($ho, $timeout, $builddir, <<END);
+sub buildcmd_stamped_logged_script ($$$$$) {
+    my ($component, $stampname, $prefix, $cmd, $suffix) = @_;
+    my $script = <<END;
         cd $component
         $buildcmd_global_prefix
         $prefix
@@ -73,6 +73,24 @@ sub buildcmd_stamped_logged ($$$$$$) {
         echo ok.
 END
 #/;
+
+    return $script;
+}
+
+sub buildcmd_stamped_logged_root ($$$$$$) {
+    my ($timeout, $component, $stampname, $prefix, $cmd, $suffix) = @_;
+    my $script = buildcmd_stamped_logged_script($component, $stampname,
+                                                $prefix, $cmd, $suffix);
+
+    target_cmd_build_root($ho, $timeout, $builddir, $script);
+}
+
+sub buildcmd_stamped_logged ($$$$$$) {
+    my ($timeout, $component, $stampname, $prefix, $cmd, $suffix) = @_;
+    my $script = buildcmd_stamped_logged_script($component, $stampname,
+                                                $prefix, $cmd, $suffix);
+
+    target_cmd_build($ho, $timeout, $builddir, $script);
 }
 
 sub selectbuildhost {
Osstest/TestSupport.pm +23 -4
index 66790575..5a9a6f8b 100644
@@ -56,6 +56,7 @@ BEGIN {
 
                       target_cmd_root_status target_cmd_output_root_status
                       target_cmd_root target_cmd target_cmd_build
+                      target_cmd_build_root
                       target_cmd_output_root target_cmd_output
                       target_cmd_inputfh_root sshuho
                       target_getfile target_getfile_root
@@ -669,8 +670,8 @@ sub target_editfile      ($$$;$$) { teditfileex('osstest',@_); }
     # my ($ho,$rfile, $lleaf,$rdest) = @_;
     #                 ^^^^^^^^^^^^^ optional
 
-sub target_cmd_build ($$$$) {
-    my ($ho,$timeout,$builddir,$script) = @_;
+sub target_cmd_build_script ($$$) {
+    my ($ho, $builddir, $script) = @_;
 
     my $distcc_hosts = get_host_property($ho,'DistccHosts',undef);
     my $distcc = defined($distcc_hosts) ? <<END : "";
@@ -682,8 +683,8 @@ END
 
     my $httpproxy = http_proxy_envsettings($ho);
 
-    target_cmd($ho, <<END.$distcc.<<END.$script, $timeout);
-	set -xe
+    my $cmd = <<END.$distcc.<<END.$script;
+        set -xe
         LC_ALL=C; export LC_ALL
         PATH=/usr/lib/ccache:\$PATH:/usr/lib/git-core
         $httpproxy
@@ -692,6 +693,24 @@ END
         cd $builddir
         rm -f build-ok-stamp
 END
+
+    return $cmd;
+}
+
+sub target_cmd_build ($$$$) {
+    my ($ho,$timeout,$builddir,$script) = @_;
+
+    my $cmd = target_cmd_build_script($ho, $builddir, $script);
+
+    target_cmd($ho, $cmd, $timeout);
+}
+
+sub target_cmd_build_root ($$$$) {
+    my ($ho,$timeout,$builddir,$script) = @_;
+
+    my $cmd = target_cmd_build_script($ho, $builddir, $script);
+
+    target_cmd_root($ho, $cmd, $timeout);
 }
 
 sub target_ping_check_core {
Signature · 7 lines
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Acked-by on v4 7/16
#12 lore raw

Re: [PATCH v4 07/16] osstest: introduce build helpers for FreeBSD

Roger Pau Monne writes ("[PATCH v4 07/16] osstest: introduce build helpers for FreeBSD"):

Quoted 6 lines

Some steps of the FreeBSD build process need to be done as root, so introduce some helpers to perform those steps:
buildcmd_stamped_logged_root and target_cmd_build_root. They behave exactly the same as the non-root counterparts.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#13 lore raw

PATCH v4 8/16 osstest: add support for the FreeBSD package manager

In reply to Roger Pau Monne

FreeBSD support is added to target_install_packages and target_install_packages_norec, although there's no equivalent to the --no-install-recommends in the FreeBSD package manager.

---
Changes since v3:
- New in this version.

---
 Osstest/TestSupport.pm | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
Osstest/TestSupport.pm +19 -2
index 5a9a6f8b..94ace09c 100644
@@ -529,13 +529,30 @@ sub target_run_apt {
         "DEBIAN_PRIORITY=critical UCF_FORCE_CONFFOLD=y \\
             with-lock-ex -w /var/lock/osstest-apt apt-get @aptopts", 3000);
 }
+sub target_run_pkg {
+    my ($ho, @aptopts) = @_;
+    target_cmd_root($ho,"lockf /var/run/osstest-pkg-lock pkg-static @aptopts",
+                    3000);
+}
 sub target_install_packages {
     my ($ho, @packages) = @_;
-    target_run_apt($ho, qw(-y install), @packages);
+    my @hostflags = get_hostflags('host');
+
+    if (grep /^freebsd/i, @hostflags) {
+        target_run_pkg($ho, qw(install), @packages);
+    } else {
+        target_run_apt($ho, qw(-y install), @packages);
+    }
 }
 sub target_install_packages_norec {
     my ($ho, @packages) = @_;
-    target_run_apt($ho, qw(--no-install-recommends -y install), @packages);
+    my @hostflags = get_hostflags('host');
+
+    if (grep /^freebsd/i, @hostflags) {
+        target_run_pkg($ho, qw(install), @packages);
+    } else {
+        target_run_apt($ho, qw(--no-install-recommends -y install), @packages);
+    }
 }
 
 sub target_somefile_getleaf ($$$) {
Signature · 7 lines
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#14 lore raw

Re: [PATCH v4 08/16] osstest: add support for the FreeBSD package manager

Roger Pau Monne writes ("[PATCH v4 08/16] osstest: add support for the FreeBSD package manager"):

Quoted 3 lines

FreeBSD support is added to target_install_packages and target_install_packages_norec, although there's no equivalent to the --no-install-recommends in the FreeBSD package manager.

LGTM, just a couple of quibbles:

Osstest/TestSupport.pm sub target_run_apt { · line 534

Quoted 3 lines
Osstest/TestSupport.pm +3 -0
+sub target_run_pkg {
+    my ($ho, @aptopts) = @_;
+    target_cmd_root($ho,"lockf /var/run/osstest-pkg-lock pkg-static @aptopts",

This line is rather long.

Osstest/TestSupport.pm sub target_run_apt { · line 541

Quoted 7 lines
Osstest/TestSupport.pm +4 -1
+}
 sub target_install_packages {
     my ($ho, @packages) = @_;
-    target_run_apt($ho, qw(-y install), @packages);
+    my @hostflags = get_hostflags('host');
+
+    if (grep /^freebsd/i, @hostflags) {

I would prefer

  +    if (grep /^freebsd\b/i, @hostflags) {
                         ^^

Osstest/TestSupport.pm sub target_run_apt { · line 545

Quoted 4 lines
Osstest/TestSupport.pm +4 -0
+        target_run_pkg($ho, qw(install), @packages);
+    } else {
+        target_run_apt($ho, qw(-y install), @packages);
+    }

Also, target_install_packages and target_install_packages_norec are rather too similar for my taste. If you can think of a better way of doing this please suggest one. If not, then it's tolerable as it is.

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#15 lore raw

Re: [PATCH v4 08/16] osstest: add support for the FreeBSD package manager

Quoted 26 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH v4 08/16] osstest: add support for the FreeBSD package manager"):

Quoted 3 lines

FreeBSD support is added to target_install_packages and target_install_packages_norec, although there's no equivalent to the --no-install-recommends in the FreeBSD package manager.

LGTM, just a couple of quibbles:

Osstest/TestSupport.pm sub target_run_apt { · line 534

Quoted 3 lines
Osstest/TestSupport.pm +3 -0
+sub target_run_pkg {
+    my ($ho, @aptopts) = @_;
+    target_cmd_root($ho,"lockf /var/run/osstest-pkg-lock pkg-static @aptopts",

This line is rather long.

Osstest/TestSupport.pm sub target_run_apt { · line 541

Quoted 7 lines
Osstest/TestSupport.pm +4 -1
+}
 sub target_install_packages {
     my ($ho, @packages) = @_;
-    target_run_apt($ho, qw(-y install), @packages);
+    my @hostflags = get_hostflags('host');
+
+    if (grep /^freebsd/i, @hostflags) {

I would prefer

  +    if (grep /^freebsd\b/i, @hostflags) {
                         ^^
Quoted 8 lines

Osstest/TestSupport.pm sub target_run_apt { · line 545

Quoted 4 lines
Osstest/TestSupport.pm +4 -0
+        target_run_pkg($ho, qw(install), @packages);
+    } else {
+        target_run_apt($ho, qw(-y install), @packages);
+    }

Also, target_install_packages and target_install_packages_norec are rather too similar for my taste. If you can think of a better way of doing this please suggest one. If not, then it's tolerable as it is.

I've changed it to:

sub package_install_cmd {
    my ($norec) = @_;
    my @hostflags = get_hostflags('host');
    my @cmd;

    if (grep /^freebsd\b/i, @hostflags) {
        push @cmd, qw(lockf /var/run/osstest-pkg-lock pkg-static install));
    } else {
        push @cmd, qw(DEBIAN_PRIORITY=critical UCF_FORCE_CONFFOLD=y
                      with-lock-ex -w /var/lock/osstest-apt apt-get);
        if ($norec)
            push @cmd, qw(--no-install-recommends);
        push @cmd, qw(-y install);
    }

    return @cmd;
}
sub target_install_packages {
    my ($ho, @packages) = @_;
    my @cmd = package_install_cmd();

    target_cmd_root($ho,"@cmd @packages", 3000);
}
sub target_install_packages_norec {
    my ($ho, @packages) = @_;
    my @cmd = package_install_cmd(1);

    target_cmd_root($ho,"@cmd @packages", 3000);
}

(will test shortly). Let me know if that looks better.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#16 lore raw

PATCH v4 9/16 osstest: introduce a FreeBSD build script

In reply to Roger Pau Monne

In order to generate the FreeBSD installer image and the install media.

The install sets are the vanilla ones generated by the 'ftp' release target. The installer image is handcrafted based on the filesystem created by the 'bootonly' target, which is then populated with the ssh host keys, and setup in order to use the serial console. The other difference from upstream FreeBSD installer images is that the one built by osstest uses a ramdisk instead of relying on the installer media to be somehow attached, either on a CD or USB drive. This is required in order to boot the image from pxelinux (where no CD or USB is actually attached to the host, and everything is fetched from tftp).

Due to the nature of the FreeBSD build, the outputs are different from what osstest expects from a buildjob, more specifically path_freebsddist points to a folder that contains the several outputs form this buildjob.

---
Changes since v3:
- Introduce two helpers to perform the build process.
- Install packages using target_install_packages.

Changes since v2:
- Increase build target timeouts.
- Use sysrc instead echo to set rc.conf options.

Changes since v1:
- Remove the ts-build-check FreeBSD hack.
- Use pkg-static instead of pkg.
- Introduce buildcmd_stamped_logged_root and target_cmd_build_root.
- Use target_cmd_build_root and buildcmd_stamped_logged_root in the ts-freebsd-build script.
- Fix the script snippets to use <<END.<<'END' in order to avoid escaping the shell variables.
- Set path_freebsddist runvar to point to the folder where the build files are stashed.
- Add a comment at the top of the file describing what runvars are consumed/produced by the build script.

---
 ts-freebsd-build | 245 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 245 insertions(+)
 create mode 100755 ts-freebsd-build
ts-freebsd-build new file +245 -0
new file mode 100755
index 00000000..d64d85f5
@@ -0,0 +1,245 @@
+#!/usr/bin/perl -w
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2017 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/>.
+
+# Consumes the following input runvars:
+#
+# revision_freebsd: FreeBSD commit ID to generate the install media from.
+# tree_freebsd: FreeBSD git tree to fetch the source code from.
+#
+# Produces the following output:
+#
+# Compressed install sets: kernel.txz, base.txz
+# Compressed debug symbols for the kernel: kernel-dbg.txz
+# Manifest file (checkums): MANIFEST
+# Installer image: install.img
+#
+# Sets the following runvar:
+#
+# path_freebsddist: points to the folder where the above files are stored.
+# freebsd_buildversion: version of FreeBSD built.
+
+use strict qw(vars);
+use DBI;
+use POSIX;
+
+unshift @INC, qw(.);
+use Osstest;
+use Osstest::TestSupport;
+use Osstest::BuildSupport;
+
+tsreadconfig();
+
+selectbuildhost(\@ARGV);
+builddirsprops();
+
+sub install_deps () {
+    target_install_packages($ho, 'git');
+}
+
+sub checkout () {
+    prepbuilddirs();
+
+    # Remove the directory as root, there might be files owned by root
+    target_cmd_build_root($ho, 300, $builddir, <<'END');
+# chflags will return error if the directory doesn't exist
+chflags -fR noschg freebsd || true
+rm -rf freebsd
+END
+
+    logm("Checkout the FreeBSD source tree");
+    build_clone($ho, 'freebsd', $builddir, 'freebsd', );
+}
+
+sub build_target($$$) {
+    my ($target, $prefix, $time) = @_;
+
+    buildcmd_stamped_logged($time, 'freebsd', $target,
+                            $prefix, <<END, '');
+make $makeflags $target
+END
+}
+
+sub build_release($$$) {
+    my ($target, $prefix, $time) = @_;
+
+    buildcmd_stamped_logged_root($time, 'freebsd', "release-$target",
+                                 $prefix, <<END, '');
+make -C release $target
+END
+}
+
+sub build () {
+    my $authkeys = authorized_keys();
+    my $target = "bootonly";
+    my $prefix = <<END;
+export MAKEOBJDIRPREFIX=$builddir/obj
+export TARGET=$r{arch}
+END
+
+    # Build process as documented in the handbook:
+    # https://www.freebsd.org/doc/handbook/updating-src.html
+
+    logm("Cleaning up previous builds");
+    build_target('cleanworld', $prefix, 300);
+
+    logm("Building world");
+    build_target('buildworld', $prefix, 25200);
+
+    logm("Building kernel");
+    build_target('buildkernel', $prefix, 3600);
+
+    # NB: the steps below need to be done as root or the permissions
+    # of the files won't be properly set (and the target will fail).
+    logm("Creating the install sets");
+    build_release('ftp', $prefix, 3600);
+
+    logm("Populating the installer image");
+    build_release($target, $prefix, 3600);
+
+    logm("Placing ssh host keys");
+    foreach my $file (<$c{OverlayLocal}/etc/ssh/ssh_host_*_key*>) {
+        target_putfile_root($ho, 30, $file,
+                            "$builddir/freebsd/release/$target/etc/ssh/");
+    }
+
+    logm("Configuring the installer image");
+    target_cmd_build_root($ho, 30, $builddir, <<END.<<'END');
+authkeys="$authkeys"
+bauds="$c{Baud}"
+cd freebsd/release/$target
+END
+# Enable sshd by default
+sysrc -f etc/rc.conf sshd_enable=YES
+
+# Allow root login and copy the keys
+echo 'PermitRootLogin yes' >> etc/ssh/sshd_config
+mkdir -p root/.ssh
+cat << ENDKEYS > root/.ssh/authorized_keys
+$authkeys
+ENDKEYS
+
+# Set host keys permissions
+chown root:wheel etc/ssh/ssh_host_*_key*
+chmod 0600 etc/ssh/ssh_host_*_key
+chmod 0644 etc/ssh/ssh_host_*_key.pub
+
+# Setup serial console output for stage1
+printf "%s" "-h -S$bauds" >> boot.config
+cat << ENDBOOT >> boot/loader.conf
+# Serial console configuration
+boot_serial="YES"
+comconsole_speed="$bauds"
+console="comconsole"
+boot_verbose="YES"
+beastie_disable="YES"
+
+# mfs boot parameters
+mfs_load="YES"
+mfs_type="mfs_root"
+mfs_name="/mfsroot"
+vfs.root.mountfrom="ufs:/dev/ufs/FreeBSD_Install"
+ENDBOOT
+
+# Enable DHCP on all network interfaces
+sysrc -f etc/rc.conf ifconfig_DEFAULT=DHCP
+
+# Remove the local script that launches the installer by default
+rm -rf etc/rc.local
+
+# Create a temporary fstab with the root dir
+echo '/dev/ufs/FreeBSD_Install / ufs rw 1 1' > etc/fstab
+
+# Remove the linked resolv.conf
+rm -rf etc/resolv.conf
+END
+
+    logm("Create the installer");
+    target_cmd_build_root($ho, 900, $builddir, <<END.<<'END');
+target="freebsd/release/$target"
+output="install.img"
+END
+mkdir -p $output.tmp
+
+# Do some pruning
+rm -rf $target/usr/share/man
+rm -rf $target/usr/share/examples
+rm -rf $target/usr/share/doc
+rm -rf $target/usr/share/dtrace
+
+# Create a mfs root image
+makefs -b 10% -B little -o label=FreeBSD_Install $output.tmp/mfsroot $target
+# Compress image
+gzip $output.tmp/mfsroot
+
+# Copy boot to the staging dir
+cp -r $target/boot $output.tmp/
+cp $target/boot.config $output.tmp/
+
+# The loader doesn't need any modules in order to boot into the mfsroot.
+# The rest of the modules can be loaded from the mfs root itself.
+rm -f $output.tmp/boot/kernel/*.ko
+
+# Compress the kernel
+gzip $output.tmp/boot/kernel/kernel
+
+makefs -B little $output.part $output.tmp
+
+# Make the image bootable
+mkimg -s gpt -b $target/boot/pmbr -p efi:=$target/boot/boot1.efifat \
+    -p freebsd-boot:=$target/boot/gptboot -p freebsd-ufs:=$output.part \
+    -p freebsd-swap::1M -o $output
+
+rm $output.part
+rm -rf $output.tmp
+END
+}
+
+sub stash () {
+    my @sets = qw(MANIFEST base.txz kernel.txz);
+    my @symbols = qw(kernel-dbg.txz);
+
+
+    logm("Stashing FreeBSD build output");
+    foreach my $set (@sets) {
+        built_stash_file($ho, $builddir, $set,
+                         "freebsd/release/ftp/$set", 0);
+    }
+    foreach my $symbol (@symbols) {
+        built_stash_debugfile($ho, $builddir, $symbol,
+                              "freebsd/release/ftp/$symbol", 0);
+    }
+    built_stash_file($ho, $builddir, "install.img", "install.img", 0);
+
+
+    my $srcversion = target_cmd_output_root($ho, <<END, 30);
+awk '/^\\\#define[[:space:]]*__FreeBSD_version/ { print \$3 }' \\
+    $builddir/freebsd/sys/sys/param.h | cut -c1-2
+END
+    store_runvar("freebsd_buildversion", "$srcversion");
+
+    # Set path_freebsddist to point to the build output folder
+    # in order to make ts-build-check happy.
+    store_runvar("path_freebsddist", "build/");
+}
+
+install_deps();
+checkout();
+build();
+stash();
+
+logm("FreeBSD build successful");
+
Signature · 7 lines
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#17 lore raw

Re: [PATCH v4 09/16] osstest: introduce a FreeBSD build script

Roger Pau Monne writes ("[PATCH v4 09/16] osstest: introduce a FreeBSD build script"):

ts-freebsd-build line 50

Quoted 5 lines

In order to generate the FreeBSD installer image and the install media.

ts-freebsd-build new file +2 -0
+sub install_deps () {
+    target_install_packages($ho, 'git');

Please say

+ target_install_packages($ho, qw(git));

ts-freebsd-build line 64

Quoted 2 lines
ts-freebsd-build new file +2 -0
+    logm("Checkout the FreeBSD source tree");
+    build_clone($ho, 'freebsd', $builddir, 'freebsd', );

You have a spurious ", " at the end there.

In general, I notice that you sometimes add comments like this:

# Reverse the neutron polarity
neutron_polarity_op(--reverse);

I won't insist on you removing any but in general I thought I'd say they aren't IMO particularly useful.

ts-freebsd-build line 82

Quoted 7 lines
ts-freebsd-build new file +7 -0
+sub build_release($$$) {
+    my ($target, $prefix, $time) = @_;
+
+    buildcmd_stamped_logged_root($time, 'freebsd', "release-$target",
+                                 $prefix, <<END, '');
+make -C release $target
+END

Does this not want $makeflags ? Mostly, this would be a -j.

ts-freebsd-build line 94

Quoted 2 lines
ts-freebsd-build new file +2 -0
+    # Build process as documented in the handbook:
+    # https://www.freebsd.org/doc/handbook/updating-src.html

_This_ is a really good comment :-).

ts-freebsd-build line 164

Quoted 2 lines
ts-freebsd-build new file +2 -0
+# Create a temporary fstab with the root dir
+echo '/dev/ufs/FreeBSD_Install / ufs rw 1 1' > etc/fstab

It's quite noticeable that there is a lot of code here that perhaps ought to be in some FreeBSD component. (This is not a criticism of your osstest submission.)

ts-freebsd-build line 231

Quoted 4 lines
ts-freebsd-build new file +4 -0
+    my $srcversion = target_cmd_output_root($ho, <<END, 30);
+awk '/^\\\#define[[:space:]]*__FreeBSD_version/ { print \$3 }' \\
+    $builddir/freebsd/sys/sys/param.h | cut -c1-2
+END

Cor. Might it be better to use target_getfile and get_filecontents, and use a perl regexp ?

Your current approach means that:
* if nothing matchines, you do not detect an error
* you are unable to check that the putative version number has a plausible syntax
* if something goes wrong, the param.h that you're parsing does not end up conveniently in a log (although I guess it's probably in build/ somewhere).

ts-freebsd-build line 234

Quoted 3 lines
ts-freebsd-build new file +3 -0
+    store_runvar("freebsd_buildversion", "$srcversion");
+
+    # Set path_freebsddist to point to the build output folder

Seems to be a unicode nonbreaking space after the # !

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#18 lore raw

Re: [PATCH v4 09/16] osstest: introduce a FreeBSD build script

Quoted 7 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH v4 09/16] osstest: introduce a FreeBSD build script"):
You have a spurious ", " at the end there.

In general, I notice that you sometimes add comments like this:

# Reverse the neutron polarity
neutron_polarity_op(--reverse);

Right, it's too verbose maybe... I've added the logm to have some kind of references to what's going on, but really it's a mess to find them between so much output (the size of the build log file is ~100MB IIRC).

Quoted 12 lines

I won't insist on you removing any but in general I thought I'd say they aren't IMO particularly useful.

ts-freebsd-build line 82

Quoted 7 lines
ts-freebsd-build new file +7 -0
+sub build_release($$$) {
+    my ($target, $prefix, $time) = @_;
+
+    buildcmd_stamped_logged_root($time, 'freebsd', "release-$target",
+                                 $prefix, <<END, '');
+make -C release $target
+END

Does this not want $makeflags ? Mostly, this would be a -j.

No, those targets are (like) install targets, and will fail if called with -j.

Quoted 11 lines

ts-freebsd-build line 94

Quoted 2 lines
ts-freebsd-build new file +2 -0
+    # Build process as documented in the handbook:
+    # https://www.freebsd.org/doc/handbook/updating-src.html

_This_ is a really good comment :-).

ts-freebsd-build line 164

Quoted 2 lines
ts-freebsd-build new file +2 -0
+# Create a temporary fstab with the root dir
+echo '/dev/ufs/FreeBSD_Install / ufs rw 1 1' > etc/fstab

It's quite noticeable that there is a lot of code here that perhaps ought to be in some FreeBSD component. (This is not a criticism of your osstest submission.)

Nods, I agree. There's a GSoC project currently ongoing to integrate this functionality into the FreeBSD build process itself.

Quoted 7 lines

ts-freebsd-build line 231

Quoted 4 lines
ts-freebsd-build new file +4 -0
+    my $srcversion = target_cmd_output_root($ho, <<END, 30);
+awk '/^\\\#define[[:space:]]*__FreeBSD_version/ { print \$3 }' \\
+    $builddir/freebsd/sys/sys/param.h | cut -c1-2
+END

Cor. Might it be better to use target_getfile and get_filecontents, and use a perl regexp ?

This line is basically the same used by the FreeBSD Makefile to get the version number, that's why I've used it, but I don't like it, I think it's fragile to regexp like that. I've changed this to:

    my $srcversion = target_cmd_output_root($ho, <<END, 30);

set -e
cd $builddir/freebsd
eval make buildenvvars
test -n "\$SRCRELDATE"
echo "\$SRCRELDATE" | cut -c1-2
END

Which I think it's more bullet-proof.

Quoted 5 lines

ts-freebsd-build line 234

Quoted 3 lines
ts-freebsd-build new file +3 -0
+    store_runvar("freebsd_buildversion", "$srcversion");
+
+    # Set path_freebsddist to point to the build output folder

Seems to be a unicode nonbreaking space after the # !

Ups.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#19 lore raw

Re: [PATCH v4 09/16] osstest: introduce a FreeBSD build script

Roger Pau Monne writes ("Re: [PATCH v4 09/16] osstest: introduce a FreeBSD build script"):

Quoted 6 lines · Ian Jackson
Quoted 5 lines

Roger Pau Monne writes ("[PATCH v4 09/16] osstest: introduce a FreeBSD build script"):
You have a spurious ", " at the end there.

In general, I notice that you sometimes add comments like this:

Quoted 7 lines
Quoted 2 lines

# Reverse the neutron polarity
neutron_polarity_op(--reverse);

Right, it's too verbose maybe... I've added the logm to have some kind of references to what's going on, but really it's a mess to find them between so much output (the size of the build log file is ~100MB IIRC).

Oh, yes, I approve of the logm's.

Quoted 4 lines
Quoted 1 line

Does this not want $makeflags ? Mostly, this would be a -j.

No, those targets are (like) install targets, and will fail if called with -j.

Oh, OK.

Quoted 13 lines
Quoted 7 lines

ts-freebsd-build line 231

Quoted 4 lines
ts-freebsd-build new file +4 -0
+    my $srcversion = target_cmd_output_root($ho, <<END, 30);
+awk '/^\\\#define[[:space:]]*__FreeBSD_version/ { print \$3 }' \\
+    $builddir/freebsd/sys/sys/param.h | cut -c1-2
+END

Cor. Might it be better to use target_getfile and get_filecontents, and use a perl regexp ?

This line is basically the same used by the FreeBSD Makefile to get the version number, that's why I've used it, but I don't like it, I think it's fragile to regexp like that. I've changed this to:

    my $srcversion = target_cmd_output_root($ho, <<END, 30);
Quoted 8 lines

set -e
cd $builddir/freebsd
eval make buildenvvars
test -n "\$SRCRELDATE"
echo "\$SRCRELDATE" | cut -c1-2
END

Which I think it's more bullet-proof.

LGTM.

Although I have to say, evaling the output of make seems brave. Does BSD make only ever print blather to stderr, then ?

Quoted 7 lines
Quoted 5 lines

ts-freebsd-build line 234

Quoted 3 lines
ts-freebsd-build new file +3 -0
+    store_runvar("freebsd_buildversion", "$srcversion");
+
+    # Set path_freebsddist to point to the build output folder

Seems to be a unicode nonbreaking space after the # !

Ups.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#20 lore raw

Re: [PATCH v4 09/16] osstest: introduce a FreeBSD build script

Quoted 11 lines · Ian Jackson

Roger Pau Monne writes ("Re: [PATCH v4 09/16] osstest: introduce a FreeBSD build script"):

Quoted 10 lines · Ian Jackson
Quoted 1 line

Roger Pau Monne writes ("[PATCH v4 09/16] osstest: introduce a FreeBSD build script"):

    my $srcversion = target_cmd_output_root($ho, <<END, 30);

set -e
cd $builddir/freebsd
eval make buildenvvars
test -n "\$SRCRELDATE"
echo "\$SRCRELDATE" | cut -c1-2
END

Quoted 6 lines
Quoted 1 line

Which I think it's more bullet-proof.

LGTM.

Although I have to say, evaling the output of make seems brave. Does BSD make only ever print blather to stderr, then ?

That's a special target that's designed to work like this, I assume this one is guaranteed to print everything else to stderr (and exit with != 0).

I've changed the last line to:

expr "\$SRCRELDATE" / 100000

So that when FreeBSD reaches version 100 (in about ~200years), this will still work.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#21 lore raw

Re: [PATCH v4 09/16] osstest: introduce a FreeBSD build script

Roger Pau Monne writes ("Re: [PATCH v4 09/16] osstest: introduce a FreeBSD build script"):

Quoted 7 lines · Ian Jackson
Quoted 2 lines

Although I have to say, evaling the output of make seems brave. Does BSD make only ever print blather to stderr, then ?

That's a special target that's designed to work like this, I assume this one is guaranteed to print everything else to stderr (and exit with != 0).

FE

Quoted 6 lines

I've changed the last line to:

expr "\$SRCRELDATE" / 100000

So that when FreeBSD reaches version 100 (in about ~200years), this will still work.

:-)

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#22 lore raw

PATCH v4 10/16 osstest: add support for runtime_IDENT_hostflags

In reply to Roger Pau Monne

This is required for FreeBSD, that will need to set some of the hostflags at runtime. The current IDENT_hostflags will be keep as-is, and they should only be set at job creation time.

Also introduce a helper to set the runtime hostflags.

---
Changes since v3:
- New in this version

---
 Osstest/TestSupport.pm | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
Osstest/TestSupport.pm +9 -2
index 94ace09c..1c5455ee 100644
@@ -79,7 +79,7 @@ BEGIN {
 
                       selecthost get_hostflags get_host_property
                       get_target_property get_host_native_linux_console
-                      hostnamepath hostnamepath_list
+                      hostnamepath hostnamepath_list set_runtime_hostflag
                       power_state power_cycle power_cycle_sleep
                       serial_fetch_logs
                       propname_massage propname_check
@@ -1587,10 +1587,17 @@ sub get_hostflags ($) {
     my ($ident) = @_;
     # may be run outside transaction, or with flights locked
     my $flags= get_runvar_default('all_hostflags',     $job, '').','.
-               get_runvar_default("${ident}_hostflags", $job, '');
+               get_runvar_default("${ident}_hostflags", $job, '').','.
+               get_runvar_default("runtime_${ident}_hostflags", $job, '');
     return grep /./, split /\,/, $flags;
 }
 
+sub set_runtime_hostflag ($$) {
+    my ($ident,$value) = @_;
+
+    store_runvar("runtime_${ident}_hostflags", $value);
+}
+
 sub host_involves_pcipassthrough ($) {
     my ($ho) = @_;
     return !!grep m/^pcipassthrough\-/, get_hostflags($ho->{Ident});
Signature · 7 lines
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#23 lore raw

Re: [PATCH v4 10/16] osstest: add support for runtime_IDENT_hostflags

Roger Pau Monne writes ("[PATCH v4 10/16] osstest: add support for runtime_IDENT_hostflags"):

Quoted 5 lines

This is required for FreeBSD, that will need to set some of the hostflags at runtime. The current IDENT_hostflags will be keep as-is, and they should only be set at job creation time.

Also introduce a helper to set the runtime hostflags.

...

Osstest/TestSupport.pm sub get_hostflags ($) { · line 1591

Quoted 7 lines
Osstest/TestSupport.pm +2 -1
@@ -1587,10 +1587,17 @@ sub get_hostflags ($) {
     my ($ident) = @_;
     # may be run outside transaction, or with flights locked
     my $flags= get_runvar_default('all_hostflags',     $job, '').','.
-               get_runvar_default("${ident}_hostflags", $job, '');
+               get_runvar_default("${ident}_hostflags", $job, '').','.
+               get_runvar_default("runtime_${ident}_hostflags", $job, '');

VG.

Osstest/TestSupport.pm sub get_hostflags ($) { · line 1598

Quoted 4 lines
Osstest/TestSupport.pm +4 -0
+sub set_runtime_hostflag ($$) {
+    my ($ident,$value) = @_;
+
+    store_runvar("runtime_${ident}_hostflags", $value);

This function suggests that you can do this
set_runtime_hostflag('host', 'freebsd-version-4.7'); set_runtime_hostflag('host', 'share-host-freebsd-4.7-xxxx-yyyy');
but of course that won't work.

I like the implied interface better than the one which implicitly overwrites all previous runtime hostflags.

Should set_runtime_hostflag take a $ho, instead ? Can you ever see us using it without a $ho ? If not then it probably should.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#24 lore raw

Re: [PATCH v4 10/16] osstest: add support for runtime_IDENT_hostflags

Quoted 7 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH v4 10/16] osstest: add support for runtime_IDENT_hostflags"):

Osstest/TestSupport.pm sub get_hostflags ($) { · line 1598

Quoted 4 lines
Osstest/TestSupport.pm +4 -0
+sub set_runtime_hostflag ($$) {
+    my ($ident,$value) = @_;
+
+    store_runvar("runtime_${ident}_hostflags", $value);

This function suggests that you can do this

Quoted 6 lines
   set_runtime_hostflag('host', 'freebsd-version-4.7');
   set_runtime_hostflag('host', 'share-host-freebsd-4.7-xxxx-yyyy');

but of course that won't work.

I like the implied interface better than the one which implicitly overwrites all previous runtime hostflags.

Right.

Quoted 2 lines

Should set_runtime_hostflag take a $ho, instead ? Can you ever see us using it without a $ho ? If not then it probably should.

I'm sorry but I don't follow. I'm not sure how I'm supposed to use the $ho parameter, neither get_hostflags or store_runvar take such a parameter. From the text above I thought that you wanted something like:

sub set_runtime_hostflag ($$) {
    my ($ident,$value) = @_;

    $value .= ','.get_runvar_default("runtime_${ident}_hostflags", $job, '');
    store_runvar("runtime_${ident}_hostflags", $value);
}

But I'm not sure.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#25 lore raw

Re: [PATCH v4 10/16] osstest: add support for runtime_IDENT_hostflags

Roger Pau Monne writes ("Re: [PATCH v4 10/16] osstest: add support for runtime_IDENT_hostflags"):

Quoted 6 lines · Ian Jackson
Quoted 2 lines

I like the implied interface better than the one which implicitly overwrites all previous runtime hostflags.

Right.

Quoted 7 lines
Quoted 2 lines

Should set_runtime_hostflag take a $ho, instead ? Can you ever see us using it without a $ho ? If not then it probably should.

I'm sorry but I don't follow. I'm not sure how I'm supposed to use the $ho parameter, neither get_hostflags or store_runvar take such a parameter. From the text above I thought that you wanted something like:

You can get $ident from $ho->{Ident}.

Quoted 8 lines
sub set_runtime_hostflag ($$) {
    my ($ident,$value) = @_;

    $value .= ','.get_runvar_default("runtime_${ident}_hostflags", $job, '');
    store_runvar("runtime_${ident}_hostflags", $value);
}

But I'm not sure.

Yes, something like that, only taking $ho rather than $ident.

Also your proposed computation is slightly wrong in that it will
produce ,FLAG

I would use split and join.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#26 lore raw

Re: [PATCH v4 10/16] osstest: add support for runtime_IDENT_hostflags

In reply to Ian Jackson
Quoted 2 lines · Ian Jackson

Should set_runtime_hostflag take a $ho, instead ? Can you ever see us using it without a $ho ? If not then it probably should.

I don't think I can do that. This script runs before the host allocation.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#27 lore raw

Re: [PATCH v4 10/16] osstest: add support for runtime_IDENT_hostflags

Roger Pau Monne writes ("Re: [PATCH v4 10/16] osstest: add support for runtime_IDENT_hostflags"):

Quoted 6 lines · Ian Jackson
Quoted 2 lines

Should set_runtime_hostflag take a $ho, instead ? Can you ever see us using it without a $ho ? If not then it probably should.

I don't think I can do that. This script runs before the host allocation.

Oh. So it does. Yes, it must take an ident then. Sorry.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#28 lore raw

PATCH v4 11/16 osstest: introduce a script to set the runtime hostflags runvar for FreeBSD jobs

In reply to Roger Pau Monne

Due to the nature of the FreeBSD install media, which is self-generated from the ts-freebsd-build script, the hostflags runvar set to FreeBSD jobs are related to the current version under test.

The following hostflags might need to be fetched from the runvars of a previous build-$arch-freebsd job:

- share-build-freebsd-$arch-$hash: the $hash used here is calculated from the checksum of the installer image used by this specific job. This allows osstest to share FreeBSD build hosts, and be sure the exact desired FreeBSD version is used.
- freebsd-$version: $version contains the major FreeBSD version under test. This version is obtained from the FreeBSD source code used to create the install media.

---
Changes since v3:
- Make use of the set_runtime_hostflag helper.
- Make use of the sha256file helper.

Changes since v2:
- New in this version.

---
 ts-freebsd-set-hostflags | 64 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)
 create mode 100755 ts-freebsd-set-hostflags
ts-freebsd-set-hostflags new file +64 -0
new file mode 100755
index 00000000..1b0206a8
@@ -0,0 +1,64 @@
+#!/usr/bin/perl -w
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2017 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/>.
+
+# This script sets the host_hostflags for a FreeBSD job based on the runvars
+# provided and the contents of the extra_hostflags runvar.
+#
+# If the freebsd_distpath runvar is set the installer image will be retrieved
+# from "freebsd_distpath"/install.img, and the FreeBSD version from the
+# freebsd_version runvar. Note that both those runvars should be set on the
+# current job.
+#
+# If freebsd_distpath is not set, it is assumed that freebsdbuildjob runvar is
+# set and the installer image will be retrieved from the path pointed to by
+# "path_freebsdddist"/install.img, and the FreeBSD version will be obtained
+# from the "freebsd_buildversion" runvar. Both of those runvars belong to the
+# flight and job pointed to by freebsdbuildjob.
+#
+# As output upon successful completion this script will set the host_hostflags
+# runvar for the current job. Note that this _must_ be done before running
+# ts-host-allocate.
+#
+
+use strict qw(vars);
+use DBI;
+use POSIX;
+
+unshift @INC, qw(.);
+use Osstest;
+use Osstest::TestSupport;
+
+tsreadconfig();
+
+sub get_freebsd_image_hash() {
+    my $distpath =  $r{"freebsd_distpath"} ||
+                    get_stashed("path_freebsddist", $r{"freebsdbuildjob"});
+
+    return sha256file("$distpath/install.img", 16);
+}
+
+sub get_freebsd_version() {
+    return $r{"freebsd_version"} ||
+           get_runvar("freebsd_buildversion", $r{"freebsdbuildjob"});
+}
+
+my $hash = get_freebsd_image_hash();
+my $version = get_freebsd_version();
+my $arch = $r{"arch"};
+
+set_runtime_hostflag("host",
+                     "share-build-freebsd-$arch-$hash,freebsd-$version");
Signature · 7 lines
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#29 lore raw

Re: [PATCH v4 11/16] osstest: introduce a script to set the runtime hostflags runvar for FreeBSD jobs

Roger Pau Monne writes ("[PATCH v4 11/16] osstest: introduce a script to set the runtime hostflags runvar for FreeBSD jobs"):

Quoted 3 lines

Due to the nature of the FreeBSD install media, which is self-generated from the ts-freebsd-build script, the hostflags runvar set to FreeBSD jobs are related to the current version under test.

This is good. However:

ts-freebsd-set-hostflags line 64

Quoted 2 lines
ts-freebsd-set-hostflags new file +2 -0
+set_runtime_hostflag("host",
+                     "share-build-freebsd-$arch-$hash,freebsd-$version");

If you agree with my comments on the previous patch, you might want to change this to two calls to set_runtime_hostflag, and to pass $ho.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#30 lore raw

Re: [PATCH v4 11/16] osstest: introduce a script to set the runtime hostflags runvar for FreeBSD jobs

In reply to Roger Pau Monne

Roger Pau Monne writes ("[PATCH v4 11/16] osstest: introduce a script to set the runtime hostflags runvar for FreeBSD jobs"):

Quoted 3 lines

Due to the nature of the FreeBSD install media, which is self-generated from the ts-freebsd-build script, the hostflags runvar set to FreeBSD jobs are related to the current version under test.

...

ts-freebsd-set-hostflags line 64

Quoted 2 lines
ts-freebsd-set-hostflags new file +2 -0
+set_runtime_hostflag("host",
+                     "share-build-freebsd-$arch-$hash,freebsd-$version");

So, having thought about this:

You are currently unconditionally calling this script for build jobs, allowing it to assume the host ident name.

You don't call it at all for test jobs. This is wrong because test jobs need the freebsd-* hostflag too.

Currently there is no test job sharing, so they need not to have the share-* flag.

I think this means this ts-freebsd-set-hostflags script needs to be told somehow what flags to set. Since the sharetype is calculated from the share-* hostflag by ts-hosts-allocate-Executive, but then recalculated from the parameters to $mjobdb->jobdb_resource_shared_mark_ready, the code and runvars need to be coordinated so there is no problem making the hostflag be approximately-fixed.

So I suggest adding a --share flag to ts-freebsd-set-hostflags.

Also: you have not noticed this because currently nothing call $mjobdb->jobdb_resource_shared_mark_ready. Normally this is done by ts-xen-build-prep which is run by prepare-build-host-linux. You haven't noticed that you aren't calling this because currently you aren't building Xen at all.

One way to deal with this would be to fix ts-xen-build-prep for FreeBSD (at least to the point where it runs to completion, even if not all the Xen build-dependencies are installed), and then call it in prepare-build-host-freebsd. But that looks quite annoying because ts-xen-build-prep reorganises the storage in rather linux-specific ways.

Another would be to split out the call to
$mjobdb->jobdb_resource_shared_mark_ready
from ts-xen-build-prep into its own script ts-host-shared-ready. That new script would have to gain a substitution system.

An ad-hoc method would be to call
$mjobdb->jobdb_resource_shared_mark_ready
from ts-freebsd-install. That seems to suggest FreeBSD installs not needing different storage arrangements or something for build hosts and test dom0s.

If you were feeling keen, you could sort out the anomaly that is a test script calling straight into $mjobdb. Eg.
1. Rename resource_shared_mark_ready to executive_resource_shared_mark_ready and change all callers.
2. Introduce a wrapper resource_shared_mark_ready which calls $mjobdb->jobdb_resource_shared_mark_ready and change the call in ts-xen-build-prep to use it.

I'll come to you in a moment to handwave at you about all this.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#31 lore raw

PATCH v4 12/16 osstest: allow catching-otherwise to pass arguments to the called script

In reply to Roger Pau Monne

Allow catching-otherwise to take a variable number of tail arguments, that will be propagated to the called proc.

---
Changes since v3:
- New in this version.

---
 sg-run-job | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
sg-run-job +4 -4
index b1f94f4d..87d81085 100755
@@ -123,8 +123,8 @@ proc run-job {job} {
     }
 }
 
-proc catching-otherwise {failst script} {
-    # Executes $script.
+proc catching-otherwise {failst script args} {
+    # Executes $script $args.
     # If job is already a failure (ie not $ok), skips it (ie does nothing).
     # If any Tcl exception is thrown, declares the job a failure.
     # (ie sets job status to $failst, and sets ok to 0)
@@ -134,9 +134,9 @@ proc catching-otherwise {failst script} {
     if {!$ok} return
 
     if {[catch {
-        uplevel 1 $script
+        uplevel 1 $script $args
     } emsg]} {
-        jobdb::logputs stderr "$flight.$jobinfo(job) $script failed: $emsg"
+        jobdb::logputs stderr "$flight.$jobinfo(job) $script $args failed: $emsg"
         set ok 0
 	setstatus $failst
     }
Signature · 7 lines
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#32 lore raw

Re: [PATCH v4 12/16] osstest: allow catching-otherwise to pass arguments to the called script

Roger Pau Monne writes ("[PATCH v4 12/16] osstest: allow catching-otherwise to pass arguments to the called script"):

Quoted 2 lines

Allow catching-otherwise to take a variable number of tail arguments, that will be propagated to the called proc.

Err, this is not necessary, I think. The caller can do it.

Let me see how you use it...

... indeed. I will reply to those patches.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#33 lore raw

PATCH v4 13/16 osstest: change the meaning of need_build_host

In reply to Roger Pau Monne

Make need_build_host store a string instead of a boolean. This is later going to be expanded to handle the FreeBSD build jobs.

---
Changes since v3:
- New in this version (split from patch).

---
 sg-run-job | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)
sg-run-job +19 -14
index 87d81085..2ee57ace 100755
@@ -52,12 +52,12 @@ proc run-job {job} {
     set skip_globs     [jobdb::read-runvar $flight $job skip_testids]
 
     set nh [need-hosts/$jobinfo(recipe)]
-    if {![string compare $nh BUILD]} {
+    if {[string match BUILD_* $nh]} {
         set need_xen_hosts {}
-        set need_build_host 1
+        set need_build_host [string range $nh [expr [string first _ $nh] + 1] end]
     } else {
         set need_xen_hosts $nh
-        set need_build_host 0
+        set need_build_host {}
     }
     set nested_layers_hosts {}
 
@@ -68,7 +68,9 @@ proc run-job {job} {
         eval run-ts broken  =             ts-hosts-allocate + $need_xen_hosts
     }
 
-    if {$need_build_host} { catching-otherwise broken allocate-build-host }
+    if {[llength $need_build_host]} {
+        catching-otherwise broken allocate-build-host $need_build_host
+    }
 
     if {$ok} { setstatus running                                          }
 
@@ -77,7 +79,10 @@ proc run-job {job} {
 
     if {$ok} { set syslog [spawn-ts broken = | ts-syslog-server]          }
 
-    if {$need_build_host} { catching-otherwise broken prepare-build-host }
+    if {[llength $need_build_host]} {
+        catching-otherwise broken \
+                           prepare-build-host-[string tolower $need_build_host]
+    }
 
     per-host-ts broken  host-install/@(*) ts-host-install-twice
 
@@ -95,7 +100,7 @@ proc run-job {job} {
         set need_xen_hosts [lunappend nested_layers_hosts]
     }
 
-    if {$need_build_host && !$ok} {
+    if {[llength $need_build_host] && !$ok} {
 	run-ts  !broken capture-logs      ts-logs-capture + host
     }
 
@@ -116,7 +121,7 @@ proc run-job {job} {
 
     if {$ok} { setstatus pass                                             }
 
-    if {$need_build_host && $ok} { jobdb::preserve-task 90 }
+    if {[llength $need_build_host] && $ok} { jobdb::preserve-task 90 }
 
     if {!$ok} {
         jobdb::logputs stdout "job not ok"
@@ -671,11 +676,11 @@ proc need-hosts/host-examine-linux {} { examine-host-examine debian }
 
 #---------- builds ----------
 
-proc need-hosts/build {} { return BUILD }
-proc need-hosts/build-kern {} { return BUILD }
-proc need-hosts/build-libvirt {} { return BUILD }
-proc need-hosts/build-rumprun {} { return BUILD }
-proc need-hosts/build-xtf {} { return BUILD }
+proc need-hosts/build {} { return BUILD_LINUX }
+proc need-hosts/build-kern {} { return BUILD_LINUX }
+proc need-hosts/build-libvirt {} { return BUILD_LINUX }
+proc need-hosts/build-rumprun {} { return BUILD_LINUX }
+proc need-hosts/build-xtf {} { return BUILD_LINUX }
 
 proc run-job/build {} {
     run-ts . = ts-xen-build
@@ -702,11 +707,11 @@ proc run-job/build-xtf {} {
     run-ts . = ts-xtf-build
 }
 
-proc allocate-build-host {} {
+proc allocate-build-host {ostype} {
     global jobinfo
     run-ts broken = ts-hosts-allocate + host
 }
-proc prepare-build-host {} {
+proc prepare-build-host-linux {} {
     global jobinfo
     run-ts broken host-install(*) ts-host-install-twice
     run-ts . host-build-prep ts-xen-build-prep
Signature · 7 lines
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#34 lore raw

Re: [PATCH v4 13/16] osstest: change the meaning of need_build_host

Roger Pau Monne writes ("[PATCH v4 13/16] osstest: change the meaning of need_build_host"):

Quoted 2 lines

Make need_build_host store a string instead of a boolean. This is later going to be expanded to handle the FreeBSD build jobs.

...

sg-run-job proc run-job {job} { · line 73

Quoted 4 lines
sg-run-job +3 -1
-    if {$need_build_host} { catching-otherwise broken allocate-build-host }
+    if {[llength $need_build_host]} {
+        catching-otherwise broken allocate-build-host $need_build_host
+    }

I think you mean

+ if {[llength $need_build_host]} {
+ catching-otherwise broken { allocate-build-host $need_build_host }
+ }

catching-otherwise takes a script as its second argument. The script can be a whole { } block and can refer to variables in the same scope (since it is invoked with uplevel).

Ie, catching-otherwise is a user-defined control construct. You can use it like "if" or something. The omission of the braces in the old code is simply because if the code to be executed is a single argumentless procedure call, they aren't needed.

So:

sg-run-job proc run-job {job} { · line 84

Quoted 4 lines
sg-run-job +3 -1
-    if {$need_build_host} { catching-otherwise broken prepare-build-host }
+    if {[llength $need_build_host]} {
+        catching-otherwise broken \
+                           prepare-build-host-[string tolower $need_build_host]

Instead:

+ catching-otherwise broken {
+ prepare-build-host-[string tolower $need_build_host]
+ }

sg-run-job proc need-hosts/host-examine-linux {} { examine-host-examine debian } · line 683

Quoted 12 lines
sg-run-job +6 -5
+    }
 
-proc need-hosts/build {} { return BUILD }
-proc need-hosts/build-kern {} { return BUILD }
-proc need-hosts/build-libvirt {} { return BUILD }
-proc need-hosts/build-rumprun {} { return BUILD }
-proc need-hosts/build-xtf {} { return BUILD }
+proc need-hosts/build {} { return BUILD_LINUX }
+proc need-hosts/build-kern {} { return BUILD_LINUX }
+proc need-hosts/build-libvirt {} { return BUILD_LINUX }
+proc need-hosts/build-rumprun {} { return BUILD_LINUX }
+proc need-hosts/build-xtf {} { return BUILD_LINUX }

I wish I had made these line up neatly! Sorry.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#35 lore raw

Re: [PATCH v4 13/16] osstest: change the meaning of need_build_host

Quoted 15 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH v4 13/16] osstest: change the meaning of need_build_host"):

Quoted 2 lines

Make need_build_host store a string instead of a boolean. This is later going to be expanded to handle the FreeBSD build jobs.

...

sg-run-job proc run-job {job} { · line 73

Quoted 4 lines
sg-run-job +3 -1
-    if {$need_build_host} { catching-otherwise broken allocate-build-host }
+    if {[llength $need_build_host]} {
+        catching-otherwise broken allocate-build-host $need_build_host
+    }

I think you mean

+ if {[llength $need_build_host]} {
+ catching-otherwise broken { allocate-build-host $need_build_host }
+ }

Quoted 8 lines

catching-otherwise takes a script as its second argument. The script can be a whole { } block and can refer to variables in the same scope (since it is invoked with uplevel).

Ie, catching-otherwise is a user-defined control construct. You can use it like "if" or something. The omission of the braces in the old code is simply because if the code to be executed is a single argumentless procedure call, they aren't needed.

Heh, I told you I would try to do it the C way ;). Thanks for the comment, it's now fixed.

Quoted 14 lines

So:

sg-run-job proc run-job {job} { · line 84

Quoted 4 lines
sg-run-job +3 -1
-    if {$need_build_host} { catching-otherwise broken prepare-build-host }
+    if {[llength $need_build_host]} {
+        catching-otherwise broken \
+                           prepare-build-host-[string tolower $need_build_host]

Instead:

+ catching-otherwise broken {
+ prepare-build-host-[string tolower $need_build_host]
+ }

Quoted 1 line

+ }

Quoted 12 lines

sg-run-job proc need-hosts/host-examine-linux {} { examine-host-examine debian } · line 683

Quoted 10 lines
sg-run-job +5 -5
-proc need-hosts/build {} { return BUILD }
-proc need-hosts/build-kern {} { return BUILD }
-proc need-hosts/build-libvirt {} { return BUILD }
-proc need-hosts/build-rumprun {} { return BUILD }
-proc need-hosts/build-xtf {} { return BUILD }
+proc need-hosts/build {} { return BUILD_LINUX }
+proc need-hosts/build-kern {} { return BUILD_LINUX }
+proc need-hosts/build-libvirt {} { return BUILD_LINUX }
+proc need-hosts/build-rumprun {} { return BUILD_LINUX }
+proc need-hosts/build-xtf {} { return BUILD_LINUX }

I wish I had made these line up neatly! Sorry.

Would you like me to align the '{ return ...' block (align on the first { of the body).

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#36 lore raw

Re: [PATCH v4 13/16] osstest: change the meaning of need_build_host

Roger Pau Monne writes ("Re: [PATCH v4 13/16] osstest: change the meaning of need_build_host"):

Quoted 15 lines · Ian Jackson
Quoted 13 lines

Roger Pau Monne writes ("[PATCH v4 13/16] osstest: change the meaning of need_build_host"):

sg-run-job proc need-hosts/host-examine-linux {} { examine-host-examine debian } · line 683

Quoted 10 lines
sg-run-job +5 -5
-proc need-hosts/build {} { return BUILD }
-proc need-hosts/build-kern {} { return BUILD }
-proc need-hosts/build-libvirt {} { return BUILD }
-proc need-hosts/build-rumprun {} { return BUILD }
-proc need-hosts/build-xtf {} { return BUILD }
+proc need-hosts/build {} { return BUILD_LINUX }
+proc need-hosts/build-kern {} { return BUILD_LINUX }
+proc need-hosts/build-libvirt {} { return BUILD_LINUX }
+proc need-hosts/build-rumprun {} { return BUILD_LINUX }
+proc need-hosts/build-xtf {} { return BUILD_LINUX }

I wish I had made these line up neatly! Sorry.

Quoted 2 lines

Would you like me to align the '{ return ...' block (align on the first { of the body).

If you feel like it that would be nice :-).

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#37 lore raw

PATCH v4 14/16 osstest: add support for FreeBSD buildjobs to sg-run-job

In reply to Roger Pau Monne

Add support and introduce a FreeBSD build job to sg-run-job.

---
Changes since v3:
- New in this version (split from existing patch).

---
 sg-run-job | 13 +++++++++++++
 1 file changed, 13 insertions(+)
sg-run-job +13 -0
index 2ee57ace..ae08183d 100755
@@ -681,6 +681,7 @@ proc need-hosts/build-kern {} { return BUILD_LINUX }
 proc need-hosts/build-libvirt {} { return BUILD_LINUX }
 proc need-hosts/build-rumprun {} { return BUILD_LINUX }
 proc need-hosts/build-xtf {} { return BUILD_LINUX }
+proc need-hosts/build-freebsd {} { return BUILD_FREEBSD }
 
 proc run-job/build {} {
     run-ts . = ts-xen-build
@@ -707,8 +708,15 @@ proc run-job/build-xtf {} {
     run-ts . = ts-xtf-build
 }
 
+proc run-job/build-freebsd {} {
+    run-ts . = ts-freebsd-build
+}
+
 proc allocate-build-host {ostype} {
     global jobinfo
+    if {[string equal $ostype FREEBSD]} {
+        run-ts broken = ts-freebsd-set-hostflags
+    }
     run-ts broken = ts-hosts-allocate + host
 }
 proc prepare-build-host-linux {} {
@@ -717,6 +725,11 @@ proc prepare-build-host-linux {} {
     run-ts . host-build-prep ts-xen-build-prep
 }
 
+proc prepare-build-host-freebsd {} {
+    global jobinfo
+    run-ts broken host-install(*) ts-freebsd-host-install
+}
+
 proc need-hosts/coverity {} { return BUILD }
 proc run-job/coverity {} {
     run-ts . = ts-coverity-build + host
Signature · 7 lines
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#38 lore raw

Re: [PATCH v4 14/16] osstest: add support for FreeBSD buildjobs to sg-run-job

Roger Pau Monne writes ("[PATCH v4 14/16] osstest: add support for FreeBSD buildjobs to sg-run-job"):

Quoted 1 line

Add support and introduce a FreeBSD build job to sg-run-job.

...

sg-run-job proc run-job/build-xtf {} { · line 719

Quoted 5 lines

proc allocate-build-host {ostype} {
global jobinfo

sg-run-job +3 -0
+    if {[string equal $ostype FREEBSD]} {
+        run-ts broken = ts-freebsd-set-hostflags
+    }

I would prefer use of `switch' for this. switch -exact $ostype etc. Stylistically, please provide an explicit and empty default clause.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#39 lore raw

PATCH v4 15/16 osstest: introduce a script to create a FreeBSD flight

In reply to Roger Pau Monne

The logic to create a FreeBSD build job is added to make-freebsd-flight. This includes creating a FreeBSD build job, and also testing the output of that build job (by creating another build job that depends on the output of the first).

Note that the FreeBSD build job needs some input in order to setup a FreeBSD host, and that can be fetched from different places:

1. Env variable FREEBSD_BUILDJOB: use the output from a previous build-<arch>-freebsd.

2. Env variables FREEBSD_DIST and FREEBSD_VERSION: set before calling into make-flight, provide the path to the installer image and sets folder and the version being installed.

3. Config file FreeBSDDist and FreeBSDVersion: same as 2. except that they are set on the config file.

---
Changes since v3:
- Split the sg-run-job code into pre-patches.

Changes since v1:
- Replace freebsd_buildjob with freebsdbuildjob.
- Replace FREEBSD_SETS/IMAGE with a single FREEBSD_DIST that points to a folder that should contain both things.
- Document the FreeBSDDist and FreeBSDVersion config file options in the README file.

---
 README              | 11 +++++++
 ap-common           |  4 +++
 make-freebsd-flight | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 98 insertions(+)
 create mode 100755 make-freebsd-flight
README +11 -0
index b45058da..51243974 100644
@@ -423,6 +423,17 @@ HostGroupFlags_<group>
 DebianPreseed
    Text to add to the debian-installer preseed file.  Optional.
 
+FreeBSDDist
+   Path to the folder that contains the FreeBSD install image and
+   the FreeBSD compressed install sets, together with the MANIFEST
+   file that holds the checksums. This is required in order to run
+   a FreeBSD host install if no previous FreeBSD buildjob is
+   available (ie: for example when running in standalone mode).
+
+FreeBSDVersion
+   Numeric value holding the major FreeBSD version of the media
+   provided in FreeBSDDist (ie: 12).
+
 ========================================
 
 Config settings relevant only to standalone mode
ap-common +4 -0
index cbb815ce..d4fa7aef 100644
@@ -37,6 +37,10 @@
 : ${PUSH_TREE_XTF:=$XENBITS:/home/xen/git/xtf.git}
 : ${BASE_TREE_XTF:=git://xenbits.xen.org/xtf.git}
 
+: ${TREE_FREEBSD:=git://github.com/freebsd/freebsd.git}
+: ${PUSH_TREE_FREEBSD:=$XENBITS:/home/xen/git/freebsd.git}
+: ${BASE_TREE_FREEBSD:=git://xenbits.xen.org/freebsd.git}
+
 : ${TREE_LIBVIRT:=git://libvirt.org/libvirt.git}
 : ${PUSH_TREE_LIBVIRT:=$XENBITS:/home/xen/git/libvirt.git}
 : ${BASE_TREE_LIBVIRT:=git://xenbits.xen.org/libvirt.git}
make-freebsd-flight new file +83 -0

83 lines not on this page · raw message

Signature · 7 lines
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#40 lore raw

Re: [PATCH v4 15/16] osstest: introduce a script to create a FreeBSD flight

Roger Pau Monne writes ("[PATCH v4 15/16] osstest: introduce a script to create a FreeBSD flight"):

Quoted 4 lines

The logic to create a FreeBSD build job is added to make-freebsd-flight. This includes creating a FreeBSD build job, and also testing the output of that build job (by creating another build job that depends on the output of the first).

...

Review

Quoted 2 lines
(quoted diff) +2 -0
+get_freebsdjob_runvars () {
+    # Figure out where are the installer binaries. The order is the follo\

wing:

make-freebsd-flight

Quoted 5 lines
make-freebsd-flight new file +5 -0
+    #
+    # 1. Env variable FREEBSD_BUILDJOB: use the output from a previous
+    # build-<arch>-freebsd.
+    #
+    # 2. Env variables FREEBSD_DIST, FREEBSD_VERSION: set before calling \

into

Please rewrap this to 70 or 75 columns.

Quoted 1 line

+ echo $runvars

Can you follow the calling pattern of set_hostos_runvars ?

I think the runvars variable should probably be "freebsd_runvars" and the function "set_freebsd_runvars".

Quoted 8 lines
make-freebsd-flight new file +8 -0
+runvars=`get_freebsdjob_runvars`
+job_create_build build-$arch-freebsd build-freebsd                       \
+            arch=$arch                                                   \
+            $RUNVARS $BUILD_RUNVARS $BUILD_FREEBSD_RUNVARS $arch_runvars \
+            tree_freebsd=$TREE_FREEBSD                                   \
+            revision_freebsd=$REVISION_FREEBSD                           \
+            host_hostflags=arch-$arch,purpose-build                      \
+            $runvars

make-freebsd-flight line 81

Quoted 10 lines
make-freebsd-flight new file +10 -0
+
+# Create an identical job that's going to use the build output from
+# the previous one.
+job_create_build build-$arch-freebsd-again build-freebsd                 \
+            arch=$arch                                                   \
+            $RUNVARS $BUILD_RUNVARS $BUILD_FREEBSD_RUNVARS $arch_runvars \
+            host_hostflags=arch-$arch,purpose-build                      \
+            tree_freebsd=$TREE_FREEBSD                                   \
+            revision_freebsd=$REVISION_FREEBSD                           \
+            freebsdbuildjob=build-$arch-freebsd

Perhaps set_freebsd_runvars could set host_hostflags too ? Not sure.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#41 lore raw

Re: [PATCH v4 15/16] osstest: introduce a script to create a FreeBSD flight

Quoted 16 lines · Ian Jackson

Roger Pau Monne writes ("[PATCH v4 15/16] osstest: introduce a script to create a FreeBSD flight"):

Quoted 4 lines

The logic to create a FreeBSD build job is added to make-freebsd-flight. This includes creating a FreeBSD build job, and also testing the output of that build job (by creating another build job that depends on the output of the first).

...

Review

Quoted 2 lines
(quoted diff) +2 -0
+get_freebsdjob_runvars () {
+    # Figure out where are the installer binaries. The order is the follo\

wing:

make-freebsd-flight

Quoted 5 lines
make-freebsd-flight new file +5 -0
+    #
+    # 1. Env variable FREEBSD_BUILDJOB: use the output from a previous
+    # build-<arch>-freebsd.
+    #
+    # 2. Env variables FREEBSD_DIST, FREEBSD_VERSION: set before calling \

into

Quoted 8 lines

Please rewrap this to 70 or 75 columns.

Quoted 1 line

+ echo $runvars

Can you follow the calling pattern of set_hostos_runvars ?

I think the runvars variable should probably be "freebsd_runvars" and the function "set_freebsd_runvars".

Done.

Quoted 13 lines
Quoted 13 lines
make-freebsd-flight new file +13 -0
+runvars=`get_freebsdjob_runvars`
+job_create_build build-$arch-freebsd build-freebsd                       \
+            arch=$arch                                                   \
+            $RUNVARS $BUILD_RUNVARS $BUILD_FREEBSD_RUNVARS $arch_runvars \
+            tree_freebsd=$TREE_FREEBSD                                   \
+            revision_freebsd=$REVISION_FREEBSD                           \
+            host_hostflags=arch-$arch,purpose-build                      \
+            $runvars
+
+# Create an identical job that's going to use the build output from
+# the previous one.
+job_create_build build-$arch-freebsd-again build-freebsd                 \
+            arch=$arch                                                   \
Quoted 8 lines

make-freebsd-flight line 81

Quoted 5 lines
make-freebsd-flight new file +5 -0
+            $RUNVARS $BUILD_RUNVARS $BUILD_FREEBSD_RUNVARS $arch_runvars \
+            host_hostflags=arch-$arch,purpose-build                      \
+            tree_freebsd=$TREE_FREEBSD                                   \
+            revision_freebsd=$REVISION_FREEBSD                           \
+            freebsdbuildjob=build-$arch-freebsd

Perhaps set_freebsd_runvars could set host_hostflags too ? Not sure.

Hm, not sure I want to do that. I expect that set_freebsd_runvars is also going to be used by non-build jobs, at which point the host_hostflags won't be the same for all jobs (like they are above).

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#42 lore raw

PATCH v4 16/16 osstest: hook FreeBSD flight into cr-daily-branch

In reply to Roger Pau Monne

Add the missing pieces so that cr-daily-branch knows how to create a FreeBSD flight. This has been tested by calling ./cr-daily-branch freebsd.

Note that there are two missing pieces. The first one is correctly setting the FREEBSD_BUILDJOB environment variable when calling make-freebsd-flight, without it the installer media will always be picked from the configuration file. This requires keeping track of previous FreeBSD successful build jobs, marking them as permanent and fetching them from the database in order to pass them on the env variable.

The second missing bit is setting daily-cron-email-freebsd to send emails to the xen-devel mailing list, ATM it's only sending emails to my personal @FreeBSD.org address (this has been done for testing purposes).

---
Changes since v3:
- Fix the daily-cron-email-* settings for FreeBSD branch flights.

---
 ap-common                       | 1 +
 ap-fetch-version                | 4 ++++
 ap-fetch-version-old            | 5 +++++
 ap-print-url                    | 3 +++
 ap-push                         | 5 +++++
 cr-daily-branch                 | 9 +++++++++
 cr-for-branches                 | 2 +-
 cri-common                      | 1 +
 daily-cron-email-adhoc--freebsd | 1 +
 daily-cron-email-play--freebsd  | 1 +
 daily-cron-email-real--freebsd  | 4 ++++
 11 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 daily-cron-email-adhoc--freebsd
 create mode 100644 daily-cron-email-play--freebsd
 create mode 100644 daily-cron-email-real--freebsd
ap-common +1 -0
index d4fa7aef..0d8a667a 100644
@@ -86,6 +86,7 @@ fi
 : ${LOCALREV_SEABIOS:=daily-cron.$branch}
 : ${LOCALREV_OVMF:=daily-cron.$branch}
 : ${LOCALREV_XTF:=daily-cron.$branch}
+: ${LOCALREV_FREEBSD:=daily-cron.$branch}
 
 : ${TREEBASE_LINUX_XCP:=http://hg.uk.xensource.com/carbon/trunk/linux-2.6.27}
 
ap-fetch-version +4 -0
index a107c93d..365ae018 100755
@@ -106,6 +106,10 @@ ovmf)
 	repo_tree_rev_fetch_git ovmf \
 		$TREE_OVMF_UPSTREAM master $LOCALREV_OVMF
 	;;
+freebsd)
+	repo_tree_rev_fetch_git freebsd \
+		$TREE_FREEBSD master $LOCALREV_FREEBSD
+	;;
 osstest)
         if [ "x$OSSTEST_USE_HEAD" = "xy" ] ; then
 	    git update-ref -m "Arranging to test HEAD" \
ap-fetch-version-old +5 -0
index 3cbc1768..9b086401 100755
@@ -34,6 +34,7 @@ check_ap_fetch_placeholders
 : ${BASE_LOCALREV_SEABIOS:=daily-cron.$branch.old}
 : ${BASE_LOCALREV_XTF:=daily-cron.$branch.old}
 : ${BASE_LOCALREV_OVMF:=daily-cron.$branch.old}
+: ${BASE_LOCALREV_FREEBSD:=daily-cron.$branch.old}
 : ${BASE_TAG_LIBVIRT:=xen-tested-master}
 
 if info_linux_tree "$branch"; then
@@ -114,6 +115,10 @@ ovmf)
 	repo_tree_rev_fetch_git ovmf \
 		$BASE_TREE_OVMF xen-tested-master $BASE_LOCALREV_OVMF
 	;;
+freebsd)
+	repo_tree_rev_fetch_git freebsd \
+		$BASE_TREE_FREEBSD xen-tested-master $BASE_LOCALREV_FREEBSD
+	;;
 osstest)
 	if [ "x$OSSTEST_USE_HEAD" != "xy" ] ; then
 	    git fetch -f $HOME/testing.git production:ap-fetch
ap-print-url +3 -0
index 93c14b35..57126292 100755
@@ -64,6 +64,9 @@ xtf)
 ovmf)
 	echo $TREE_OVMF_UPSTREAM
 	;;
+freebsd)
+	echo $TREE_FREEBSD
+	;;
 osstest)
 	echo none:;
 	;;
ap-push +5 -0
index a27ccc22..5b6ce7fc 100755
@@ -41,6 +41,7 @@ TREE_RUMPRUN=$PUSH_TREE_RUMPRUN
 TREE_SEABIOS=$PUSH_TREE_SEABIOS
 TREE_OVMF=$PUSH_TREE_OVMF
 TREE_XTF=$PUSH_TREE_XTF
+TREE_FREEBSD=$PUSH_TREE_FREEBSD
 
 if info_linux_tree "$branch"; then
 	cd $repos/linux
@@ -125,6 +126,10 @@ xtf)
 	cd $repos/xtf
 	git push $TREE_XTF $revision:refs/heads/xen-tested-master
 	;;
+freebsd)
+	cd $repos/freebsd
+	git push $TREE_FREEBSD $revision:refs/heads/xen-tested-master
+	;;
 ovmf)
 	cd $repos/ovmf
 	git push $TREE_OVMF $revision:refs/heads/xen-tested-master
cr-daily-branch +9 -0
index 39483cda..7bc2c1da 100755
@@ -207,6 +207,10 @@ if [ "x$REVISION_LINUXFIRMWARE" = x ]; then
 	determine_version REVISION_LINUXFIRMWARE linuxfirmware LINUXFIRMWARE
         export REVISION_LINUXFIRMWARE
 fi
+if [ "x$REVISION_FREEBSD" = x ]; then
+	determine_version REVISION_FREEBSD freebsd FREEBSD
+	export REVISION_FREEBSD
+fi
 
 case "$tree" in
 xen)
@@ -255,6 +259,10 @@ ovmf)
 	realtree=ovmf
 	NEW_REVISION=$REVISION_OVMF
 	;;
+freebsd)
+	realtree=freebsd
+	NEW_REVISION=$REVISION_FREEBSD
+	;;
 *)
 	NEW_REVISION=''
 	wantpush=false
@@ -274,6 +282,7 @@ examine)	makeflight=make_hosts_flight
 			./make-hosts-flight $1 $2 blessed-$3 $3 $4
 		}
 		;;
+freebsd)	makeflight=./make-freebsd-flight ;;
 *)         	makeflight=./make-flight ;;
 esac
 
cr-for-branches +1 -1
index a6912735..23e4ca84 100755
@@ -31,7 +31,7 @@ scriptoptions="$1"; shift
 LOGFILE=tmp/cr-for-branches.log
 export LOGFILE
 
-: ${BRANCHES:=osstest xen-4.0-testing xen-4.1-testing xen-4.2-testing xen-4.3-testing xen-4.4-testing xen-4.5-testing xen-4.6-testing xen-4.7-testing xen-4.8-testing xen-4.9-testing xen-unstable qemu-mainline qemu-upstream-unstable qemu-upstream-4.2-testing qemu-upstream-4.3-testing qemu-upstream-4.4-testing qemu-upstream-4.5-testing qemu-upstream-4.6-testing qemu-upstream-4.7-testing qemu-upstream-4.8-testing qemu-upstream-4.9-testing linux-linus linux-4.9 linux-4.1 linux-3.18 linux-3.16 linux-3.14 linux-3.10 linux-3.4 linux-arm-xen seabios ovmf xtf ${EXTRA_BRANCHES}}
+: ${BRANCHES:=osstest xen-4.0-testing xen-4.1-testing xen-4.2-testing xen-4.3-testing xen-4.4-testing xen-4.5-testing xen-4.6-testing xen-4.7-testing xen-4.8-testing xen-4.9-testing xen-unstable qemu-mainline qemu-upstream-unstable qemu-upstream-4.2-testing qemu-upstream-4.3-testing qemu-upstream-4.4-testing qemu-upstream-4.5-testing qemu-upstream-4.6-testing qemu-upstream-4.7-testing qemu-upstream-4.8-testing qemu-upstream-4.9-testing linux-linus linux-4.9 linux-4.1 linux-3.18 linux-3.16 linux-3.14 linux-3.10 linux-3.4 linux-arm-xen seabios ovmf xtf freebsd ${EXTRA_BRANCHES}}
 export BRANCHES
 
 fetchwlem=$wlem
cri-common +1 -0
index 903fb4e2..a3e679cf 100644
@@ -80,6 +80,7 @@ select_xenbranch () {
 	seabios)		tree=seabios;	xenbranch=xen-unstable ;;
 	xtf)			tree=xtf;	xenbranch=xen-unstable ;;
 	ovmf)			tree=ovmf;	xenbranch=xen-unstable ;;
+	freebsd)		tree=freebsd;	xenbranch=xen-unstable ;;
 	distros-*|examine)	tree=none;	xenbranch=xen-unstable ;;
 	osstest)		tree=osstest;	xenbranch=xen-unstable ;;
 	esac
daily-cron-email-adhoc--freebsd new file +1 -0
new file mode 100644
index 00000000..b64821af
@@ -0,0 +1 @@
+To: [email protected]
daily-cron-email-play--freebsd new file +1 -0
new file mode 100644
index 00000000..b64821af
@@ -0,0 +1 @@
+To: [email protected]
daily-cron-email-real--freebsd new file +4 -0
new file mode 100644
index 00000000..6ee2fa4d
@@ -0,0 +1,4 @@
+To: [email protected],
+    [email protected],
+    [email protected]
+Bcc: [email protected]
Signature · 7 lines
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#43 lore raw

Re: [PATCH v4 16/16] osstest: hook FreeBSD flight into cr-daily-branch

Roger Pau Monne writes ("[PATCH v4 16/16] osstest: hook FreeBSD flight into cr-daily-branch"):

Quoted 11 lines

Add the missing pieces so that cr-daily-branch knows how to create a FreeBSD flight. This has been tested by calling ./cr-daily-branch freebsd.

Note that there are two missing pieces. The first one is correctly setting the FREEBSD_BUILDJOB environment variable when calling make-freebsd-flight, without it the installer media will always be picked from the configuration file. This requires keeping track of previous FreeBSD successful build jobs, marking them as permanent and fetching them from the database in order to pass them on the env variable.

I promised to help you with this.

Quoted 4 lines

The second missing bit is setting daily-cron-email-freebsd to send emails to the xen-devel mailing list, ATM it's only sending emails to my personal @FreeBSD.org address (this has been done for testing purposes).

Right.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel