DHCP: Support MTU option

This patch introduces support for MTU option as described in
RFC2132, chapter 5.1. Interface MTU Option

Amazon EC2 networking uses this option in some cases and it gives
throughput improvement of about 250% on big instances with 10G networking.

Netperf results for hi1.4xlarge instances, TCP_MAERTS test, OSv runs netserver:

Send buffer size     Throughput w/ patch (Mbps)     Throughput w/o patch (Mbps)     Improvement (%)

32                   4912.29                        1386.28                         254
64                   4832.01                        1385.99                         249
128                  4835.09                        1401.46                         245
256                  4746.41                        1382.28                         243
512                  4849.04                        1375.23                         253
1024                 4631.8                         1356.69                         241
2048                 4859.59                        1371.92                         254
4096                 4864.99                        1383.67                         252
8192                 4627.07                        1364.05                         239
16384                4868.73                        1366.48                         256
32768                4822.69                        1366.63                         253
65536                4837.67                        1353.87                         257

Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
elf: fix object::lookup_addr to lookup correct symbol

Fix object::lookup_addr to lookup correct symbol.
It should returns the nearest symbol which is s_addr < addr, but it
compares opposite way.

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
sysinfo(): fix stack overwrite

sysinfo() used sizeof(struct sysinfo) to decide how many zeros to write.
The problem is that our struct was much larger than Linux's (we had a much
larger padding at the end), so if we run code compiled on Linux, that code
would allocate a small structure on the stack and then zero a much larger
structure, causing the stack to be corrupted.

Drop the "reserved" field making our structure larger. It's not needed.

Fixes #174.

Tested-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
sysinfo(): Provide some real measurements

sysinfo() until now was a stub. This patches fills some of the information
we can already provide, namely the uptime in seconds (through the recently
added osv::clock::uptime()), the total and free memory (through the recently
added memory::stats::free()/total() functions), and number of processes
(always 1 on OSv).

This patch also changes a couple of types from unsized names (like "unsigned")
to fixed-sized ones (like "u32"), to match the definition of this structure
on Linux. It won't make any difference on x86_64, but perhaps in some future
architecture it will.

Tested-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
run.py: without -e, revert to the default command line.

As issue #128 explains, it is annoying that once the "-e" option was used
in run.py, it overrides the default command line, so that running run.py
again without -e reruns the same modified command line, and not the default
one as usual.

This simple patch changes this behavior: On every run of run.py, the command
line is set - if "-e" is given it is set to the given command line, but if
"-e" is absent, the command line is reset to the default one. This is
basically the behavior that people always wanted from run.py.

This patch, and the behavior it performs, are much simpler than any of
the alternatives proposed in issue #128.

Please don't complain that this can only be used for development, and not
for EC2, for creating images to distribute, and so on. After all, this is a
patch to *run.py*, and it is obviously not relevant to anyone who is running
an OSv image not through run.py. This patch only makes run.py more convenient
to use.

Fixes #128.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
run.py: Add -V (--verbose) option

The OSv loader has a "--verbose" option to enable debug() output to be
printed to the console and not just to a memory buffer. However, needing to
pass this option in the "-e" string is annoying, and even worse when you want
to use the default command line and didn't even want an explict "-e" option.

So this patch adds a --verbose to run.py, which can be used whether or not
a "-e" option is given. For example:

    run.py --verbose
or
    run.py --verbose tests/tst-timerfd.so

As a shorthand for --verbose, I used "-V". Unfortunately, lowercase "-v"
was already taken (by the "vhost" option).

Fixes #173.

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

This would be useful for device with mmio bar, e.g. AHCI controller.

Signed-off-by: Asias He <asias@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
virtio: Do not call setup_features twice

setup_features() is called twice, once in virtio_driver constructor and
once in virtio device driver constructor. Doing it in driver constructor
is enough.

Signed-off-by: Asias He <asias@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
virtio-scsi: Skip uio size check in driver

The check is moved to bdev_read and bdev_write.

Signed-off-by: Asias He <asias@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
posix_memalign: Remove the extra check on size

Remove the extra check on size just like the remark above implies.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc: added gethostbyname()

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc: added __snprintf_chk() and __vasprintf_chk()

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc: added rand_r()

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