mgmt: update to latest

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: do not rely on osv::power_off() to sleep

Nadav saw tracing_smoke_test failing when run inside a VM on QEMU
without KVM. The test failed because there was no trace of
osv::power_off() in the backtrace of 'trace prof-wait'. We concluded
that it is best not to rely on this function to always sleep.

I changed the assertion to use 'sched::thread::wait' instead, which
is so generic it should probably always be there.

Reported-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>
libc: add inet_addr, inet_aton

The code is taken from musl-libc.

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
bsd: Add support IP socket options

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
virtio-net: enable multicast

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vmxnet3: enable multicast

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
eventfd: add eventfd support

eventfd is an object used for event notification. Eventfd object
maintains a counter, which can be read or written to using normal read
or write system call. Depending on how eventfd is created, read may
either wipe out counter or reduce it by 1. If a read or write cannot be
services immediately then the execution is blocked until an event
occurs to unblock the execution. For example: read on eventfd would be
blocked if the counter is 0, similarly write on it would be blocked if
counter is ULLONG_MAX-1. Writing to an eventfd unblocks any reader
waiting for it.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: add eventfd unit test

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Remove unnecessary #include

Remove an include of "api/assert.h" from osv/debug.hh. This was not
only unnecessary, it also needlessly causes problems when a program
(such as the httpserver module) combines the host header files and OSv's,
and both <assert.h> and "api/assert.h" end up being used, and they have
a slightly different definition of __assert_fail.

This include was added in commit b40cb27a but I don't know why.
It doesn't seem needed.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
sched: Add API for iterating over all threads

We currently don't provide any method of iterating over all threads (something
which, "top" would like to do, for example). thread_map and thread_map_mutex
are private to sched.cc, and should stay that way.

So this patch provides a new function with_all_friends(f), which iterates
over all threads and calls the given std::function for each one. The
function is supposed to be safe (a thread will not be freed while someone
is running f on it), but it is inefficient as it holds thread_map_mutex
throughout the entire iteration, so it should currently only be used for
debugging purposes, e.g., for implementing "top".

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
random: hw source of entropy should be conditionally registered

The hardware source of entropy should be only registered when
available, e.g. virtio-rng.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
random: Avoid uneeded buffer allocation/deletion

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tools: add uush

add a micro micro interactive shell which allows to just
run commands either in the foreground or in the background
using "&" appended to the command.
Useful for testing purposes, especially running directly
in loader.img before full usr.img build is available.
No cmdline arguments.

"uush" is a module, so you can add it to the image by using
make image=uush

Examples of use:

with just loader.img (AArch64):

./scripts/imgedit.py setargs build/release/loader.img --nomount /tools/uush.so
qemu-system-aarch64 -nographic -M virt -enable-kvm -kernel loader.img -cpu host -m 1024M

with full usr.img and scripts (x64):
./scripts/run.py -c 1 -V -e tools/uush.so

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
modules: introduce a concept of repository

Repository holds modules in directories. No extra config file needed,
layout is implied.

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>
Add test for sethostname() and friends

This test can run on both Linux (needs root permissions) and OSv.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
modules: make api.require() impose compilation ordering

This change makes api.require() express not only run-time dependency
but also imply a compilation order. osvinit depends on httpserver
artifacts during its build, require() could be reused in a simple way
to express this dependency.

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>
sampler: make start_sampler() always succeed

It's simpler that way. That's what the API user would typically want
to do. If the sampler is already running it is restarted.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
modules: include apps.git as module repository

This way there is no longer need for apps.git/modules.json. That file
currently holds zero information. It has no other purpose than being
source of merge conflicts.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
modules: configure osv.git/modules as module repository

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
core: implement pselect()

Add implementation for pselect().

Signed-off-by: Jaspal Singh Dhillon <jaspal.iiith@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>