Commit Graph

6482 Commits

Author SHA1 Message Date
Samuel Ortiz
d5f5648b37 vendor: Add vendored dependencies
We use cargo vendor to generate a .cargo/config file and the vendor
directory. Vendoring allows us to lock our dependencies and to modify
them easily from the top level Cargo.toml.

We vendor all dependencies, including the crates.io ones, which allows
for network isolated builds.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-06-04 17:51:52 +02:00
Rob Bradford
e3f7bc2e9d build: Update Cargo.lock to reflect changed dependencies
This also adds a new comment to Cargo.lock that is introduced by newer
cargo.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-06-03 14:18:18 +01:00
Jing Liu
8370a5bcc2 vmm: Repair the port IO memory alignment
The IO memory alignment should be set as byte alignment instead of 0x400
which is copied from crosvm.

Signed-off-by: Jing Liu <jing2.liu@linux.intel.com>
2019-05-28 08:05:55 -07:00
Sebastien Boeuf
e5e651895b config: Reorganize command line parsing
The command line parsing of the user input was not properly
abstracted from the vmm specific code. In the case of --net,
the parsing was done when the device manager was adding devices.

In order to fix this confusion, this patch introduces a new
module "config" dedicated to the translation of a VmParams
structure into a VmCfg structure. The former is built based
on the input provided by the user, while the latter is the
result of the parsing of every options.

VmCfg is meant to be consumed by the vmm specific code, and
it is also a fully public structure so that it can directly
be built from a testing environment.

Fixes #31

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-05-24 17:08:52 +01:00
Rob Bradford
9900daacf8 README: Update for new --disk usage
And fix the use of "also" that remained when the two sections on usage
were flipped around.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-05-22 17:46:59 +01:00
Rob Bradford
a09f918adc main, vmm: Add support for multiple --disk options
Store the list of disks in a Vec<PathBuf> and then iterate over that
when creating the block devices.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-05-22 17:46:59 +01:00
Samuel Ortiz
52790424f2 vm-allocator: Force documenting all public APIs
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-22 07:44:32 +02:00
Samuel Ortiz
9f247751e7 vm-allocator: Allow for freeing system resources
We allow freeing PIO and MMIO address ranges for now.

Fixes: #27

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-22 07:44:32 +02:00
Samuel Ortiz
4b451b01d9 vm-allocator: Allow for freeing address ranges
We can only free ranges that exactly map an already allocated one, i.e.
this is not a range resizing.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-22 07:44:32 +02:00
Samuel Ortiz
8bb71fad76 vmm: Simplify the vcpu run switch
Use a catchall case for all reasons that we do not handle, and
move the vCPU run switch into its own function.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-21 07:56:17 -07:00
Logan Saso
6615d55223 Revert "main: Fix --net behavior"
This reverts commit 8e9e7601f5.
2019-05-17 21:22:21 +01:00
Sebastien Boeuf
8e9e7601f5 main: Fix --net behavior
Recent refactoring of the flags parsing broke the --net behavior where
the network tap interface should be created by the VMM if the user does
not provide any argument to this option.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-05-17 00:42:33 +01:00
Logan Saso
e52132c8c8 main: refactored parameter parsing
CONTRIBUTING.md: removed a space to suport markdown linking

Refactored cmdline and net_params arguments to use option adapters
to achieve the same parsed results in a "more rusty" way.

Deleted a space in the contributing markdown to link properly.

