Giter Club home page Giter Club logo

rumprun's People

Contributors

anttikantee avatar derangedmonkeyninja avatar esotsal avatar fltt avatar gaffo avatar gandro avatar ijackson-citrix avatar justincormack avatar kent-mcleod avatar kevinboulain avatar liuw avatar mato avatar najamelan avatar nyx avatar sg2342 avatar thedrow avatar tjfontaine avatar tombousso avatar yarlb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rumprun's Issues

gcc may generate references not satisfied by libc++ (HIGH PRIORITY)

how-to-repeat:

  • build rumprun against NetBSD HEAD
  • build pcre from rumprun-packages against said build

Result:

  CXXLD    pcrecpp_unittest
pcrecpp_unittest: In function `pcrecpp::RE::DoMatch(pcrecpp::StringPiece const&, pcrecpp::RE::Anchor, int*, pcrecpp::Arg const* const*, int) const':
(.text+0x57ce): undefined reference to `__cxa_throw_bad_array_new_length'
collect2: error: ld returned 1 exit status

This is a high priority problem since it prevents from updating to latest NetBSD sources.

unikernel read from stdin returns EOF (qemu/x86_64)

I followed the Tutorial: Building Rumprun Unikernels. Starting from
helloer.c, I successfully built and ran helloer-rumprun.bin on my host
(Mac OS X 10.11.1). helloer.c uses printf to write to stdout (the
qemu console display).

I wrote a similar program echoer.c which also uses fgets to read from
stdin (see program below). It works as expected when compiled and run
on my host: fgets reads input from the keyboard, unless I signal
end-of-file by typing ^D (output below). But when I follow the
same procedure I used to build and run helloer-rumprun.bin on qemu, in
my echoer-rumprun.bin the first call to fgets returns EOF immediately, without
reading from the keyboard (output below).

I would like my rumprun programs to read keyboard input from stdin.
How can I achieve this?

I discovered this behavior while working with rumprun-packages/python.
I successfully built and ran the hw.py/.c/.bin example, which uses
Python print to write to stdout. But when I replaced hw.py (etc.)
with my own echo.py/.c/.bin that also uses the Python input function
to read from stdin, the call to input raises the Python EOFError.

In Python also, I would like to read keyboard input from stdin.

Jon Jacky

/* echoer.c - test reading from stdin in rump kernel */

#include <stdio.h>

int main()
{
  char string[80];
  char *result = "Anything but NULL";
  while (result != NULL) {
    printf (">> ");
    result = fgets(string,80,stdin); /* returns null pointer if EOF */
    if (result != NULL) printf ("%s", string);
  }
  printf("EOF\n");
  return 0;
}
# running echoer on host, Mac OS X 10.11.1.  It echoes until you type ^D to indicate EOF.

$ ./echoer
>> Hello
Hello
>> world
world
>> EOF
$
# running echoer-rumprun.bin unikernel in qemu on host, Mac OS X 10.11.1
# It returns EOF Immediately, then exits

$ rumprun qemu -i echoer-rumprun.bin
...
In qemu window:
...
=== calling "echoer-rumprun.bin" main() ===

>> EOF

=== main() of "echoer-rumprun.bin" returned 0 ===

=== ERROR: _exit(0) called ===
...

rumprun does not handle spaces in arguments naturally

As reported by @ether42 on irc:

e.g.: rumprun ... foo.bin "a b" => argv[1] = a, argv[2] = b

You can use e.g. rumprun ... foo.bin "'a b'" for argv[1] = a b, but that is against POLA.

Fix: most likely need to change rumprun to pass cmdline as a json array, and also the rumpconfig counterpart.

build-rr.sh fails if CDPATH is set

If CDPATH is set then bash's cd can print the path. This causes platform/hw/pci/Makefile.pci's:

PCIDIR!=        cd ${.PARSEDIR} ; pwd -P

to set PCIDIR to the same path twice (once from cd, once from pwd).

The fix is to unset CDPATH. I'm guessing either buildrump or build-rr should do this.

FreeBSD rumprun qemu ./hellopp.bin fails

rumpkernel/rumprun at 0afa70e
hw platform and tests created using

export CC=gcc48
export CXX=g++48
export MAKE=gmake
./build-rr.sh -qq hw -- -F ACLFLAGS=-m32 -F ACLFLAGS=-march=i686
./tests/buildtests.sh hw

backtrace for ./app-tools/rumprun qemu -i -p -D 1234 tests/hello/hellopp.bin

[sg@bath ~/devel/rumprun]$ /usr/local/bin/gdb -q tests/hello/hellopp.bin 
Reading symbols from tests/hello/hellopp.bin...done.
(gdb) target remote:1234
Remote debugging using :1234
0x0000fff0 in ?? ()
(gdb) break _lwpabort
Breakpoint 1 at 0x30fff0: file /home/sg/devel/rumprun/lib/librumprun_base/_lwp.c, line 367.
(gdb) c
Continuing.

