tests: add benchmark for timeslice length

This patch adds a tests/misc-timeslice.cc, a simple benchmark running two
cpu-hog threads and seeing what time slice each one gets (i.e., how often
do we switch between the two threads).

The same test can run on both Linux and OSv, so we can use it to callibrate
our choice of thyst (or whatever other mechanism we'll use for controlling
the time slice).

Running this on my own Linux host, I see it is using a 10ms time slice.

When we run it on OSv, we see a 1ms time slice. Sadly, this has nothing to
do with our intentional choice of our scheduler (thyst is higher than 1ms).
Rather what causes switching every 1ms is the unrelated "page access scanner"
thread. This thread runs every 1ms for an extremely short duration, and when
it stops running, the scheduler again picks the thread with least runtime,
without letting the thread that was running earlier complete its time slice
(its thyst advantage was taken away from it when it stopped running for the
page access scanner).

If I disable the page access scanner, I see the average timeslice is 3.95ms,
which is thyst*2 (thyst=2_ms), as expected.

This benchmarks suggests we should:

1. change thyst from 2_ms to 5_ms, to callibrate the time slices of cpu hogs
   like Linux.

2. Rethink page access scanner's desire to run 1000 times a second. Why 1000?
   Alternatively, if we woke the scanner thread 1000 times a second but did
   *not* reschedule at that point, we could get it running 1000 times a second
   when there are already many context switches - but running fewer times
   when there are few context switches.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
x64/misc.bin: update to latest

It has libraries that are needed by OpenSSL.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
httpserver: tests: fix invalid use of assert_between()

The method takes 4 parameters, not 3. Causes run-time error.
httpserver: tests: fix assetion failure in testfile.py

Fixes assetion failure with message: u'666' != 666

The 'permission' field is a string not an integer
libc: implement __fread_chk()

It is needed by RAND_load_file() from OpenSSL.
modules: add libz module

It is needed by both java and openssl
modules: make java depend on libz
modules: add openssl module
httpserver: link against boost_program-options which matches the includes

We use includes from misc.bin but shared object from the host. When I
linked against boost_program-options.so which I have on the host I
got:

obj/main.o: In function `boost::program_options::basic_command_line_parser<char>::run()':
/home/tgrabiec/src/osv/mgmt/httpserver/../../external/x64/misc.bin/usr/include/boost/program_options/detail/parsers.hpp:107: undefined reference to `boost::program_options::detail::cmdline::get_canonical_option_prefix()'
collect2: error: ld returned 1 exit status
httpserver: make: make 'init' target phony
httpserver: make: simplify rules
httpserver: make: link against openssl
httpserver: make: do not use relative paths

They're evil, this is broken with relative paths:

 cd $(src) && SOME_PATH=$(src)
httpserver: template API docs on the protocol name
httpserver: remove unused field
httpserver: abstract away HTTP transport

This will allow to switch between HTTP/HTTPS at run time.
modules: introduce run_on_init() declaration

api.run_on_init(cmdline) means that cmdline should be executed at init
time as if a file was put inside /init directory with '30-'
prefix.

The order in which commands declared this way will run depends on the
order in which modules depend on each other. Dependant modules will
run before modules which depend on them which means automatic priority
assignment.

The motivation for this change is to allow "run on init" behavior to
be optional, depending on the chosen run configuration. For example
some times we want HTTP server to run as daemon and some times as
standalone app. It's simplest to reuse an already present run
configuration mechanism for that.
httpserver: introduce .fg run configuration

When image is built like this:

  make image=httpserver.fg

OSv will wait for it before exiting. "fg" is for "foreground". It can
be useful when we want to have a generic image with just the API
through which commands will be started externally.
Bump up swagger-ui.git HEAD ref
httpserver: add support for SSL transport

HTTP server will now support both plain HTTP and SSL-based HTTPS. The
protocol flavor can be chosen at run-time, either with command line
argument or cloud-init configuration.

To start httpserver in SSL mode pass the --ssl command line parameter,
or build the module in using the fg_ssl run configuration:

   make image=httpserver.fg_ssl

For more details, check out documentation draft:
https://github.com/cloudius-systems/osv/wiki/The-RESTful-API#configuring-ssl