Explain Gcc version requirement in README

Explain in README that Gcc 4.7 is required, gcc 4.8 is recommended.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
vfs_task: Fix path conversion in certain cases

task_conv was wrongly converting "/.." and produced a path with unexpected
characters after /
Consequently, repeated calls (Java) to 'new File("/..").exists()' returned
ambigous results, not to mention other properties like isDirectory.

This confused the shell's completion mechanism (and me).

In more detail, in this (/..) situation 'len' was more than 2 (in line 105) which
caused 'tgt' to be pointing before the begining of 'full', from that point
whatever stopped the backward search for '/' (lines 109-112) was unexpected.
I guess this might occur with other combinations.

This sets 'len' to be 1 when starting an absolute path conversion, to match
the behavior where relative path conversion sets 'len = strlen(cwd)'.

Signed-off-by: Or Cohen <orc@fewbytes.com>
mmu: Fix off-by-one on range covered by ELF

The correct range is elf_start:(elf_start + elf_size - 1)

Signed-off-by: Raphael S.Carvalho <raphael.scarv@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: fix --trace-backtraces uninitialized data in backtrace

Also fix other review comments related to 1f161695d86d.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
gdb: extract symbol/file/line resolution into a class

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
gdb: cache syminfo objects

Looking up symbols is expensive, store them in a cache.

Speeds up dumping the trace log when a backtrace is taken.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
gdb: resolve backtrace symbols in trace logs

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Add kill() support - sort of

This patch adds support for the Linux kill(2) function.
The next patch will add alarm(2) support, which uses kill(2).

To be honest, we sort-of implement kill(). This implementation is
compatible with the API, but the semantics are somewhat different:
While in Linux kill() causes the signal handler to run on one of the
existing threads, in this implementation, the signal handler is run in a
*new* thread.

Implementing the exact Linux semantics in OSv would require tracking when
OSv runs kernel code (i.e., code in the main executable, not a shared
object) so we can delay running the signal handler until returning to the
user code. Moreover, we'll need to be able to interrupt sleeping kernel
code. This is complicated and adds overhead even if signals aren't used
(and they aren't used in most modern code).

I expect that this code will be "good enough" in many use cases.
This code will *not* be good in enough in programs that expect one of the
following:

1. A program that by using Posix Thread's "signal masks" tried to ensure
   that the signal is delivered to one specific thread, and not to an
   arbitrary thread.

2. A program that used kill() or alarm() not intending to run a signal
   handler, but rather intending to interrupt a sleeping system call
   like sleep() or read(). Our kill() does not interrupt sleeping OSv
   function calls, which will continue to sleep on the thread they run
   on.

The support in this patch (and see next patch, for alarm()) is good
enough for netperf's use of alarm().

P.S. kill() can be used only to send a signal to the current process, the
only process we have in OSv (you can also use pid=0 and pid=-1 to achieve
the same results).

This patch also adds a test for kill() and alarm(). The alarm() test
will fail until the next patch :-)

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Merge branch 'trace'

Some fixups to --trace-backtrace, plus symbol resolution in the log output.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Support alarm()

This patch adds support for Linux's alarm(2) system call.

alarm() is needed in some ancient Unix software, like netperf :(

This implementation is fully compatible with Linux's alarm(), but please
note that what alarm() does when the alarm times out is a kill(SIGALRM) -
so all the caveats mentioned in the previous patch regarding kill(),
will also apply here.

Alarm() is implemented by running one "alarm thread", started on the
first alarm() call. This alarm-thread waits for the alarm to expire,
or for instructions to change the alarm. When an alarm expires the
alarm thread does a kill(0,SIGALRM).

tst-kill.cc (from the previous patch) includes a test to see that
alarm() really sends a SIGALRM signal on time, and also that we can
cancel a pending alarm and not receive a signal.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
netperf: since alarm() support added no special patch is needed

  1. Netperf patch removed from repository
  2. Documentation updated

Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Trivial prototype change

Change the name of the argument of wake_with from "Pred" to "Action".
This argument is a function to run, *not* a predicate (it's not supposed
to return a boolean value), so it doesn't make sense to call it Pred.

The implementation of wake_with already used the name "Action" - this
patch fixes the prototype too.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
pci: debug printouts fixes

  1. MSI-X printous fixed
  2. Duplicate EOLs removed

Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
Add "-version" option to RunJava

Add "-version" option to RunJava, and therefore to java.so and the "java"
CLI command.

java -version now shows:

  java version "1.7.0_25"
  OpenJDK Runtime Environment (1.7.0_25-mockbuild_2013_07_27_13_36-b00)
  OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

I can't explain why the version on the second line is different than what
"java -version" on Fedora 18 shows for the same libjvm.so:

  java version "1.7.0_25"
  OpenJDK Runtime Environment (fedora-2.3.10.4.fc18-x86_64)
  OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
condvar: add comment

Add a comment to condvar explaining that it makes a guarantee that
POSIX Threads' condition variables do not - that there are no spurious
wakeups.

The comment goes on to explain that at least in one place (semaphore.cc)
we make use of this added guarantee, so if the condition variable
implementation is ever rewritten, we'll need to keep this guarantee.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
build: run gradle in daemon mode

Speeds up mgmt null build considerably
compat: Add missing linux version.h for boost:asio.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
kvmclock: Implement support for old kvmclock MSRs.

Older versions of KVM and user VMMs expose kvmclock MSRs at different
MSR offsets. Detect the old flag in kvmclock::probe() and use the old
MSRs if they are the only ones available.

Signed-off-by: Venkatesh Srinivas <venkateshs@google.com>
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
kvmclock: Simplify probe() function

Make kvmclock::probe() easier to follow by simplifying the processor
feature checks.

Cc: Venkatesh Srinivas <venkateshs@google.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
usr.manifest: Add content-type.properties to JRE

Fixes the following warning on OSv startup:

  Warning: default mime table not found: /usr/lib/jvm/jre/lib/content-types.properties

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