cli: Refactoring command structure

A small needed refactoring, hopefully before CLI gains attention upstream.

* Refactor the command structure to match the Lua suggested module structure.
* Change "run" method name to "main".

Signed-off-by: Or Cohen <orc@fewbytes.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cli: Add "hello" boilerplate command example

Signed-off-by: Or Cohen <orc@fewbytes.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs: implement sendfile()

An implementation for sendfile() using mmap() and write().
It copies data from in_fd to out_fd without any intermediates.
It assumes that if mmap() succeeds, then munmap() will most
likely succeed. If not, it ignores return value of munmap().

Fixes #363
Fixes #273

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Jaspal Singh Dhillon <jaspal.iiith@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: add tests for sendfile()

A battery of tests for sendfile().
The tests belong to 2 groups:
1. copy data from file to file
2. copy data from file to a socket
In both cases, two sub-cases arise: the offset is/is not NULL.

Signed-off-by: Jaspal Singh Dhillon <jaspal.iiith@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
ide: fix drive availability check

Nadav explains:

  After commit 2a56d98d7de1db014d8ac03cca12ecfb524dd83c fixed the PCI
  offset constants, OSv suddenly became able to mount IDE devices.
  Unfortunately, on VMware, it wrongly recognized both an IDE and a pscsi
  device, resulting in two drivers trying to take the "vblk0" name and
  causing a sys_panic() and a crashed boot (see full stack trace in issue
  #369).

  It turns out that our IDE device recognition code wasn't diligent
  enough in trying to recognize devices which appear to be there, but
  actually aren't, as happened on VMware. Remember that a physical
  computer can have an IDE controller, but no disk actually plugged in,
  and so can the virtual counterpart. This patch adds better tests for the
  existence of the IDE disk, and now on VMware we no longer wrongly-see an
  IDE disk, and VMware boot is back to normal.

Fixes #369

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: run tests with --unsafe-cache

Much faster on spinning disks.

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