OSv Init: http client

The http client is loosely based on the boost http client example.
The original example can be found here:
http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/example/cpp03/http/client/sync_client.cpp

The client class redirect its output to an output stream so if the c is
a client the following can be done:
std::cout << c;

The client is used to retrieve init files from a remote server. It can
be replaced by a library client if need arises.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
OSv Init: the osvinit class

The osvinit object uses command from a yaml parser to either call an API
command or to perform internal command.
The supported options are:
Each command contains: GET, PUT, POST or DELETE with a url of the
command. Path parameters comes as part of the url.
Query parameteres follow as a yaml parameters.

The osvinit can be set to stop on errors or ignore them.

When opening the api, the osv init creates a new thread for that, it
would wait for that thread to terminate.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
OSv Init: the main

The main starts an osvinit task. It should get in the command line
either a file name or a server name and path on the server as the init
file.

It uses a parser for passing the configuration to the osvinit

It call the osvinit wait, it would return imidiatialy if the httpserver
was not run.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
OSv Init: A basic configuration file

The default configuration file is empty. When the osvinit will be in use
it should replace the httpserver and the osvinit would start the api
server when the configuration is done.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
OSv Init: Makefile

Adding the make file. It create the osvinit.so for use with the image
and the osvinit for standalon testing.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
OSv Init: add the module.py

Package the yaml-cpp lib, the osvinit.so and the osvinit.yaml init file.
By default the osvinit will not be started, but the httpserver will.

To change that, the starting line can be uncommentted or the osvinit can
be started with a -e directly.

The osvinit and httpserver should not be both started.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>

module.py need merge
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
OSvInit: add directory of the yaml-cpp library

Add the directory of the yaml-cpp library to the path

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
mgmt: compile osvinit after httpserver

Explicitly specify to the build system that the osvinit module needs
to be compiled after the httpserver module. Otherwise, we may randomly
get opposite order, and the compilation will fail.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
osvinit: fix compilation error

handle() returns void now.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
osvinit: express compilation-time dependency on httpserver with require()

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
osvinit: update location of httpserver module

This fixes 'make' in osv.git

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
mempool: limit max_object_size to page_size / 4

Because of the page_header mempool allocator can put only one half-page
sized object in a page. Page allocator has exactly the same space overhead
but is much simpler (no need for setting up page_header, freeing objects
allocated on another CPU is trivial).

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
mempool: replace MALLOC_ALIGNMENT with alignof(max_align_t)

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
mempool: set default alignment to min(size, alignof(max_align_t))

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
mempool: don't increase size of arbitrary aligned objects

This is just a rewrite of a conditionals that are responsible for
choosing appropriate allocator for a requested size and alignment.
The allocator is given the object size exactly as requested.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
vfs: move poll_link to file.h

Avoids problems with forward declarations in the following patch.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
vfs: convert file::f_poll_list to be a boost::intrusive::list

Also use new/delete instead of malloc/free.

Safer for everyone.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
vfs: remove unneeded extern "C" from osv/file.h

Gets in the way of template declarations.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
epoll: use correct key

According to epoll(7):

       Q0  What is the key used to distinguish the file descriptors
           registered in an epoll set?

       A0  The key is the combination of the file descriptor number
           and the open file description (also known as an "open file handle",
           the kernel's internal representation of an open file).

Right now we just use the file pointer, which means that two epolls on the
same file, but using a different fd, will fail, where they should succeed.

Fix by using a combination of the file descriptor and the file pointer as
the epoll_key.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
epoll: properly lock epoll file

epoll operations can be executed concurrently, protect against this using
file::f_lock.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>