vfs: Convert mount point list into C++

This converts VFS mount point list to list from the C++ standard
library.

Reviewed-by: Avi Kivity <avi@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs: Use delete instead of free in vfs_mount.cc

The mount struct is allocated with "new" so use "delete" to deallocate it for
symmetry and to avoid future bugs if a destructor is introduced.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs: Use C++ locking in vfs_mount.cc

Use SCOPE_LOCK and WITH_LOCK in vfs_mount.cc.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs: kill vcount()

After c59e0fd, vcount isn't used anywhere.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs: count_match return failure when mountpt does not match

ZFS allows user to create multiple file systems on a pool. As a part of
the file system creation, ZFS creates a new mount directory and mounts
new file system there. The default mountpoint is /<pool>/<fs name>/.
For example: zfs create tank/fs1 would mount new fs on /tank/fs1.

During path lookup (in namei), we have to find the mount point for
given path. We go through the list of mount points and find the one
which matches the most (function count_match). Once the mount point is
found, namei skips the mount point portion of the path and goes through
rest of the components of path mapping each component to dentry. For
example: if namei(/proc/mounts) is called - namei would find that
mountpoint is /proc and then it will try to map /mount to a dentry.

The count_match() function matches each character of path against given
mountpoint. If a match is found - the function returns number of
characters matched. If a character does not match - it breaks out of
the loop, in which case it must return no match (i.e. set length of the
match to 0).

However, because of bug in mount point matching function (count_match),
when mountpoint '/tank/fs1' is matched against '/tank/fs2', it
incorrectly returns a match and sets the length of the match to 8. As a
result, namei lookup fails - since /2 is not a path. The failure
particularly happens only when
1. strlen(path) == strlen(mountpoint),  AND
2. Last character of path do not match

Example failure run
==================
[/]% run zfs.so create tank/fs1
run_elf(): running main() in the context of thread 0xffff800009d3e050
VFS: mounting zfs at /tank/fs1
zfs: mounting tank/fs1 from device tank/fs1
run: finished with exitcode 0

[/]% run zfs.so create tank/fs2
run_elf(): running main() in the context of thread 0xffff80000b708050
VFS: mounting zfs at /tank/fs2
cannot mount 'tank/fs2': No such file or directory
filesystem successfully created, but not mounted
program /zfs.so returned 1
run: finished with exitcode 1

[/]% ls /tank
ls: could not access /tank/fs2: No such file or directory
.     ..    fs1
==================

Reviewed-with-a-smile-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs: simplify namei external loop

Reviewed-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs: remove dead code from namei

Reviewed-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
pthread_yield: mark as extern

Apparently, pthread_yield declaration is not in the standard headers, so it
ends up not being exported as a C symbol. Manually do it.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
modules: add libyaml module

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cloud-init: depend on libyaml

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
httpserver: add missing libyaml.so when cloud-init module is not included

httpserver's DSO is linked against libyaml but does not include it in
its manifest. Fix by depending on libyaml module.

Makes the following dmesg line go away:

  could not load libyaml-cpp.so.0.5

Currently it doesn't cause any run-time problems because the
functionality which uses libyaml is run only when httpserver is
configured via cloud-init, in which case libyaml is already included.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Jolokia - change 'p' parameter to non-required in swagger definition

Makes "/jolokia" (without args) function identically to vanilla
Jolokia (-> version)

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