Breakpoint 1, _lwpabort () at /home/sg/devel/rumprun/lib/librumprun_base/_lwp.c:367
367 {
(gdb) bt
#0  _lwpabort () at /home/sg/devel/rumprun/lib/librumprun_base/_lwp.c:367
#1  0x00340018 in raise (s=s@entry=6) at /home/sg/devel/rumprun/src-netbsd/lib/libc/gen/raise.c:48
#2  0x0033fc5a in abort () at /home/sg/devel/rumprun/src-netbsd/lib/libc/stdlib/abort.c:74
#3  0x0011ad47 in report_failure (err=<optimized out>, thrown_exception=0x4a7a10) at rt_exception.cc:696
#4  0x003571e1 in std::__1::__vector_base_common<true>::__throw_length_error (this=this@entry=0x45e3e8 <std::__1::locale::__imp& std::__1::(anonymous namespace)::make<std::__1::locale::__imp, unsigned int>(unsigned int)::buf+8>) at /home/sg/devel/rumprun/src-netbsd/external/bsd/libc++/dist/libcxx/include/vector:305
#5  0x00357608 in __recommend (__new_size=4294967295, this=0x45e3e8 <std::__1::locale::__imp& std::__1::(anonymous namespace)::make<std::__1::locale::__imp, unsigned int>(unsigned int)::buf+8>) at /home/sg/devel/rumprun/src-netbsd/external/bsd/libc++/dist/libcxx/include/vector:949
#6  std::__1::vector<std::__1::locale::facet*, std::__1::__sso_allocator<std::__1::locale::facet*, 28u> >::__append (this=0x45e3e8 <std::__1::locale::__imp& std::__1::(anonymous namespace)::make<std::__1::locale::__imp, unsigned int>(unsigned int)::buf+8>, __n=4294967295)
    at /home/sg/devel/rumprun/src-netbsd/external/bsd/libc++/dist/libcxx/include/vector:1041
#7  0x00114012 in resize (__sz=4294967295, this=0x45e3e8 <std::__1::locale::__imp& std::__1::(anonymous namespace)::make<std::__1::locale::__imp, unsigned int>(unsigned int)::buf+8>) at /home/sg/devel/rumprun/src-netbsd/external/bsd/libc++/dist/libcxx/include/vector:1983
#8  std::__1::locale::__imp::install (this=this@entry=0x45e3e0 <std::__1::locale::__imp& std::__1::(anonymous namespace)::make<std::__1::locale::__imp, unsigned int>(unsigned int)::buf>, 
    f=f@entry=0x45e5c0 <std::__1::collate<char>& std::__1::(anonymous namespace)::make<std::__1::collate<char>, unsigned int>(unsigned int)::buf>, id=-2) at /home/sg/devel/rumprun/src-netbsd/external/bsd/libc++/lib/../dist/libcxx/src/locale.cpp:441
#9  0x001140c9 in install<std::__1::collate<char> > (f=0x45e5c0 <std::__1::collate<char>& std::__1::(anonymous namespace)::make<std::__1::collate<char>, unsigned int>(unsigned int)::buf>, 
    this=0x45e3e0 <std::__1::locale::__imp& std::__1::(anonymous namespace)::make<std::__1::locale::__imp, unsigned int>(unsigned int)::buf>) at /home/sg/devel/rumprun/src-netbsd/external/bsd/libc++/lib/../dist/libcxx/src/locale.cpp:164
#10 std::__1::locale::__imp::__imp (this=0x45e3e0 <std::__1::locale::__imp& std::__1::(anonymous namespace)::make<std::__1::locale::__imp, unsigned int>(unsigned int)::buf>, refs=1) at /home/sg/devel/rumprun/src-netbsd/external/bsd/libc++/lib/../dist/libcxx/src/locale.cpp:178
#11 0x001147a4 in make<std::__1::locale::__imp, unsigned int> (a0=<optimized out>) at /home/sg/devel/rumprun/src-netbsd/external/bsd/libc++/lib/../dist/libcxx/src/locale.cpp:70
#12 make_classic () at /home/sg/devel/rumprun/src-netbsd/external/bsd/libc++/lib/../dist/libcxx/src/locale.cpp:465
#13 std::__1::locale::classic () at /home/sg/devel/rumprun/src-netbsd/external/bsd/libc++/lib/../dist/libcxx/src/locale.cpp:472
#14 0x001147f8 in std::__1::locale::__imp::make_global () at /home/sg/devel/rumprun/src-netbsd/external/bsd/libc++/lib/../dist/libcxx/src/locale.cpp:481
#15 0x00114845 in std::__1::locale::__global () at /home/sg/devel/rumprun/src-netbsd/external/bsd/libc++/lib/../dist/libcxx/src/locale.cpp:488
#16 0x0011488d in std::__1::locale::locale (this=0x45d968 <std::__1::__cin+4>) at /home/sg/devel/rumprun/src-netbsd/external/bsd/libc++/lib/../dist/libcxx/src/locale.cpp:493
#17 0x001025ff in basic_streambuf (this=0x45d964 <std::__1::__cin>) at /home/sg/devel/rumprun/src-netbsd/external/bsd/libc++/dist/libcxx/include/streambuf:370
#18 __stdinbuf (__st=0x45d9a0 <std::__1::state_types>, __fp=<optimized out>, this=0x45d964 <std::__1::__cin>) at /home/sg/devel/rumprun/src-netbsd/external/bsd/libc++/dist/libcxx/include/__std_stream:73
#19 std::__1::ios_base::Init::Init (this=0x45d5c0 <std::__1::__start_std_streams>) at /home/sg/devel/rumprun/src-netbsd/external/bsd/libc++/lib/../dist/libcxx/src/iostream.cpp:38
#20 0x00346c1f in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at /home/sg/devel/rumprun/src-netbsd/external/bsd/libc++/lib/../dist/libcxx/src/iostream.cpp:34
#21 _GLOBAL__sub_I__ZNSt3__13cinE () at /home/sg/devel/rumprun/src-netbsd/external/bsd/libc++/lib/../dist/libcxx/src/iostream.cpp:68
#22 0x0030e752 in runinit () at /home/sg/devel/rumprun/lib/librumprun_base/netbsd_initfini.c:68
#23 _netbsd_userlevel_init () at /home/sg/devel/rumprun/lib/librumprun_base/netbsd_initfini.c:96
#24 0x0030e464 in rumprun_boot (cmdline=cmdline@entry=0x49c260 <bmk_multiboot_cmdline> "tests/hello/hellopp.bin \t\t {, \n\t\"cmdline\": \"tests/hello/hellopp.bin\", \n\t\t}, ") at /home/sg/devel/rumprun/lib/librumprun_base/rumprun.c:83
#25 0x00100f0f in bmk_mainthread (cmdline=0x49c260 <bmk_multiboot_cmdline>) at init.c:36
#26 0x00345b89 in bmk_cpu_sched_bouncer ()

