cli: poll() when waiting for ANSI codes response

Fixes #513.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Or Cohen <orc@fewbytes.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cli: Fix depends/build for executable

Properly reference our version of Lua.
Add missing packages to scripts/setup.py.

Signed-off-by: Or Cohen <orc@fewbytes.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
api/sched.h - improve const correctness

Some inline functions that do not modify a cpu_set cannot take a const
one. Noticed while trying to use this functions.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
sched: allow migrating an existing thread

We already allow pinning a new thread to a particular CPU. This patch
allows moving an existing thread to a particular CPU. The new API is
currently limited to a thread moving itself, via a new function thread::pin()
and cannot be used by one thread to moving another thread.

There's a subtle point in a running thread migrating itself: It must not
start to run on the target CPU before it stops running on this CPU.
So this thread's code cannot "wake" itself on a remote CPU, or it might
run in two places concurrently for a short duration. So we need an
auxiliary thread to do this migration for us. Instead of re-using an
existing auxiliary thread (e.g., the load balancer), this patch takes
the quick-of-dirty approach of temporarily creating a new thread just
for this purpose. Since this function will likely be called rarely,
I believe this inefficient approach is "good enough".

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Support Linux affinity-setting functions

We already support the Linux pthread_attr_setaffinity_np() function to
pin a newly-created thread to a particular CPU. This patch adds support
for the Linux sched_setaffinity() and pthread_setaffinity_np() functions
which pin an existing thread to a CPU.

Currently, our support is limited to a one-cpu cpu set, and only to
pinning the calling thread (not one thread pinning another thread).
This is a useful case, as some thread APIs (including the one in C++11)
have no support for creating a pinned thread, so the users need to create
a thread and then have it pin itself.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests/misc-ctxsw - eliminate OSv-only code

Because OSv did not support the Linux function sched_setaffinity(),
we had in tests/misc-ctxsw.cc alternative OSv-only code. Now that
sched_setaffinity() is supported, we can drop this OSv-only code.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Update the Wiki URL in error message

Update the Wiki URL to match the new Wiki structure

Reviewed-by: Tomasz Grabiec <tgrabiec@gmail.com>
Signed-off-by: Tzach Livyatan <tzach@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
add option "nohalt" to use osv::poweroff() instead of osv::halt() if Guest aborted

Signed-off-by: KANATSU Minoru <icc.pot.tyew272@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
drivers: add TIOCGWINSZ support to ioctl

ruby test script need TIOCGWINSZ.
hard-coded about window size to 80x25

Signed-off-by: KANATSU Minoru <icc.pot.tyew272@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
scripts: add words for filtering error to tests/testing.py

Signed-off-by: KANATSU Minoru <icc.pot.tyew272@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
scripts: add test script for CRuby

Signed-off-by: KANATSU Minoru <icc.pot.tyew272@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Tester script to compile and execute tests

tester.py - compilation / execution of test dirctories

usage: Tester run [-h] [--config_param CONFIG_PARAM] directory
[directory ...]
usage: Tester compile [-h] [--config_param CONFIG_PARAM] directory
[directory ...]

can be used manually to compile/run tests

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
EC2 Tester script to launch an instance and run tests

ec2-tester.sh - ec2 tester script that will launch an EC2 instance for
tests and run the tests using tester.py

requires setting of AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY

usage: ec2_tester.sh [-h] [--help] [--src src] [--override-image image]
[--region region] [--zone zone] [--placement-group placement-group]
[--osv-version osv-version] test-directory ...

ec2-tester will:
- create an ami from a raw image
- start an instance using the ami
- verify the instance is accesible (ping)
- use tester.py to run tests toward the initiated instance
- clean all temporary item at the end

can be used manually to launch an EC2 instance and run tests

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
apps: update to latest

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
testing.py: Fix broken regular expression

It's a regular expression so "[BUG]" matches messages with any of the
three characters in it...  The bug was introduced in commit 0f41b2b
("scripts: add words for filtering error to tests/testing.py").

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tools/cpiod: Show bad CPIO magic

If the CPIO magic check fails, include the faulty magic in the exception
message to give some clues to the poor sod who needs to debug the
issue.

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tools/cpiod: mkdirp() error reporting

If mkdirp() fails, be kind to the person debugging a dubious issue and
don't be silent about it.

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cpiod: exit early when can't create directories

The current cpiod prints a message, but doesn't stop immediately, if it
can't create a directory needed to hold an extracted file or directory.
Unfortunately, when add_dir() or add_file() fails, our current code does not
know how to skip it, so continuing is pointless and confusing (what will
follow will be a "bad magic" error, as our cpio parser tries to parse
the unskipped file content as a new header).

So when mkdir fails, we should throw an exception instead of continuing,
so the user will see the right error and not the silly "bad magic" error.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cpiod: create implicit directories with default permissions

In dir_add(), we created parent directories with the same permissions
as the leaf directory. This will fail if the intent is to create a non-
writable directory.

Instead what we need to do is to always create the parent directories
with default permissions (if different permissions are intended, the
parents should appear separately in the archive), and the mode just
needs to control the leaf file or directory.

Moreover, there is really no reason to do any of this with umask().
Just using chmod() is clearer and makes sure only the intended file
has the intended permissions.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
gdb: look for objects also in apps/ directory

For debugging OSv, we add to gdb a "osv syms" command which attempts
to load into gdb the same shared-objects that were loaded on OSv.

We looked for these objects in a bunch of places (build directory,
modules/ directory, etc.). This patch also adds to this path the apps/
directory (where stuff from osv-apps.git is compiled). This is
convenient when debugging OSv running various applications.

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