libct: reformat code in serve_spawn()

Remove extra indent by using goto for handling error path.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
libct: split serve_spawn function

because the part for extracting arguments will be used in serve_enter.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
libct: correct handling of arguments and environments from protobuf messages

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
add python bindings

Here are python bindings for libct functions. There are
two modules, one, libctcapi, provides all libct functions
as is and shouldn't be used. Second - high-level API with
classes.

Example of usage:

import libct

def test(arg):
        print arg
        return 1

s = libct.open("local")
ct = s.container_create('qwe')
ct.spawn_cb(test, "testtesttest")
print ct.wait()
ct.destroy()
s.close()

Second example:

import libct

s = libct.open("unix:///var/run/libct.sock")
ct = s.container_create('qwe')
ct.set_root("/mnt")
ct.set_nsmask(libct.consts.CLONE_NEWIPC |
                libct.consts.CLONE_NEWNET |
                libct.consts.CLONE_NEWNS |
                libct.consts.CLONE_NEWUTS |
                libct.consts.CLONE_NEWPID)

ct.controller_add(libct.consts.CTL_CPU)
ct.spawn_execv("/sbin/init", ['/sbin/init', '3'])
print ct.wait()
ct.destroy()
s.close()

Drawbacks:
1. libctmod.c contains a lot of duplicated code, usually people
make some autogenerators for making such bindings for C-functions,
so it will be good to write such script.

2. We should store error descriptions in some single place, because
they needed in python bindings to provide clear exceptions.

3. libct_container_set_option is not implemented, we need to add
second version of this function with va_list argument.

4. All python functions and classes usually have documentation in
form of docstrings, so it should be written later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>