Building bare metal arm fails

Building with the following fails:
CC=arm-none-eabi-gcc ./build-rr.sh hw

Building with the following and two patches succeeds:
CC=arm-none-eabi-gcc NOGCCERROR=yes ./build-rr.sh hw --
-F CPPFLAGS=-I$PWD/rumprun/platform/hw/rump/include

Patch buildrump.sh/buildrump.sh to correct floating point detection.
Patch platform/hw/Makefile; buildtest target is broken because rumpbake hw_generic is not compatible with arm machine.

diff --git a/buildrump.sh b/buildrump.sh
index 4c8661d..7dde205 100755
--- a/buildrump.sh
+++ b/buildrump.sh
@@ -1115,7 +1115,7 @@ probearm ()
# build to use hardfloat if the compiler defaults to VFP.
# This is because the softfloat env is not always functional
# in case hardfloat is the compiler default.

  •   if cppdefines **VFP_FP**; then
    
  •   if cppdefines __ARM_PCS_VFP; then
            hf=hf
    else
            hf=
    

diff --git a/platform/hw/Makefile b/platform/hw/Makefile
index 6d2ff03..ad3c6b3 100644
--- a/platform/hw/Makefile
+++ b/platform/hw/Makefile
@@ -9,7 +9,8 @@ include ${BUILDRUMP_TOOLFLAGS}
endif

ifneq (${KERNONLY},true)
-TARGETS:= app-tools userlibs buildtest
+#TARGETS:= app-tools userlibs buildtest
+TARGETS:= app-tools userlibs
else
TARGETS:= compiler_rt
endif
@@ -32,7 +33,7 @@ endif
ifeq (${MACHINE},amd64)
supported:= true
endif
-ifeq (${MACHINE},evbarm)
+ifeq (${MACHINE},evbearm-el)
supported:= true
HASPCI:= n
ARCHDIR= arm/integrator

rumprun made image can not get network device working on xenserver 6.5

Hi,

I'm trying to run rumprun kernel image on XenServer 6.5(SP1, build date 2015-04-17, build number 90233c), it's found the network device in a rumprun-baked image can not work correctly under XenServer 6.5, it can not get or receive any packet from xenbr0(linux bridge or open vswitch). here below is the link to the test result I got from the image after boot it in the XenServer 6.5 environment.

https://gist.github.com/bigben80/b761b060700b7f56457d

Also tried to setup a Ubuntu 15.10 + Xen 4.5.1 environemt for comparing, same image works fine in that environment(both Linux bridage and open vswitch verified).

Time jumps backwards when user code is cpu-bound for long enough

Originally reported by Anton Ivanov as follows:

I'm trying to run some simple benchmarks (whetstone, for example) on rumprun (on XEN and KVM). I face a problem, which was already addressed about 9 months ago by you, more specifically -- timekeeping. In my case the clock is counting 20-30 times slower. It takes roughly 20 seconds for the benchmark to run, however by completion the rumprun clock tells me that only 0.9 seconds had passed. I used different "time" functions including gettimeofday() all of them give the same result.

Investigation with a test program calling getttimeofday() in a busy loop shows that time is "oscillating" around a single second. If sched_yield() is called inside the loop then time flows normally. Problem is reproducible on all platforms (Xen, hw with KVM or QEMU).

xen/bmk: implement out-of-band timecounter for more accurate timekeeping

Due to the combination of -xen and -bmk using a cooperative scheduler and the rump kernel clock driver depending on soft interrupts being scheduled, if an application calls gettimeofday() in a loop without calling sched_yield() then the time values returned are not updated.

This is commonly used in applications to (for example) determine the frequency of a hardware time stamp counter:

    cycles_t cycles_start = get_cycles(),
             cycles_end;
    usecs_t usecs_start = get_usecs(),
            usecs_end;
    for (i= 0; i < 1000000; ++i)
    {
        usecs_end = get_usecs();
        // sched_yield() would need to be called here.
        if (usecs_end - usecs_start > 200)
            break;
    }
    cycles_end = get_cycles();
    cycles_t freq = (1000000ULL * (cycles_end - cycles_start)) /
                    (usecs_end - usecs_start);

The above code will crash with a division by zero due to usecs_end never being updated.
The solution is to implement an out-of-band timecounter driver for the rump kernel which does not rely on clock interrupts.

C++ exception handling not working

The following test program

#include <iostream>
using namespace std;

int main()
{
    try {
        throw 1234;
    }
    catch (int e) {
        cout << "Caught exception: " << e << endl;
    }
    return 0;
}

Should produce:

Caught exception: 1234

Instead, it produces:

=== calling "./testex.bin" main() ===

rumprun: call to ``_sys___sigprocmask14'' ignored
_lwpabort() called

=== ERROR: _exit(1) called ===

librumpxen_xendev broken due to header abuse

librumpxen_xendev will break when src-netbsd is next updated, so I'll disable its build pending someone wanting to have fun fixing it. Hopefully the fix will be actually fixing it by not including headers from multiple sources in the same file as opposed to adding more finicky and inevitably breaking ifdefs.

