[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 23/26] rumprun: `rumpbake' our executables and run them with `rumprun'



(Well, our one executable: xenstore-ls)

Modern rumprun requires the output of the linker to be `baked' (second
link phase, where the complete unikernel is assembled).

This has to be done as part of the build, because it needs all the
rumpkernel libraries.  It generates a single image file - there is no
longer any disk image or config file produced by the rump ecosystem.

The baked file needs to be provided in a dist.  We have
ts-rumprun-bake take command line argument specifying which things to
bake.  It reads the runvars for the source executables and creates a
single dist output containing the images.  There are now `executables'
and `images'.

Furthermore modern rumprun requires the image to be run with
`rumprun'.  One underlying reason is that it wants to pass the command
line and some other config parameters to the guest via xenstore, in
/local/domain/GUEST/rumprun/cfg.  To do this outside xl requires the
domain to be created paused.  Another is to abstract away details of
the actual execution environment (compared to other unikernel
execution models).

rumprun has a mode (-D -T) in which it would be possible to fish the
configuration and the desired json object (for the cfg) out of the
tempfile it creates.  It might also be possible for osstest to
construct these out of whole cloth.

However, this would be undesirable because it would break if rumprun
changed (in particular, if the interface to the domain creation
changed).

And because of the cfg wrinkle it still wouldn't let us construct a
domain config file which could be passed to
toolstack($ho)->guest_create.

So instead we invent Osstest::Rumprun::rumprun_guest_create, which
invokes rumprun.  rumprun implicitly invokes xl.

The config editing which was previously done by ts-rumprun-demo-setup
is now done by passing appropriate options to rumprun.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 Osstest/RumpRun.pm         | 67 ++++++++++++++++++++++++++++++++++
 make-flight                |  2 +-
 sg-run-job                 |  2 ++
 ts-rumprun-bake            | 89 ++++++++++++++++++++++++++++++++++++++++++++++
 ts-rumprun-demo-setup      | 52 ++++-----------------------
 ts-rumprun-demo-xenstorels |  3 +-
 6 files changed, 167 insertions(+), 48 deletions(-)
 create mode 100644 Osstest/RumpRun.pm
 create mode 100755 ts-rumprun-bake

diff --git a/Osstest/RumpRun.pm b/Osstest/RumpRun.pm
new file mode 100644
index 0000000..0582bd2
--- /dev/null
+++ b/Osstest/RumpRun.pm
@@ -0,0 +1,67 @@
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2009-2013 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/>.
+
+
+package Osstest::RumpRun;
+
+use strict;
+use warnings;
+
+use Osstest::TestSupport;
+
+BEGIN {
+    use Exporter ();
+    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
+    $VERSION     = 1.00;
+    @ISA         = qw(Exporter);
+    @EXPORT      = qw(
+                     rumprun_guest_create
+                   );
+    %EXPORT_TAGS = ( );
+
+    @EXPORT_OK   = qw();
+}
+
+sub rumprun_guest_create ($) {
+    my ($gho) = @_;
+    my $ho = $gho->{Host};
+    my $gn = $gho->{Guest};
+    guest_prepare_disk($gho);
+
+    my $rumprun = target_var($gho, 'rumprun_path');
+    if (!$rumprun) {
+       logm("finding rumprun to use for $gho->{Name} on $ho->{Name}");
+       my $buildjob = $r{guests_rumprunbuildjob} // # todo: eliminate this
+           target_var($gho, 'rumprunbuildjob');
+       my $rumprundist = target_extract_jobdistpath_subdir
+           ($ho, "rumprun-rumprun-g-$gho->{Name}", "rumprun", $buildjob);
+       $rumprun = "$rumprundist/rumprun";
+       store_runvar("${gn}_rumprun_path", $rumprun);
+    }
+
+    my $imagepath = $r{"${gn}_imagepath"};
+    my $cmdline = guest_var($gho, 'cmdline', undef);
+
+    my $cmd = "$rumprun xen";
+    $cmd .= " -N $gn";
+    $cmd .= " -IIFTAG,IFBASENAME,mac=$gho->{Ether}";
+    $cmd .= " $imagepath";
+    $cmd .= " $cmdline";
+
+    target_cmd_root($ho, $cmd, 100);
+}
+
+1;
diff --git a/make-flight b/make-flight
index 906bf2b..c94dfa4 100755
--- a/make-flight
+++ b/make-flight
@@ -203,7 +203,7 @@ do_rumpkernel_tests () {
             guests_rumprunbuildjob=build-$rumparch-rumprun   \
      rump_builtimage=rumprun:/usr/local/lib/xen/rump-kernel/rump-kernel \
             rump_cmdline=3                                           \
-            xenstorels_builtimage=:/usr/local/bin/xenstore           \
+            xenstorels_builtimage=rumpimages:xenstorels              \
             xenstorels_cmdline='ls -fp device'                       \
             all_hostflags=$most_hostflags
 }
