Commit Graph

492 Commits

Author SHA1 Message Date
Rob Bradford
f63cb85f93 net_util: Implement fmt::Display for MacAddr
Updated clippy does not like the declaration of a "to_string()" function
and instead requires fmt::Display to be implemented.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-09-27 08:05:56 -07:00
Rob Bradford
ff1cb11946 arch: Use if-let notation
To keep updated clippy happy.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-09-27 08:05:56 -07:00
Rob Bradford
df2516f229 vhost_rs: Add clippy override
clippy wants us to use "if let Some(fd) = fd {}" but to combine that
with && is an experimental feature.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-09-27 08:05:56 -07:00
Rob Bradford
2ae3919181 vm-virtio: Fix formatting
With the 1.38.0 toolchain rustfmt is even stricter about formatting now

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-09-27 08:05:56 -07:00
Samuel Ortiz
8188074300 main: Start the VMM thread
We now start the main VMM thread, which will be listening for VM and IPC
related events.
In order to start the configured VM, we no longer directly call the VM
API but we use the IPC instead, to first create and then start a VM.

Fixes: #303

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-26 16:21:14 +02:00
Samuel Ortiz
e235c6de4f vmm: Add VM creation and startup helpers
Based on the newly defined Cloud Hypervisor IPC, those helpers send
VmCreate and VmStart requests respectively. This will be used by the
main thread to create and start a VM based on the CLI parameters.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-26 16:21:14 +02:00
Samuel Ortiz
151f96e454 vmm: Add a VMM thread startup routine
This starts the main, single VMM thread, which:

1. Creates the VMM instance
2. Starts the VMM control loop
3. Manages the VMM control loop exits for handling resets and shutdowns.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-26 16:21:14 +02:00
Samuel Ortiz
2f1ff23066 vmm: (Re-)Introduce a VMM structure
Unlike the Vmm structure we removed with commit bdfd1a3f, this new one
is really meant to represent the VM monitoring/management object.
For that, we implement a control loop that will replace the one that's
currently embedded within the Vm structure itself.
This will allow us to decouple the VM lifecycle management from the VM
object itself, by having a constantly running VMM control loop.

Besides the VM specific events (exit, reset, stdin for now), the VMM
control loop also handles all the Cloud Hypervisor IPC requests.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-26 16:21:14 +02:00
Samuel Ortiz
4671a5831f vmm: Move the EpollContext implementation to lib
The VMM thread and control loop will be the sole consumer of the
EpollContext and EpollDispatch API, so let's move it to lib.rs.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-26 16:21:14 +02:00
Samuel Ortiz
03ab6839c1 vmm: Introduce Cloud Hypervisor IPC
Cloud Hypervisor IPC is a simple, mpsc based protocol for threads to
send command to the furture VMM thread. This patch adds the API
definition for that IPC, which will be used by both the main thread
to e.g. start a new VM based on the CLI arguments and the future HTTP
server to relay external requests received from a local Unix domain
socket.
We are moving it to its own "api" module because this is where the
external API (HTTP based) will also be implemented.