trap #UD

I've got Node.js compiling and baking but when I run it, I get

trap: #UD

in a loop. Any ideas?

times() causes a crash due to incorrect implementation of STUB()

Any call to the times() system call will cause a crash (division by zero). The root cause is due to:

  • times() calls getrusage()
  • getrusage() is a STUB()
  • STUB() is defined as returning ENOTSUP rather than -1.

The correct behaviour for STUB should be to return -1, however this may cause applications to stop working due to calls returning errors. More discussion is needed, and/or different definitions of stubs.

run an instance on ec2

i'm looking for help running an instance on ec2 using

rumprun ec2 <flags> <image>.bin

i am able to get my nginx.bin into AMI form, and it appears to boot, but quickly goes into stopped mode on amazon

here are the steps i've been following to bring the image up, based on the freelist post: https://www.freelists.org/post/rumpkernel-users/Amazon-EC2-support-now-in-Rumprun

_building binary_
based on https://github.com/rumpkernel/wiki/wiki/Tutorial%3A-Serve-a-static-website-as-a-Unikernel:
replacing

rumprun-bake hw_virtio ./nginx.bin bin/nginx

with

rumprun-bake xen_pv ./nginx.bin bin/nginx

which finishes without error.
i then run:

root@323c362efdc0:~/rumprun-packages/nginx# rrumprun ec2 -I 'qnet0,xenif' -W 'qnet0,inet,dhcp' -b images/stubetc.iso,/etc -b images/data.iso,/data -- nginx.bin -c /data/conf/nginx.conf

!!!
!!! NOTE: rumprun is experimental. syntax may change in the future
!!!

Done.  Place contents of "rumprun-nginx.bin.ec2dir" to EC2 volume and boot.

i then tar the directory, scp it to an instance running on EC2. then, from a terminal inside that machine (copied/modified from freelist.org post):

tar xvf rumprun-nginx.tar.gz
export AWS_ACCESS_KEY=<secret>
export AWS_SECRET_KEY=<secret>
./make-unikernel-snapshot.sh -p rumprun-nginx.bin.ec2dir/ -k rumprun-nginx.bin.ec2dir/boot/nginx.bin

the contents of make-unikernel-snapshot.sh:

SUDO=sudo
UNIKERNELMOUNTPOINT=/mnt/unikernel
FILESYSTEMMOUNTPOINT=/mnt/filesystem
THISINSTANCEID=`wget -q -O - http://instance-data/latest/meta-data/instance-id`
THISREGION=`wget -q -O - http://instance-data/latest/dynamic/instance-identity/document | awk '/region/ {gsub(/[",]/, "", $3); print $3}'`
THISAVAILABILITYZONE=`wget -q -O - http://instance-data/latest/dynamic/instance-identity/document | awk '/availabilityZone/ {gsub(/[",]/, "", $3); print $3}'`
case "${THISREGION}" in ap-northeast-1) KERNELID=aki-176bf516; ;; ap-southeast-1) KERNELID=aki-503e7402; ;; ap-southeast-2) KERNELID=aki-c362fff9; ;; eu-central-1) KERNELID=aki-184c7a05; ;; eu-west-1) KERNELID=aki-52a34525; ;; sa-east-1) KERNELID=aki-5553f448; ;; us-east-1) KERNELID=aki-919dcaf8; ;; us-gov-west-1) KERNELID=aki-1de98d3e; ;; us-west-1) KERNELID=aki-880531cd; ;; us-west-2) KERNELID=aki-fc8f11cc; ;; *) echo $"Error selecting pvgrub kernel for region"; exit 1; esac
while getopts "h:p:n:r:k:" arg; do case $arg in h) echo "usage: $0 [-h] [-n <name>] [-r <region>] -k <unikernel> -p
<filesystempath> "; echo "usage: $0 [-h] [-n <name>] [-r <region>] -k <unikernel> -p
<filesystempath> "; echo ""; echo "<filesystempath>: Directory path to copy to block file system and
attach to unikernel"; echo "<unikernel>: Name of the kernel file (e.g. rump.xen)"; echo "<name>: the application name to use (default: ${NAME})"; echo "<region>: the EC2 region to register AMI in (default: ${THISREGION})";  echo To run this script you will need the Amazon command line tools ; installed from here:; echo ; http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/set-up-ec2-cli-linux.html; echo ""; echo Remember to set each of the following environment variables in your; echo environment before running this script:; echo AWS_ACCESS_KEY; echo AWS_SECRET_KEY; exit 1 ;; p) FILESYSTEMPATH=$OPTARG ;; n) NAME=$OPTARG ;; r) THISREGION=$OPTARG ;; k) UNIKERNELFILE=$OPTARG ;; esac; done
if [ ! -e "${FILESYSTEMPATH}" ]; then
echo "Must specify a file system path file with the [-p] flag."
echo "Run '$0 -h' for full option list."
exit 1
fi

if [ ! -e "${UNIKERNELFILE}" ]; then
echo "Must specify a unikernel file with the [-k] flag."
echo "Run '$0 -h' for full option list."
exit 1
fi

# Make name unique to avoid registration clashes
NAME=${NAME}-`date +"%d-%b-%Y-%s"`

echo Name : ${NAME}
echo THISREGION: ${THISREGION}
echo THISINSTANCEID: ${THISINSTANCEID}
echo THISAVAILABILITYZONE: ${THISAVAILABILITYZONE}
echo UNIKERNELMOUNTPOINT: ${UNIKERNELMOUNTPOINT}
echo FILESYSTEMMOUNTPOINT: ${FILESYSTEMMOUNTPOINT}
echo UNIKERNELFILE: ${UNIKERNELFILE}
echo FILESYSTEMPATH: ${FILESYSTEMPATH}