diff --git a/sg-run-job b/sg-run-job
index eb3df26..6d455c7 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -478,6 +478,8 @@ proc run-job/build-libvirt {} {
 proc run-job/build-rumprun {} {
     run-ts . = ts-rumprun-build
     run-ts . = ts-xen-build + host --no-kconfig tools
+    run-ts . = ts-rumprun-bake + host \
+        xenstorels ::/usr/local/bin/xenstore-ls
 }
 
 proc prepare-build-host {} {
diff --git a/ts-rumprun-bake b/ts-rumprun-bake
new file mode 100755
index 0000000..d79d6f8
--- /dev/null
+++ b/ts-rumprun-bake
@@ -0,0 +1,89 @@
+#!/usr/bin/perl -w
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2009-2013 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/>.
+
+# ts-rumprun-bake HOST IMAGENAME [JOB]:DIST:SUBPATH [IMAGENAME ... [... ...]]
+#
+# Generates a dist stash `rumpimages' containg files IMAGENAME
+# From the specified files
+
+use strict qw(vars);
+use DBI;
+use Osstest;
+use Osstest::TestSupport;
+use Osstest::BuildSupport;
+
+tsreadconfig();
+
+our ($whhost,$gn) = @ARGV;
+selectbuildhost(\@ARGV);
+
+
+
+our %images;
+
+our $jobdir = target_jobdir($ho);
+our $imagesdir = $jobdir.'/rumpbake-images';
+our $rumpbake = $jobdir.'/rumprun/rumprun/bin/rumprun-bake';
+
+target_cmd($ho, "mkdir -p $imagesdir");
+
+sub bakeimage ($$) {
+    my ($name,$spec) = @_;
+    
+    $spec =~ m/^(.*?)\:(.*?)\:/ or die "$spec ?";
+    my $buildjob = $1;
+    my $execpart = $2;
+    my $execpath = $';
+
+    logm("baking rump image $name from $spec");
+
+#    my $rumpbake = target_extract_jobdistpath_subdir
+#      ($ho, 'rumpbake-base', 'rumprun', $r{guests_rumprunbuildjob});
+#    $rumpbake = "$rumpbake/rumpbake";
+
+    my $execdist;
+    eval {
+       $execdist = target_extract_jobdistpath_subdir
+           ($ho, "rumpbake-n-$name", $execpart, $buildjob || $job);
+    };
+    if ($@) {
+       warn "skipping: $@";
+       return;
+    }
+    my $execfile = $execdist.$execpath;
+
+    target_cmd_build($ho, 1000, $imagesdir, <<END);
+        if test -f $execfile; then
+            $rumpbake xen_pv $name $execfile
+        fi
+END
+}
+
+sub stash () {
+    built_stash($ho, "$jobdir", "rumpbake-images", "rumpimagesdist");
+}
+
+while (@ARGV) {
+    die unless @ARGV>=2;
+    my $name = shift @ARGV;
+    my $rumpexec = shift @ARGV;
+    eval {
+       bakeimage($name,$rumpexec);
+    };
+}
+
+stash();
diff --git a/ts-rumprun-demo-setup b/ts-rumprun-demo-setup
index 655328f..212d758 100755
--- a/ts-rumprun-demo-setup
+++ b/ts-rumprun-demo-setup
@@ -35,58 +35,18 @@ our $rkdist;
 sub prep () {
     $gho = prepareguest($ho, $gn, $gn, 4096, undef, 30);
 
-    my $cfg_rkdist = target_extract_jobdistpath_subdir
-       ($ho, 'rumprun--base', 'rumprun',
-        $r{guests_rumprunbuildjob});
-    $cfg_rkdist .= '/usr/local/lib/xen/rump-kernel';
-
-    my $buildjob = guest_var($gho, 'rumprunbuildjob', undef);
     my $builtimage = guest_var($gho, 'builtimage', undef);
+    my $buildjob = guest_var($gho, 'rumprunbuildjob', undef);
+
     $builtimage =~ m/\:/ or die "$builtimage ?";
     my $builtimage_part = $`;
     my $builtimage_subpath = $'; #';
-    $rkdist = target_extract_jobdistpath_subdir
-       ($ho, "rumprun-$gn", $builtimage_part, $buildjob);
-    my $imagefile = $rkdist.$builtimage_subpath;
-    my $cmdline = guest_var($gho, 'cmdline', undef);
-
-    my @images;
-
-    my $fsimagesdir = target_jobdir($ho)."/$gn-images";
 
-    my $cfgfile = "$gn.cfg";
-    my $cfgpath = "/etc/xen/$cfgfile";
-    target_editfile_root($ho, "$cfg_rkdist/domain_config", $cfgfile, $cfgpath,
-                        sub {
-       while (<EI>) {
-           next if m/^\s*\#/;
-           next unless m/\S/;
-
-           my $in = $& if m/^\w\S*/;
-
-           s# = .*              # " = '$gn'"          #xe  if $in eq 'name';
-           s# = .*              # " = '$imagefile'"   #xe  if $in eq 'kernel';
-           s#\b mac=[0-9a-f:]+  # "mac=$gho->{Ether}" #xe  if $in eq 'vif';
-           s# = .*              # " = '$cmdline'"     #xe  if $in eq 'extra';
-
-           if ($in eq 'disk') {
-               s{\b img/(\w+.ffs) \b}{
-                    push @images, $1;
-                    "$fsimagesdir/$1";
-                }xeg;
-           }
-
-           print EO or die $!;
-       }
-    });
-
-    store_runvar("$gho->{Guest}_cfgpath", $cfgpath);
+    $rkdist = target_extract_jobdistpath_subdir
+       ($ho, "rumprun-g-$gn", $builtimage_part, $buildjob);
+    my $imagepath = $rkdist.'/'.$builtimage_subpath;
 
-    target_cmd($ho, <<END.(join "\n", map { <<END; } @images), 200);
-                   mkdir -p $fsimagesdir
-END
-                   cp $cfg_rkdist/img/$_ $fsimagesdir/$_
-END
+    store_runvar("${gn}_imagepath", $imagepath);
 }
 
 prep();
diff --git a/ts-rumprun-demo-xenstorels b/ts-rumprun-demo-xenstorels
index a54fbf4..47aa289 100755
--- a/ts-rumprun-demo-xenstorels
+++ b/ts-rumprun-demo-xenstorels
@@ -19,6 +19,7 @@ use strict qw(vars);
 use DBI;
 use Osstest;
 use Osstest::TestSupport;
+use Osstest::RumpRun;
 use Data::Dumper;
 
 tsreadconfig();
@@ -44,7 +45,7 @@ sub arrangepreserve () {
 }
 
 sub start () {
-    guest_create($gho);
+    rumprun_guest_create($gho);
 
     $domid = guest_find_domid($ho, $gho);
 }
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.