Signed-off-by: Logan Saso <logansaso+tech@gmail.com>
2019-05-16 19:22:21 +01:00
Samuel Ortiz
9299502955 cloud-hypervisor: Switch to crates.io kvm-ioctls
Fixes: #15

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-15 05:59:08 +01:00
Samuel Ortiz
0d8193778c README: Add travis build status badge
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-14 18:18:11 +01:00
Sebastien Boeuf
c1f1fe713f vm: Propagate errors appropriately
In order to get meaningful error messages, we want to make sure all
errors are passed up the call stack. This patch fixes this previous
limitation by separating errors related to the DeviceManager from
errors related to the Vm.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-05-14 05:34:35 +01:00
Chao Peng
6ecdd98634 virtio: Enable qcow support for virtio-block
With this enabled, one can pass a QCOW format disk
image with '--disk' switch.

Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
2019-05-13 22:08:29 +01:00
Samuel Ortiz
919226f31e cloud-hypervisor: Add README
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-12 23:15:30 +02:00
Samuel Ortiz
b60ef22100 cloud-hypervisor: Add CREDITS
Giving credits to Firecracker, crosvm and rust-vmm contributors.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-12 23:15:30 +02:00
Samuel Ortiz
bcd562e271 cloud-hypervisor: Add a contributing guide
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-12 23:15:30 +02:00
Samuel Ortiz
4daf999cad cloud-hypervisor: Add initial list of maintainers
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-12 23:15:30 +02:00
Samuel Ortiz
929b343bce cloud-hypervisor: Adopt the Contributor Covenant code of conduct
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-12 23:15:30 +02:00
Rob Bradford
adb0abf400 main: Make supplying the commandline optional
If no commandline is supplied replace with an empty string. No kernel
commandline is needed when using the firmware to boot.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-05-10 16:32:39 +02:00
Samuel Ortiz
2c94529660 vmm: Propagate boot_kernel errors properly
So that our error traces are more meaningful.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-10 16:32:39 +02:00
Samuel Ortiz
43965eda6f main: Improve guest setting log format
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-10 16:32:39 +02:00
Samuel Ortiz
fe99c29743 vm-virtio: Remove useless PCI BAR debug log
We should not unconditionally display our virtio PCI BAR setting.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-10 16:32:39 +02:00
Samuel Ortiz
83dadb818f vmm: Remove useless memory setting log
We don't really need to tell everyone where the host and guest memory
address is...

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-10 16:32:39 +02:00
Samuel Ortiz
3f38b42f05 vmm: Fix the Error enum comment
Our error handling is no longer only related to KVM ioctls.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-10 16:32:39 +02:00
Samuel Ortiz
cacce5f7c4 vmm: Use random local MAC address as the default one
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-10 16:32:39 +02:00
Samuel Ortiz
576a28ae5e net_util: Add helper for generating a random local MAC
We must ensure our MAC addresses do not conflict with a global one.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-10 16:32:39 +02:00
Sebastien Boeuf
5934f30fde vmm: Add support for letting the VMM create the TAP interface
Until now, the only way to get some networking with cloud-hypervisor
was to let the user create a TAP interface first, and then to provide
the name of this interface to the VMM.

This patch extend the previous behavior by adding the support for the
creation of a brand new TAP interface from the VMM itself. In case no
interface name is provided through "tap=<if_name>", we will assume
the user wants the VMM to create and set the interface on its behalf,
no matter the value of other parameters (ip, mask, and mac).
In this same scenario, because the user expects the VMM to create the
TAP interface, he can also provide the associated IP address and subnet
mask associated with it. In case those values are not provided, some
default ones will be picked.

No matter the value of "tap", the MAC address will always be set, and
if no value is provided, the VMM will come up with a default value for
it.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-05-10 16:32:39 +02:00
Samuel Ortiz
0c4c330843 cloud-hypervisor: Switch to the linux-loader pending PR branch
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-10 16:32:39 +02:00
Samuel Ortiz
ac328df87c cloud-hypervisor: Switch to the vmm-sys-util pending PR branch
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-10 16:32:39 +02:00
Chao Peng
8e7579b20e vm-virtio: Add virtio-rng implementation
Most of the code is taken from crosvm(bbd24c5) but is modified to
be adapted to the current VirtioDevice definition and epoll
implementation.

A new command option '--rng' is provided and it gives one the option
to override the entropy source which is /dev/urandom by default.

Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
2019-05-10 16:32:39 +02:00
Chao Peng
97865b605f vmm: Provide a common method to build a virtio PCI device
Since more virtio devices will be added and this code can be reused
for any type of virtio device.

Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
2019-05-10 16:32:39 +02:00
Sebastien Boeuf
c0be6642ad vmm: Leverage virtio-net to provide connectivity
This patch expand the device registration to add a new virtio-net
device in case the user provide the appropriate flag --net from the
command line.