##########################################################################################
##########################################################################################
###### prepare block device
###### this will be the root file system for the unikernel
##########################################################################################
##########################################################################################

# create a 1 GB EBS volume using the AWS console
#http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-CreateVolume.html
UNIKERNELVOLUMEID=`ec2-create-volume --aws-access-key ${AWS_ACCESS_KEY} --aws-secret-key ${AWS_SECRET_KEY} --availability-zone ${THISAVAILABILITYZONE} --region ${THISREGION} -s 1 | awk '{print $2}'`

# wait for EC2 to get its act together
echo Waiting for create volume to complete......
sleep 10

# attach the EBS volume
#http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-AttachVolume.html
ec2-attach-volume ${UNIKERNELVOLUMEID} --aws-access-key ${AWS_ACCESS_KEY} --aws-secret-key ${AWS_SECRET_KEY} --region ${THISREGION} --instance ${THISINSTANCEID} --device /dev/xvdk

echo Waiting for attach volume to complete......
sleep 10

# unmount any existing volume at the UNIKERNELMOUNTPOINT
set +e
${SUDO} umount ${UNIKERNELMOUNTPOINT}
set -e

# create the UNIKERNELMOUNTPOINT
${SUDO} mkdir -p ${UNIKERNELMOUNTPOINT}

# format the EBS volume as ext2
${SUDO} mkfs -t ext2 /dev/xvdk

#Label the disk. AWS has an unofficial tutorial that does not include this step.
${SUDO} tune2fs -L '/' /dev/xvdk

# mount the device
${SUDO} mount /dev/xvdk ${UNIKERNELMOUNTPOINT}

# set permissions
${SUDO} chmod -R ug+rwx ${UNIKERNELMOUNTPOINT}

${SUDO} mkdir -p ${UNIKERNELMOUNTPOINT}/boot/grub
echo default 0 > menu.lst
echo timeout 1 >> menu.lst
echo title Rump >> menu.lst
echo " root (hd0)" >> menu.lst
echo " kernel /boot/rump-os.gz" >> menu.lst
${SUDO} mv menu.lst ${UNIKERNELMOUNTPOINT}/boot/grub/menu.lst
${SUDO} gzip -c ${UNIKERNELFILE} > ./rump-os.gz
${SUDO} mv ./rump-os.gz ${UNIKERNELMOUNTPOINT}/boot/.

# show what is in the target
${SUDO} find ${UNIKERNELMOUNTPOINT}

# unmount any existing volume at the UNIKERNELMOUNTPOINT
${SUDO} umount ${UNIKERNELMOUNTPOINT}

# detach the EBS volume
#http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-DetachVolume.html
ec2-detach-volume --aws-access-key ${AWS_ACCESS_KEY} --aws-secret-key ${AWS_SECRET_KEY} --region ${THISREGION} ${UNIKERNELVOLUMEID}

##########################################################################################
###### prepare the unikernel for booting on EC2
##########################################################################################

# make a snapshot of the unikernel root block volume
# -- AMI’s cannot be created from volumes, only from snapshots
UNIKERNELSNAPSHOTID=`ec2-create-snapshot --aws-access-key ${AWS_ACCESS_KEY} --aws-secret-key ${AWS_SECRET_KEY} --description 'unikernel boot volume' --region ${THISREGION} ${UNIKERNELVOLUMEID} | awk '{print $2}'`

# Create image/AMI from the snapshot
#http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-CreateImage.html
## HAVING TROUBLE? COULD IT BE [--root-device-name name]
echo Waiting for snapshot to complete......
sleep 20

AMIID=`ec2-register --aws-access-key ${AWS_ACCESS_KEY} --aws-secret-key ${AWS_SECRET_KEY} --name "${NAME}" \
--description "${NAME}" \
-a x86_64 \
-s ${UNIKERNELSNAPSHOTID} \
--region ${THISREGION} \
--kernel ${KERNELID} \
--virtualization-type paravirtual \
| awk '{print $2}'`

##########################################################################################
###### finish
##########################################################################################

echo You can now start this instance via:
echo ec2-run-instances --region ${THISREGION} ${AMIID}
echo ""
echo Don\'t forget to customise this with a security group, as the
echo default one won\'t let any inbound traffic in.


after this, i get an ami that i can boot an instance from. i can peek the system log from the instance through the AWS UI:

Xen Minimal OS!
  start_info: 0xae2000(VA)
    nr_pages: 0x26700
  shared_inf: 0x7dcc9000(MA)
     pt_base: 0xae5000(VA)
nr_pt_frames: 0x9
    mfn_list: 0x9ae000(VA)
   mod_start: 0x0(VA)
     mod_len: 0
       flags: 0x0
    cmd_line: root=/dev/sda1 ro 4
  stack:      0x96d840-0x98d840
MM: Init
      _text: 0x0(VA)
     _etext: 0x7dc7d(VA)
   _erodata: 0x9a000(VA)
     _edata: 0x9fce0(VA)
stack start: 0x96d840(VA)
       _end: 0x9ade40(VA)
  start_pfn: af1
    max_pfn: 26700
