build.mk: aarch64: add --nomount to cmdline

don't try to mount zfs in our first simplified loader image.
Add comment about having to manually add the hello world program,
since there is no way to customize the loader image.

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
build.mk: aarch64: switch to image=uush as default

...until the build system confusion in modules/ is sorted out.

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
sched: fix exit notifiers mutual exclusion

As Pawel Dziepak noticed, the RCU protection for thread exit_notifiers
wasn't entirely safe, because we copied std::function objects under
the RCU lock, and that could cause allocations, and ultimately, sleeping.

So this patch replaces the RCU protection by that of a read-write lock
(rwlock). The code is greatly simplified, and the warnings against
deleting functions are gone. We now run the notifier functions inside
the rwlock's read lock, and they are allowed to sleep. Like the RCU
solution, several threads can complete in parallel.

Our existing rwlock's read-side is slower than the RCU read side - with a
roughly 50ns overhead; But a 50ns slowdown of thread exit is negligable,
and moreover, the old RCU-using code also included slow code like copying
the list, which is now unnecessary.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
musl: take alphasort and scandir from musl

Our copies were identical up to trivial changes in header files inclusion,
and the original musl version works too (we probably imported a slightly
newer version).

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
core: make sched::cpu::current() out of line in DSOs

If it's in-line then DSO is accessing thread-local variables defined
in the kernel object which involves calling program::tls_addr() which
may block. However a lot of code assumes that current() does not
block. This was causing aborts in tst-unordered-ring-mpsc.

Fixes #447.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Revert "epoll: fix up lock ordering issues"

This reverts commit 4eb729eaa4a11d5fbb8b5f5d26209b5149097513. Fixes #448.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Http server: Add a helper function in the reply to add a header

This adds a helper function in the reply object that adds a header to
the list of headers.

Reviewed-by: Tomasz Grabiec <tgrabiec@gmail.com>
Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Http Server: Support optional Access-Control-Allow-Origin header

When the GUI and API are not placed on the same server it is useful to
have the Access-Control-Allow-Origin header set to *.

This adds a command line flag option to set the header.

The server now passes its configuration to the request handler.
When the flag is set, the request adds the access control header.

Reviewed-by: Tomasz Grabiec <tgrabiec@gmail.com>
Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Http server: Expose ifconfig infromation in the API

This adds the equivalent of the ifconfig information to the API.
/network/ifconfig will return a list of all the interfaces with their
configuration and data.
To check a specific interface (ie. lo0) do:
/network/ifconfig/lo0

Interfaces information returns with timestamp. Currently all interfaces
in a single call have the same timestamp, we assume that the
difference is neglegtable, but API support specific
timestamp per interface.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Http server: Add recursive operation for directories

Directory deletion should support recursive deletion to support deleting
all of its sub content.

This patch adds both directory recursive deletion and modify directory
creation to be aligned with hadoop HDFS:
"Make the given file and all non-existent parents into directories. Has
the semantics of Unix 'mkdir -p'. Existence of the directory hierarchy
is not an error."

Reviewed-by: Tomasz Grabiec <tgrabiec@gmail.com>
Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
ifconfig/dmesg: Fix MAC address format

For example, if we set MAC address 0e:0f:2b:ec:e8:15,OSv will display
e:f:2b:ec:e8:15 using ifconfig or dmesg command.

Signed-off-by: Haifeng Gao <gaohaifeng.gao@huawei.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Http Server: file length was missing in file API

File length was missing in the file API. This adds the missing attribute
and adds a test to verify all the attribute in the file API.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
jvm_balloon: Add API to get the JVM balloon size

This adds an api with its own header file to return the balloon size.
Using a separate header file, removes the dependencies in other headers
such as JNI.

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Http Server: Add an API to return the balloon size

This adds an API that returns the balloon size. To test call:

GET: http://localhost:8000/os/memory/balloon

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc/misc: Migrate to upstream musl

Migrate all identical files under libc/misc to upstream musl.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc/passwd: Migrate to upstream musl

Migrate all identical files under libc/passwd to upstream musl.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc/thread: Migrate to upstream musl

Migrate all identical files under libc/thread to upstream musl.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc: Move _chk variants into separate files

Move the _chk variants into separate files so to simplify migration to
upstream musl.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace.py: optimize split_format()

This improves all trace.py commands by 30%. We're using memoization
techinque to save computation.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace.py: optimize unpack()

This brings a small but noticable improvement.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>