drivers: Make block device init silent by default

We now print disk probe information like:

virtio-scsi: Add scsi device target=1, lun=0   as vblk0, devsize=10842275840

Disable it by default. The --verbose option will make this info
available which is useful when debug.

Reported-by: Pekka Enberg <penberg@cloudius-systems.com>
Signed-off-by: Asias He <asias@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc: add scandir() from musl

Add missing scandir() function from musl 1.0.0. Fixes #237.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
ahci: Limit max size of a bio request

One PRDT entry can contain 4MB buffer at most, we currently only use one
PRDT per AHCI cmd. Limit the size of a bio request to respect it. Larger
bio will be split into smaller bios by multiplex_strategy.

Signed-off-by: Asias He <asias@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
ahci: Align cmd_table tables to 128-byte address

AHCI spec '4.2.2 Command List Structure' says 'Command Table Descriptor
Base Address' must be aligned to 128-byte cache line, indicated by bits
06:00 being reserved.

All the 32 cmd_table are allocated in one linear space. The size of
cmd_table is 144 bytes for now which is larger than 128 bytes. So we pad
cmd_table to 256 byes.

Signed-off-by: Asias He <asias@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
ahci: Assert data buffer address

Assert to make sure the data buffer address satisfies the AHCI spec's data
alignment requirement.

Signed-off-by: Asias He <asias@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
ahci: Use all the cmd slots

AHCI has 32 cmd slots to issue cmd. Only first slot is used currently
which makes the queue-depth 1.

This patch uses all the cmd slots and makes the cmd completion async.
Now, the queue-depth is 32.

Test with "/tests/misc-bdev-write.so" on VBOX shows improvements:

   Before: ~10MB/s
   After: ~20MB/s

1000 round of "/tests/misc-bdev-rw.so" tests passed on VBOX and QEMU.

Signed-off-by: Asias He <asias@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
sched: Add assert to capture rescheduling attempt in nested exception

Rescheduling in nested exception is not supported since nested exception
stack is per cpu, but without the assert such reschedule will cause
stack corruption which will be hard to debug.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
mempool: Contiguous physical memory holder class

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
[ penberg: fix formatting ]
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Add vmxnet3 driver

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Add vmxnet3 argument on run.py

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Support VMDK and VDI format

Add osv.vmdk and osv.vdi targets on Makefile.

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Asias He <asias@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
scripts/gen-vbox-ova.sh: Add --vga option to vdi image

Generate osv.vdi image from 'make osv.vdi' Makefile target which will
convert to the image to vdi as well as add the --vga option.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
networking: remove double socket unlock

sogeneric_send(), in one error case, unlocks the socket before doing
'goto release' which unlocks the socket again, resulting in an assertion
failure (unlocking an unlocked mutex) and crash.

This patch removes the extra unlock.

Fixes #248.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
balloon: Fix JNI detach in request_memory()

The request_memory() function has an early exit condition where we
forgot to call _detach().  Fix that up by attaching later in the
function which ensures we eventually will detach.

Signed-off-by: wangbicheng <wangbicheng@huawei.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Merge github.com:amnonh/osv
mgmt: update to latest

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
loader: Print OSv version info correctly

On VBOX and VMW, the version info is not printed correctly.
Fix it by only print after our console is initialized.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Asias He <asias@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Support 'make osv.vmdk' without 'make all'

Add 'all' as dependent target of osv.vmdk/.vdi, to prevent build error.

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
bsd: set a smaller default stack for BSD threads.

All threads created through the bsd/porting/kthread interface are threads that
used to be kernel threads in BSD, which means they are expected to use less
stack. Although I have no idea what is the default stack size for BSD, in Linux
things need as little as 4k. More importantly, they are threads whose memory
usage are under our control, and we could fix heavy offenders without a
problem.

If we don't say anything, they will start with 64k which is way, way, too much.
I am proposing here we go lower and get to 16k - which is even still quite
conservative, but so am I.

Measuring memory before and after the mount - because ZFS is currently our
heaviest user, I can save around 7Mb with this patch.

Passes make check (except for tst-kill, which is broken AFAICT) and misc-fs-stress.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tst-kill: fix crash

tst-kill runs various signal handlers, which we run in separate threads.
When the test completes, we may be unlucky enough for the last signal
handler to still be running, at which point when the module's memory
is unmapped (e.g., in test.py -s each test is unmapped when it ends)
we can get a page fault and a crash.

This patch sleeps for a second at the end of tst-kill, to make sure that
the signal handler has completed; This sleep is a bit ugly, but I can't
think of a cleaner way - Posix provides no way to check if there's a
running handler, and I wouldn't like to add a new API just for this test.

Fixes #249.

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