Mapping memory range 0xc00000 - 0x26700000
setting 0x0-0x9a000 readonly
skipped 0x1000
MM: Initialise page allocator for c1f000(c1f000)-26700000(26700000)
MM: done
Demand map pfns at 26701000-2026701000.
Heap resides at 2026702000-4026702000.
Initialising timer interface
Initialising console ... done.
gnttab_table mapped at 0x26701000.
Initialising scheduler
Thread "Idle": pointer: 0x2026702050, stack: 0x26660000
Thread "xenstore": pointer: 0x2026702800, stack: 0x26670000
xenbus initialised on irq 1 mfn 0x104a653
Thread "shutdown": pointer: 0x2026702fb0, stack: 0x26680000
Dummy main: start_info=0x98d940
Thread "main": pointer: 0x2026703760, stack: 0x26690000
"main" "root=/dev/sda1" "ro" "4" 
vbd 2049 is hd0
******************* BLKFRONT for device/vbd/2049 **********


backend at /local/domain/0/backend/vbd/25601/2049
Failed to read /local/domain/0/backend/vbd/25601/2049/feature-barrier.
Failed to read /local/domain/0/backend/vbd/25601/2049/feature-flush-cache.
2097152 sectors of 512 bytes
**************************
�[H�[J

    GNU GRUB  version 0.97  (629760K lower / 0K upper memory)



�[m�[4;2H+-------------------------------------------------------------------------+�[5;2H|�[5;76H|�[6;2H|�[6;76H|�[7;2H|�[7;76H|�[8;2H|�[8;76H|�[9;2H|�[9;76H|�[10;2H|�[10;76H|�[11;2H|�[11;76H|�[12;2H|�[12;76H|�[13;2H|�[13;76H|�[14;2H|�[14;76H|�[15;2H|�[15;76H|�[16;2H|�[16;76H|�[17;2H+-------------------------------------------------------------------------+�[m

    Use the ^ and v keys to select which entry is highlighted.

    Press enter to boot the selected OS, 'e' to edit the

    commands before booting, or 'c' for a command-line.  

this is not what i see when i locally run

rumprun qemu -M 128 -i -b images/stubetc.iso,/etc -b images/data.iso,/data -g '-nographic -vga none' -- nginx.bin -c /data/conf/nginx.conf

a hw-virtio baked version of the same image. the instance stops shortly after booting; i am unable to connect to / ping the instance in any way (security group rules are open)

any help would be greatly appreciated.

Specify default C++ standard in a non-broken way

Currently, we require at least c++11. Since not all compilers default to at least c++11, we need a default standard. That default is currently set in the compiler wrapper (the one generated from cc.in) when the C++ compiler is used. That least to the following window of brokenness:

gcc -c foo.cc
g++ -o foo foo.o

I have not found a way to specify -std=c++11 so that it is used for cpp only when c++ is being compiled. If we don't specify it for cpp, the value of _cplusplus is wrong. If we do, gcc will complain if you do not build c++ code.

Improve xen network performance

The current interface between the rump kernel and the minios netfront requires copying all packets both ways. In fact, on the receive path the data are copied twice.

To improve things:

  1. adjust netfront so that it supports packet reference counting and scatter-gather
  2. migrate to the virtif_user component interface from drv-netif-dpdk (it contains multiple performance improvements over the one available in the NetBSD tree)

hw: Implement timekeeping

As reported by @talex5 while testing mirage-console on rumprun:

I also tested mirage-skeleton/console, which worked but ran rather fast (it's supposed to wait 1s between each print). Calling gettimeofday showed the clock running fast for some reason.

@anttikantee notes:

That's because when I wrote the platform, I didn't bother writing a clock driver, and just used "rtdsc" as an approximation.

Linker crashes during building (./build-rr.sh hw) on RHEL6v7

( cd rumprun/lib/librumprunfs_base && RUMPRUN_GENFS_CC="rumprun/obj-amd64-hw/rumptools/bin/x86_64--netbsd-gcc" RUMPRUN_GENFS_OBJCOPY="rumprun/obj-amd64-hw/rumptools/bin/x86_64--netbsd-objcopy" RUMPRUN_GENFS_INCDIR="rumprun/./obj-amd64-hw/dest.stage/include" rumprun/./obj-amd64-hw/app-tools/x86_64-rumprun-netbsd-genfs rumprun/./obj-amd64-hw/lib/librumprunfs_base/librumprunfs_base.a etc )
collect2: ld terminated with signal 11 [Segmentation fault]

Could not initialize SDL(No available video device) - exiting

run the following command:
root@xxxx:~/rumprun/rumprun-packages/nginx# rumprun qemu -i -M 128 -I if,vioif,'-net tap,script=no,ifname=tap0' -W if,inet,static,10.0.120.101/24 -b images/data.iso,/data -- bin/nginx -c /data/conf/nginx.conf

But failed:
Could not initialize SDL(No available video device) - exiting

Error when compiling an existing project with rumprun

Hi,

I followed this tutorial. And I wanted to compile an existing project with cmake.

$ cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=../../rumprun/app-tools/x86_64-rumprun-netbsd-toolchain.cmake .
$ make

cmake was successful. After typing make, I got an error:

fatal error: sys/cpuset.h: No such file or directory
 #include <sys/cpuset.h>

It seems that there is no header file named cpuset.h in rumprun/platform/hw/rump/include/sys

Does anyone know how to solve this problem?

Thanks!

Can't find boot filesystem when booting rumprun ISO image in VirtualBox

Just tried this using the Mirage "hello world" example -- seem to get the following possibly relevant error:

vendor 8086 product 7010 (IDE mass storage, interface 0x8a) at pci0 dev 1 function 1 not configured

...followed by

rumprun: failed to mount rootfs from image

(There are several other devices not configured but they don't seem so relevant :))

allow user-specified rumpbake.conf files

Currently all targets of rumpbake are hardcoded. That means I can't control
what rump components are linked in to the final binary. That's not very
desirable for power users. Being the first one to have such needs I can
certainly foresee other users in the future want to do the same.

I would like to make rumpbake more flexible. That could be done by either
getting rid of the positional arguments or making it accept user provided
config file.

The syntax of rumpbake being experimental means we can get away with any
breakage at this stage.

Thoughts?

Deadlock on high-rate UDP packet sending using NetBSD virtio driver

Full test program: https://gist.github.com/jmmlmendes/aaea56a8b7044487595ef7a6782fc018

Additional details: this happens only when using KVM, not with plain QEMU.

When sending UDP packets at high rate, there is a point when ENOBUFS is always returned despite successive calls to sched_yield() to allow the actual sending to happen (and thus clearing buffers).

For example, the following piece of code will create an infinite loop:

void udp_flood(int fd, struct sockaddr *dst, int pktlen)
{
    struct timeval start, end;
    long long total_us = 0;
    unsigned long long pkt_sent = 0;

    gettimeofday(&start, NULL);

    while (pkt_sent < PACKETS_TO_SEND) {
        if (sendto(fd, payload, mtu, MSG_NOSIGNAL, dst, pktlen) >= 0)
            pkt_sent++;
        else
            printf("errno %d - %s\n", errno, strerror(errno));

        sched_yield();
    }

    gettimeofday(&end, NULL);
    total_us = tv_to_us(&start, &end);
    printf("%llu packets sent in %lld us\n", pkt_sent, total_us);
}

When sleeping between sends, this situation may not happen if the sleep time is high enough.
Seems to me that buffers are being flushed to the host except when they are full (or above a certain threshold), however, when the sending is too fast, buffers are filled and then never cleared.

Have you encountered this situation before?

bug in syscall_mman.c munmap()

I am trying to port erlang to rumpkernel and faced some weird issues. After much effort and line-by-line debugging via gdb I found a critical bug in rumprun. The munmap() implementation do not match the posix description, or as such based on my understanding. This issue results into very strange memory corruption in the erlang code, which is definitely non-trivial.

The issue will strike when the application code tries to deallocate a portion of the memory earlier allocated via mmap (as in syscall_mman.c), while assuming that the rest of the portion should still be available to the application after the munmap() call. This is not true as per the munmap() implementation, which frees the complete memory segment allocated earlier.

{Snip from my the freenode iirc}

<neeraj> The implementation of munmap in rumprun/lib/librumprun_base/syscall_mman.c is probably buggy
<neeraj> the munmap(void *addr, size_t len) just does free(addr) and return 0
<neeraj> If I read man munmap correctly then only the pages who are in the [addr, addr+len)  range should be deallocated instead of de-allocating the complete allocation pointed by addr
<neeraj> In this case erlang is doing a tricky mmap alloc/dealloc, while rump's munmap() implementation deallocating the complete alloc done earlier, resulting in erlang use a deallocated memory location.
<neeraj> This later results into a memory corruption because future allocation allocates the same memory location which is used by erlang.

I spent a small amount of time thinking about a patch and quickly realized that the allocated in lib/libbmk_core/memalloc.c bmk_memalloc() uses a header for the complete block. In case the user wants to deallocate only a part of the original allocation then moving header around and re-aligning is required and can be tricky at times (should be handled correctly).

constructor array points to hyperspace when building with gcc 4.6

I'm not keen on spending time fixing the issue, but documenting it anyway. Most likely some sort of linker script adjustment is necessary, but it was already painful enough zeroing in on the current linker scripts to further go mucking about in them.

If someone produces tested patches, those can of course be merged.

qboot

I'm wondering if qboot would be of use.
You can find some timings I did here.

TLS data is filled with garbage on hw/amd64

Try to use something like __thread int x = 10;, observe x initially being != 10 at runtime.

data points:

  • verified to fail on both qemu and bare metal.
  • TLS bss works fine (and TLS data too after something is assigned in place of the initial garbage).
  • xen/amd64 works fine.

rumpctrl

what is necessary to compile/run a unikernel that can be accessed by rumpctrl?
(by setting RUMP_SERVER=<some_tcp_addr>)

hang with qemu/x86_64 (or kvm) + serial console + mpg123

The following hangs sooner or later:

rumprun qemu -i -I t,vioif,'-net tap,ifname=tap0,script=no' -W t,inet,static,10.0.0.2/24 -g '-soundhw es1370 -nographic -vga none' -- mpg123.bin http://10.0.0.1:8080/demo.mp3

If I ping -f the guest address, it hangs ~instantly (<1s). "hang" here means that both music and network responsiveness stops; most likely cause of that is that interrupts stop being handled.

Using the vga console (i.e. without -nographic -vga none) the guest is 100% solid.

Delay when using QEMU/KVM port forwarding + DHCP

Per running the Node.js Express example, i.e.

rumprun kvm -M 160 -I 'nic,vioif,-net user,hostfwd=tcp::3000-:3000' -W nic,inet,dhcp -i -b express-$(EXPRESS_VERSION).iso,/express ../build/out/Release/node.bin /express/examples/hello-world/index.js

I observed that I had to wait 5 seconds from VM start to get a response from http://localhost:3000. I can connect before that but my browser waits until 5 seconds has elapsed from VM start.

I can fix this in two ways:

  1. Run with a static address:

    rumprun kvm -M 160 -I 'nic,vioif,-net user,hostfwd=tcp::3000-:3000' -W nic,inet,static,10.0.2.15/24 -i -b express-$(EXPRESS_VERSION).iso,/express ../build/out/Release/node.bin /express/examples/hello-world/index.js
  2. Disable duplicate address detection by always doing return 0 from if_do_dad (src-netbsd/sys/net/if.c)

Suspicion is that DHCP causes DAD but static does not, and that while doing DAD, the network interface is in some tentative state that is unable to reply to packets.

Doc may indicates to strip binaries

Hi,
following wiki example, I've build a 33M image of nginx. Using simply strip nginx.bin, size is reduced to 5M.
Thanks for this big work !

hw/KVM: No real-time clock / wall time

The hw platform needs support for getting real / wall time from the host when running on KVM. Need to investigate what mechanism KVM uses for this (RTC emulation? Something else?).

~3.5+GB RAM not supported on x86_64

Dunno if anyone would need so much memory with a unikernel, but documenting this one anyway. The reason for not it not being supported is the PCI window which occurs at <4GB, and hence RAM has to be split into multiple regions. The page allocator supports only one region of RAM. It's not hard to support more regions, but we'll just keep it on the list of things to implement using the JIT method.

build-rr.sh xen fails with "xen/xen.h" not found

following the instructions from the build tutorial:

git submodule update --init
CC=cc ./build-rr.sh xen
[...]
rumprun/platform/xen/pci/../xen/include/mini-os/hypervisor.h:17:21: fatal error: xen/xen.h: No such file or directory
 #include <xen/xen.h>```

build fails if backend compiler has ssp headers installed

For example on void linux with libssp-devel installed:

#    create  libc/fgets_chk.d
CC=/root/rumprun/platform/baremetal/rumptools/bin/i486--netbsdelf-gcc /root/rumprun/platform/baremetal/rumptools/bin/nbmkdep -f fgets_chk.d.tmp  --   -std=gnu99    -D__NetBSD__ -U_FORTIFY_SOURCE -Ulinux -U__linux -U__linux__ -U__gnu_linux__ --sysroot=/root/rumprun/platform/baremetal/rumptools/dest  -D_LIBC -DLIBC_SCCS -DSYSLIBC_SCCS -D_REENTRANT -D_DIAGNOSTIC -DMLIBDIR=\"\" -DHESIOD -DINET6 -DNLS -DYP -I/root/rumprun/src-netbsd/lib/libc/include -I/root/rumprun/src-netbsd/lib/libc -I/root/rumprun/src-netbsd/sys -I/root/rumprun/src-netbsd/lib/libc/compat/../locale -I/root/rumprun/src-netbsd/lib/libc/compat/stdlib -I/root/rumprun/src-netbsd/lib/libc/compat/../stdlib -D__BUILD_LEGACY -I/root/rumprun/src-netbsd/lib/libc/../../common/lib/libc/quad -I/root/rumprun/src-netbsd/lib/libc/../../common/lib/libc/string -I/root/rumprun/src-netbsd/lib/libc/../../common/lib/libc/arch/i386/string -D__DBINTERFACE_PRIVATE -I/root/rumprun/src-netbsd/libexec/ld.elf_so -I/root/rumprun/src-netbsd/lib/libc/dlfcn -I/root/rumprun/src-netbsd/lib/libc/gdtoa -I/root/rumprun/src-netbsd/lib/libc/locale -DNO_FENV_H -I/root/rumprun/src-netbsd/lib/libc/arch/i386/gdtoa -DWITH_RUNE -I/root/rumprun/src-netbsd/lib/libc -DPOSIX_MISTAKE -DCOMPAT__RES -DUSE_POLL -DPORTMAP -DWIDE_DOUBLE -DALL_STATE -DUSG_COMPAT      /root/rumprun/src-netbsd/lib/libc/ssp/fgets_chk.c &&  mv fgets_chk.d.tmp fgets_chk.d
In file included from /root/rumprun/src-netbsd/lib/libc/ssp/fgets_chk.c:41:0:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9/include/ssp/stdio.h:38:17: fatal error: ssp.h: No such file or directory
 #include <ssp.h>
                 ^
compilation terminated.
nbmkdep: compile failed.

For whatever reason, gcc doesn't pick up the ssp headers from --sysroot, but rather from the host.

cc @xtraeme

polling for POLLOUT on standard output fails

Consider the following test code, abbreviated:

struct pollfd pfd[1];
int rv;
for (;;) {
    pfd[0].fd = 1;
    pfd[0].events = POLLOUT;
    pfd[0].revents = 0;
    printf ("calling poll()\n");
    rv = poll(pfd, 1, 1000);
    printf ("poll() returned: %d, errno = %d, revents = %d\n", rv, errno, pfd[0].revents);
    sleep(1);
}

The expected output is:

calling poll()
poll() returned: 1, errno = 0, revents = 4

Instead, on rumprun-xen I get:

calling poll()
poll() returned: 0, errno = 0, revents = 0
PANIC: assert "(thread->bt_flags & THREAD_TIMEDOUT) == 0" FAILED

app-tools/rumprun -D automatically sets -p

Currently, rumprun -D sets -p and there is no way to un-p. For simplicity, -D should not set -p, as it is a valid debugging use case to let the domain run before attaching the debugger.

i386 is broken

The last revision where i386 still works is 75cd6b8. After that (with 7eade13), the platform enters a state of brokenness with hangs and memory corruption. It doesn't appear to be broken the same way all between 7eade13 and HEAD, but I didn't try to analyse how exactly things vary.

"rumprun kvm -i buildtest.hw_generic" reproduces a seemingly arbitrary hang/panic/etc. for me instantly. qemu is more forgiving, which is probably why there was only one case where the travis i486 test failed.

Needless to say, fix or revert needs to happen on Friday.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.