The VMM thread will be listening for IPC requests from an mpsc receiver,
process them and send a response back through another mpsc channel.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-26 16:21:14 +02:00
Samuel Ortiz
6710a39b5a vmm: Pass the exit and reset fds to the vm creation method
As we're going to move the control loop to the VMM thread, the exit and
reset EventFds are no longer going to be owned by the VM.
We pass a copy of them when creating the Vm instead.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-26 16:21:14 +02:00
Samuel Ortiz
feb1c33084 vmm: Add a VM config getter
We will need it from the VMM thread, when trying to reboot a VM.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-26 16:21:14 +02:00
Samuel Ortiz
47167a658e vmm: Add a VM console handling method
In order to handle the VM STDIN stream from a separate VMM thread
without having to export the DeviceManager, we simply add a console
handling method to the Vm structure.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-26 16:21:14 +02:00
Samuel Ortiz
ea7abc6c80 vmm: Add a VM stop method
In order to transfer the control loop to a separate VMM thread, we want
to shrink the VM control loop to a bare minimum.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-26 16:21:14 +02:00
Samuel Ortiz
e6ef9ece2c vmm: Move the tty setting to the VM start routine
We want to shrink the control loop to a bare minimal.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-26 16:21:14 +02:00
Samuel Ortiz
2e9d815701 vmm: Use a reference counted VmConfig when creating a new VM
Once passed to the VM creation routine, a VmConfig structure is
immutable. We can simply carry a Arc of it instead of a reference.
This also allows us to remove any lifetime bound from our VM.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-26 16:21:14 +02:00
Samuel Ortiz
2e0f1c2afe README: Update Slack invitation link
The current one is no longer valid.
The new one does not expire.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-25 13:25:00 +01:00
dependabot-preview[bot]
e869283b4e build(deps): bump cfg-if from 0.1.9 to 0.1.10
Bumps [cfg-if](https://github.com/alexcrichton/cfg-if) from 0.1.9 to 0.1.10.
- [Release notes](https://github.com/alexcrichton/cfg-if/releases)
- [Commits](https://github.com/alexcrichton/cfg-if/compare/0.1.9...0.1.10)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-09-24 20:30:43 +00:00
Samuel Ortiz
bdfd1a3f38 vmm: Remove the Vmm structure
The Vmm structure is just a placeholder for the KVM instance. We can
create it directly from the VM creation routine instead.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-24 10:12:04 +02:00
Samuel Ortiz
9c5135da7a vmm: Simplify the VM start flow
We can integrate the kernel loading into the VM start method.
The VM start flow is then: Vm::new() -> vm.start(), which feels more
natural.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-24 10:12:04 +02:00
Samuel Ortiz
b79c1f7722 vmm: Derive the clone trait for VmConfig
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-24 08:39:39 +01:00
Samuel Ortiz
acc60b0ad5 vmm: Make VsockConfig owned
Convert Path to PathBuf and remove the associated lifetime.
Now we can remove the VmConfig associated lifetime.

Fixes #298

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-24 08:39:39 +01:00
Samuel Ortiz
3dc7aff00e vmm: Make vhost-user configuration owned
Convert Path to PathBuf, &str to String and remove the associated lifetime.

Fixes #298

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-24 08:39:39 +01:00
Samuel Ortiz
5f8a62f3d0 vmm: Make DeviceConfig owned
Convert Path to PathBuf and remove the associated lifetime.

Fixes #298

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-24 08:39:39 +01:00
Samuel Ortiz
36137232f0 vmm: Make ConsoleConfig owned
Convert Path to PathBuf and remove the associated lifetime.

Fixes #298

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-24 08:39:39 +01:00
Samuel Ortiz
79a02f9171 vmm: Make PmemConfig owned
Convert Path to PathBuf and remove the associated lifetime.

Fixes #298

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-24 08:39:39 +01:00
Samuel Ortiz
00674cd850 vmm: Make FsConfig owned
Convert Path to PathBuf, &str to String and remove the associated lifetime.

Fixes #298

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-24 08:39:39 +01:00
Samuel Ortiz
5323da031c vmm: Make RngConfig owned
Convert Path to PathBuf and remove the associated lifetime.

Fixes #298

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-24 08:39:39 +01:00
Samuel Ortiz
0688bec298 vmm: Make NetConfig owned
Convert str to String and remove the associated lifetime.

Fixes #298

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-24 08:39:39 +01:00
Samuel Ortiz
675e46355c vmm: Make DiskConfig owned
Convert Path to PathBuf and remove the associated lifetime.

Fixes #298

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-24 08:39:39 +01:00
Samuel Ortiz
036890e5be vmm: Make KernelConfig owned
Convert Path to PathBuf and remove the associated lifetime.

Fixes #298

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-24 08:39:39 +01:00
Samuel Ortiz
9c5bfb8e13 vmm: Make MemoryConfig owned
Convert Path to PathBuf and remove the associated lifetime.

Fixes #298

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-24 08:39:39 +01:00
dependabot-preview[bot]
dbff0e94b8 build(deps): bump backtrace from 0.3.37 to 0.3.38
Bumps [backtrace](https://github.com/rust-lang/backtrace-rs) from 0.3.37 to 0.3.38.
- [Release notes](https://github.com/rust-lang/backtrace-rs/releases)
- [Commits](https://github.com/rust-lang/backtrace-rs/compare/0.3.37...0.3.38)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-09-23 20:08:09 +00:00
Sebastien Boeuf
0c8f9d2768 ci: Boot from vhost-user-blk with hypervisor-fw
Now that vhost-user has been fixed regarding size of the virtqueues,
booting a VM with the firmware from a vhost-user-blk backend actually
works. That's why this commit updates the previously introduced
integration test to make it use the firmware instead of direct kernel
boot.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-23 17:29:38 +01:00
Sebastien Boeuf
f06b2aaaa7 vm-virtio: vhost-user: Set the right vring size
The vhost-user implementation was always passing the maximum size
supported by the virtqueues to the backend, but this is obviously wrong
as it must pass the size being set by the driver running in the guest.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-23 17:29:38 +01:00
dependabot-preview[bot]
a2f3da3488 build(deps): bump arc-swap from 0.4.2 to 0.4.3
Bumps [arc-swap](https://github.com/vorner/arc-swap) from 0.4.2 to 0.4.3.
- [Release notes](https://github.com/vorner/arc-swap/releases)
- [Changelog](https://github.com/vorner/arc-swap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/vorner/arc-swap/compare/v0.4.2...v0.4.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-09-21 08:11:43 +00:00
Sebastien Boeuf
2cd406ba50 vm-virtio: Fix virtio-pci BAR type
The 32 or 64 bits type for the memory BAR was not set correctly. This
patch ensure the right type is applied to the BAR.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-21 09:11:30 +01:00
Sebastien Boeuf
29b3848ffb ci: Add a test to validate the VM can be booted from vhost-user-blk
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-20 15:56:51 +02:00
Sebastien Boeuf
d723b7dae8 vm-virtio: vhost-user-blk: Add support for reset
If we expect the vhost-user-blk device to be used for booting a VMM
along with the firmware, then need the device to support being reset.

In the vhost-user context, this means the backend needs to be informed
the vrings are disabled and stopped, and the owner needs to be reset
too.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-20 15:56:51 +02:00
Sebastien Boeuf
0a229ef4f5 ci: Extend vhost-user-blk test to validate the content
This commit extends the existing integration test related to
vhost-user-blk by validating the block image contains one file
"foo" containing "bar".

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-20 15:56:51 +02:00
Yang Zhong
6b06cec611 ci: add test case for vhost-user-blk
Currently we need use backend device from Qemu to test vhost-user-blk
device. Once the rust backend is ready, we will replace it.

Signed-off-by: Yang Zhong <yang.zhong@intel.com>
2019-09-20 15:56:51 +02:00
Yang Zhong
360980d93c vhost-user-blk: enable write_config for WCE
In vhost-user-blk, only WCE value can be set back to device in
guest kernel like
echo "write through" > /sys/block/vda/cache_type

So write_config() will only set WCE value from guest kernel to
vhost user side.

Signed-off-by: Yang Zhong <yang.zhong@intel.com>
2019-09-20 15:56:51 +02:00
Yang Zhong
39083d705b vhost-user-blk: make read_config work
Since config space in vhost-user-blk are mostly from backend
device, this change will get config space info from backend
by vhost-user protocol.

Signed-off-by: Yang Zhong <yang.zhong@intel.com>
2019-09-20 15:56:51 +02:00
Yang Zhong
a949ab21f7 main: add arguments entry for vhost-user-blk
To add vhost-user-blk support, it requires to add arguments
passed for it.

Signed-off-by: Yang Zhong <yang.zhong@intel.com>
2019-09-20 15:56:51 +02:00
Yang Zhong
4164853ec6 vmm: add vhost-user-blk support
Update vm configuration and device initial process to add
vhost-user-blk support.

Signed-off-by: Yang Zhong <yang.zhong@intel.com>
2019-09-20 15:56:51 +02:00
Yang Zhong
c7559bb7a4 config: make error definition common
Since vhost-user-blk use same error definition with vhost-user-net,
those errors need define to common usage.

Signed-off-by: Yang Zhong <yang.zhong@intel.com>
2019-09-20 15:56:51 +02:00
Yang Zhong
397d388710 vm-virtio: Add vhost-user-blk implementation
vhost-user-blk has better performance than virtio-blk, so we need
add vhost-user-blk support with SPDK in Rust-based VMMs.

Signed-off-by: Yang Zhong <yang.zhong@intel.com>
2019-09-20 15:56:51 +02:00
Yang Zhong
b232de9963 vhost_rs: Add INFLIGHT_SHMFD protocol feature
Add to the vhost_rs crate the INFLIGHT_SHMFD protocol feature that was
missing from the list. The feature has been recently introduced in
vhost-user specification, which is the reason why it was missing.

Signed-off-by: Yang Zhong <yang.zhong@intel.com>
2019-09-20 15:56:51 +02:00
Sebastien Boeuf
927148dd3c vhost_rs: Fix GET_CONFIG command
Following the vhost-user specification that can be found at
https://github.com/qemu/qemu/blob/master/docs/interop/vhost-user.rst#virtio-device-config-space
this patch fixes the GET_CONFIG command.

This command is very specific as it needs to provide a body and a
payload corresponding to the content of the configuration structure as
an array of bytes. As a reply, it receives the body and payload provided
by the slave.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-20 15:56:51 +02:00
Yang Zhong
c347f84d74 Revert "vhost_rs: add config messge support"
This reverts commit 3e99098bf3 because we
realized there was no need for those extra functions to be introduced as
the existing one from the vhost crate are sufficient for the vhost-user
configuration use case.
2019-09-20 15:56:51 +02:00