scripts: Add script to generate OSv VMware configuration

./scripts/gen-vmx.sh will create build/release/osv.vmx
You can run this VM image on VMware by executing following command:
vmware build/release/osv.vmx

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
mmu: read page content before populating page table

Page should not be accessible through a page table before it contains
valid data, otherwise a thread running on another vcpu can see garbage.
We rely on zfs file prefetch mechanism to minimize actual disk IO for
mmap_populate mappings. In the feature this will be replaced with proper
page cache integration.

Fixes #228

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Revert "vfs/zfs: Sync vnode and znode refcounts"

This reverts commit ca805bdb48465fdc7dbd46e1c4eee2e64d7c6d1e.

The commit breaks Cassandra startup as follows:

   INFO 09:18:00,244 Opening /var/lib/cassandra/data/system/local/system-local-jb-5 (5677 bytes)
  page fault outside application, addr 0
  [backtrace]
  0x31899b <mmu::vm_fault(unsigned long, exception_frame*)+219>
  0x34c105 <page_fault+101>
  0x34acc7 <ex_pf+35>
  0x391e94 <vn_stat+132>
  0x3935c9 <sys_stat+41>
  0x38a4ee <__xstat+78>

Raphael explains:

  I found that the following commit
  ca805bdb48465fdc7dbd46e1c4eee2e64d7c6d1e is the guilty one. It correctly
  fixes some mismatches between znode and vnode refcnts, then moves
  VOP_INACTIVE from vrele to keep them synchronized. This change assumes
  that there is no mismatch anymore.

  However, there is apparently a corner-case that the patch doesn't
  address. Example: If the vnode is one refcnt ahead of the respective
  znode, on an eventual vrele, the znode would be destroyed while the
  vnode is still alive. zfs_getattr attempts to dereference the field of
  the znode which doesn't exist anymore, thus the page fault.

As it's a regression, revert the commit for now.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tst-zfs-mount.so: Disable reference count check

Commit 951cca4 ("Revert "vfs/zfs: Sync vnode and znode refcounts")
forgot to disable ZFS reference count test case.

Reported-by: Avi Kivity <avi@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
zfs: Set f_fsid in zfs_statfs

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs/zfs: Add st_dev field support to stat

Tomek says:

Some programs rely on the fact that the (stat.st_ino, stat.st_dev) pair
uniquely identifies the file.
In OSv only st_ino is set by vn_stat(), st_dev is zeroed. It is possible that
files on different file systems will have the same inode number and hence
appear as referring to the same file.

Spotted during code inspection of openssl and vfs, I didn't run into any issue
related to that yet.

This patch addresses the issue #216

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: Check st_dev and f_fsid validity

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

In commit 08835b4e608eddcbd0ce17e3ef7a813d7b239731, we turned off uma
allocation caching when CONF_debug_memory is on because it hid bugs.
Or at least, this is what was *intended*. What the patch actually did
was the opposite - it turned off the cache in the normal compilation!

This caused a deterioration of UDP memcached performance, from 159,000
to 131,000 req/sec. This was the second half of the recent memcached
performance deterioration (see issue #227).

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
x64: Fix duplicate ex_pf() declaration

There is a duplication in OSv exceptions.

Signed-off-by: Wangbicheng <wangbicheng@huawei.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
run: reuse command line in standalone images

If the user specifies an image, take the command line from there, instead
of looking for an unrelated build/release/cmdline.

TODO: support --verbose and friends using imgedit.py.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
dhcp.hh: Replaced const with constexpr

Replaced all const specifiers with constexpr in dhcp.hh.

Signed-off-by: Andrei Preda <andreipreda07@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
scsi: Free req and data in scsi_common::exec_inquery

It is not freed after we're done with it.

Signed-off-by: Asias He <asias@cloudius-systems.com>
scsi: Intorduce req->free_by_driver flag

This is used to tell lower-level scsi driver to free the request,
otherwise the scsi layer will free the request.

read/write/flush scsi are async request, they are freed by the
lower-level scsi driver. Other scsi request are freed by the scsi layer.

Signed-off-by: Asias He <asias@cloudius-systems.com>
scsi: Introduce req->cdb_len

Set req->cdb_len to the actual size of the scsi command and only copy
the actual size of the command.

This reduces the number of bytes we copy.

This also fixes the warning in pvscsi which complains the size of the
cdb is larger than expected.

Signed-off-by: Asias He <asias@cloudius-systems.com>
scsi: Construct cdb in-place

Instead of copying a scsi cdb, construct it in-place.
This saves 16 bytes of memory copying on every read or write.

Signed-off-by: Asias He <asias@cloudius-systems.com>
apps: update for cassandra/jenkins integration

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
trace: do not attempt to read across the pivot page

This is an optimization. We first check if the entry is valid using
the 'tp' field and only if it is we try to read the rest.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
trace: encode and decode strings

Python3 became more restrictive with regards to string handling than
python2. In python3 strings no longer conform to byte array interface,
they have to be encoded explicitly. The current code throws exception
when run in python3.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
gdb: remove dead import

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
gdb: use "int" type instead of "long"

There is no difference between them in python2 and python3 no
longer has "long".

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>