Add names to threads running external executables

For gdb's "osv info threads" and the new top.py, it is useful for all
threads to have names. Most of OSv's internal threads already have
informational names, but when we run external executables like java
or memcached, we often see empty names.

This patch changes loader.cc's "run_main", during its run of an
executable's main(), to set the current thread's name to the executable's
name. Moreover, if a thread spawns another thread and doesn't explicitly
set its name, it will inherit the parent's name, with a prepended ">"
character.

For example, "top" while running both memcached and Java (the shell),
might now show this:

157 threads on 4 CPUs; idle:  69%  27%  86%  89%
   ID  %CPU    TIME NAME
  216  90.4   27.28 >/memcached
   41  19.6    5.01 virtio-net-rx
  234   6.1    1.61 >>>java.so
    2   3.4    5.60 page-access-sca
  227   2.5    0.69 >java.so
  228   1.8    0.61 >java.so
  ....

Note how the thread using 90.4% of a CPU is named ">/memcached", meaning
it is a thread spawned by /memcached's main() thread. Another 6.1% is
spend by ">>>java.so", which is the great-grandson of the java.so main
thread; We don't know what is the function of this thread (it would be
nice to be able to somehow figure this out), but at least knowing it is
part of Java, and not a part of memcached or libhttpserver or some
anonymous part of the kernel, is interesting.

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

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
scripts: top.py

This patch adds a "top" script (scripts/top.py) which one runs on the
host, and it connects to an OSv guest through the REST API. Every two
seconds it makes an /os/thread request to get the list of all threads,
and each one's total CPU time. Subtracting two consecutive lists provides
us with the CPU time consumed by each thread during this period, which
is then divided by the elapsed time to produce the CPU usage percentage
of each thread. On each refresh, the top 20 threads are displayed.

For example, during a single-threaded memcached run:

155 threads on 4 CPUs; idle:  12%  77%  98%  99%
   ID  %CPU    TIME NAME
  216  91.5   19.30 >/memcached
   41  17.9    3.32 virtio-net-rx
    2   2.1    1.25 page-access-sca
    6   0.5    0.09 rcu0
   14   0.4    0.04 percpu1
   13   0.1    0.04 rcu1
    5   0.0    0.02 balancer0
    7   0.0    0.04 percpu0
   16   0.0    0.01 rcu2

The idle threads are not shown in the main list, but rather on the top
summary line, which says how many CPUs were found, and what percentage
of the time this CPU was idle over the last period.

The percentage, including idle percentage, is not very accurate, and
numbers slightly below and even slightly over 100 can be expected for
running threads, because of a quirk in thread::thread_clock's
implementation, which cannot see a running thread's current time-slice.
But because typical time-slices are much shorter than top's period
(2 seconds), this problem is usually negligable.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libosv.so make it work with python2 as well

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
release-ec2: move generic code to separate file

Generic EC2-related code moved to a separate file to be reused
in Jenkins test automation scripts.

Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
ec2-utils: introduce more instance-related functions

Functions introduced:

  1. Query instance ID by name
  2. Query instance private IP by name

Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs: Move dentry-specific functions to a new file

Created a file, vfs_dentry.cc, in the directory ./fs/vfs/ that will
now holds all the dentry-specific functions.

Details:
- Moved lookup_init content to a new function called dentry_init,
and call dentry_init from lookup_init.
- Add declaration for dentry_lookup and dentry_init in fs/vfs/vfs.h

No semantic change has been made here, just refactoring things.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: Binary trace dump API

Add API to generate binary trace dump file with varying/optional levels of
information contained, suitable for wire export.

Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
mgmt: update to latest

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
random: Clarify unblocking message

Change the message 'random: unblocking device.' to
'random: device unblocked'.
Purpose is to avoid people misinterpreting its
meaning, i.e. think that the device is still being
unblocked after the message is printed.

One classical example:
When running mgmt shell, OSv often hangs for a while
right after the message is printed, so it's not hard
to think that the unblocking is slowing down the boot
process, which is not true.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>