If the flag is provided, the code will parse the TAP interface name
and the expected MAC address from the command line. The VM will be
connected to the provided TAP interface, and it will communicate the
MAC address to the virtio-net driver.

If the flag is not provided, the VM will not register any virtio-net
device, therefore it will not have any connectivity with the host.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-05-10 16:32:39 +02:00
Sebastien Boeuf
53f5295454 network: Add virtio-net dependencies
The newly added virtio-net implementation needs to interact with TAP
interfaces and MAC addresses, which is the reason why it is easier
to rely on existing packages net_util and net_gen.

One more thing, both net_util and net_gen could be trimmed down,
based on using only the things we need from cloud-hypervisor.

Both net_util, net_gen and sys_util are based on Firecracker
commit d4a89cdc0bd2867f821e3678328dabad6dd8b767.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-05-10 16:32:39 +02:00
Sebastien Boeuf
6d27cfb3b6 vm-virtio: Create virtio-net device
In order to provide connectivity through network interface between
host and guest, this patch introduces the virtio-net backend.

This code is based on Firecracker commit
d4a89cdc0bd2867f821e3678328dabad6dd8b767

It is a trimmed down version of the original files as it removes the
rate limiter support. It has been ported to support vm-memory crate
and the epoll handler has been modified in order to run a dedicated
epoll loop from the device itself. This epoll loop runs in its own
dedicated thread.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-05-10 16:32:39 +02:00
Sebastien Boeuf
1d450c527f gitignore: Don't track Cargo.lock files
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-05-10 16:32:39 +02:00
Sebastien Boeuf
513e4ffb52 gitignore: Don't track rusty-tags.vi files
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-05-10 16:32:39 +02:00
Rob Bradford
4b58eb4867 pci: configuration: Fix rustfmt issue
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-05-10 16:32:39 +02:00
Rob Bradford
ce1d90c15b devices: legacy: Fix rustfmt issue
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-05-10 16:32:39 +02:00
Rob Bradford
a0bbcefa14 cloud-hypervisor: Recursively run rustfmt
"cargo fmt --all -- check" does not check all the other crates in the
repository so replace this with a find command. In the long term it
might be appropriate to use a cargo workspace to solve this problem.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-05-10 16:32:39 +02:00
Sebastien Boeuf
a9ed8fa499 resources: Add a 5.0 kernel config
This is helpful and actually needed to ensure everyone is testing
from the same kernel reference.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-05-10 16:32:22 +02:00
Samuel Ortiz
81875f5be5 cloud-hypervisor: Add basic Travis based CI
We only run builds, tests and static checks for now.

Fixes: #7

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-09 15:45:50 +02:00
Rob Bradford
1151b07682 vm-virtio: block: Add support for resetting a block device
As it is necessary to return the interrupt EventFD and the queue EventFD
to the transport layer upon reset the activate function has been
modified to clone these descriptors as well as the underlying disk
itself.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-05-09 15:44:18 +02:00
Rob Bradford
3b2faa9f11 vm-virtio: Reset underlying device on driver request
If the driver triggers a reset by writing zero into the status register
then reset the underlying device if supported. A device reset also
requires resetting various aspects of the queue.

In order to be able to do a subsequent reactivate it is required to
reclaim certain resources (interrupt and queue EventFDs.) If a device
reset is requested by the driver but the underlying device does not
support it then generate an error as the driver would not be able to
configure it anyway.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-05-09 15:44:18 +02:00
Samuel Ortiz
040ea5432d cloud-hypervisor: Add proper licensing
Add the BSD and Apache license.
Make all crosvm references point to the BSD license.
Add the right copyrights and identifier to our VMM code.
Add Intel copyright to the vm-virtio and pci crates.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-09 15:44:17 +02:00
Samuel Ortiz
8f05773eae vmm: Fix build warning
Use the VM vcpus vector instead of creating a mutable one.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-09 15:44:17 +02:00
Sebastien Boeuf
5c9fc816de serial: Set terminal in raw mode
In order to have proper output from the serial, we need to setup the
terminal in raw mode. When the VM is shutting down, it is also the
VMM responsibility to set the terminal back into canonical mode if we
don't want to get any weird behavior from the shell.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-05-09 15:44:17 +02:00