Commit Graph

350 Commits

Author SHA1 Message Date
Yang Zhong
3e99098bf3 vhost_rs: add config messge support
The previous definitions does not cover config space read/write
and only cover general message as below:

A vhost-user message consists of 3 header fields and a payload.

+---------+-------+------+---------+
| request | flags | size | payload |
+---------+-------+------+---------+

but for config space, the payload include:

Virtio device config space
^^^^^^^^^^^^^^^^^^^^^^^^^^

+--------+------+-------+---------+
| offset | size | flags | payload |
+--------+------+-------+---------+

:offset: a 32-bit offset of virtio device's configuration space

:size: a 32-bit configuration space access size in bytes

🎏 a 32-bit value:
  - 0: Vhost master messages used for writeable fields
  - 1: Vhost master messages used for live migration

:payload: Size bytes array holding the contents of the virtio
          device's configuration space

This patch add specific functions for config message, which can
get/set config space from/to backend.

Signed-off-by: Yang Zhong <yang.zhong@intel.com>
2019-09-03 08:39:37 -07:00
Yang Zhong
e05de4514d vhost_rs: The vhost user version we support
The vhost user version should be same with backend.
define VHOST_USER_VERSION    (0x1)

Signed-off-by: Yang Zhong <yang.zhong@intel.com>
2019-09-03 08:39:37 -07:00
Yang Zhong
6fb7c3bbc2 vhost_rs: remove config space offset setting
There is one definition in message.rs file as below:
pub const VHOST_USER_CONFIG_OFFSET: u32 = 0x100

This definition is only for virtio mmio config space
and we will add this offset in virtio-mmio side and
not vhost user protocl side.

Signed-off-by: Yang Zhong <yang.zhong@intel.com>
2019-09-03 08:39:37 -07:00
Yang Zhong
a44a903587 vhost_rs: Change get_config()/set_config()
Use acked_protocol_features to replace acked_virtio_features in
get_config()/set_config() for protocol features like CONFIG.

This patch also fix wrong GET_CONFIG setting for set_config().

Signed-off-by: Yang Zhong <yang.zhong@intel.com>
2019-09-03 08:39:37 -07:00
Yang Zhong
b4187a1b9d vhost_rs: Change the VhostUserConfigFlags
The latest vhost user spec only define two members in
VhostSetConfigType, master and live migration. These
changes can make rust-vmm compatible with vhost user backend.

Signed-off-by: Yang Zhong <yang.zhong@intel.com>
2019-09-03 08:39:37 -07:00
Samuel Ortiz
8718043dfc cloud-hypervisor: Bump vmm-sys-util crate version
Bump from 829d605 to fd4dcd1.

PR #225 failed because we were still using the vmm-sys-util logging
macros and the crate's syslog module got removed.

This one relies on the previous commit switching to using the
log crate macros instead.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-02 15:07:42 +02:00
Samuel Ortiz
add0471120 vfio: Use the log crate macros
Instead of using the syslog vmm-sys-util ones.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-09-02 15:07:42 +02:00
Sebastien Boeuf
772191b409 vm-virtio: vhost-user: Rely on acked features to setup backend
At this point in the code, the acked features have been provided by the
guest and they can be set back to the backend. There's no need to
retrieve one more time the backend features for this purpose.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-08-31 17:33:17 +01:00
Sebastien Boeuf
97699a521f vm-virtio: vhost-user: Vring should be enabled after initialization
As mentioned in the vhost-user specification, each ring is initialized
in a stopped state. This means each ring should be enabled only after
it has been correctly initialized.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-08-31 17:33:17 +01:00
Sebastien Boeuf
a4ebcf486d vm-virtio: vhost-user-net: Map proper error when getting features
Simple patch replacing unwrap() with appropriate map_err().

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-08-31 17:33:17 +01:00
Sebastien Boeuf
cdfe576eb1 vm-virtio: vhost-user-net: Set the right set of features
The available features are masked with the backend features, therefore
the available features should be the one used when calling into
set_features() API.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-08-31 17:33:17 +01:00
Sebastien Boeuf
bc42420583 vm-virtio: Expand vhost-user handler to be reused from virtio-fs
In order to factorize the code between vhost-user-net and virtio-fs one
step further, this patch extends the vhost-user handler implementation
to support slave requests.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-08-31 17:33:17 +01:00
Sebastien Boeuf
b7d3ad9063 vm-virtio: fs: Factorize vhost-user setup
This patch factorizes the existing virtio-fs code by relying onto the
common code part of the vhost_user module in the vm-virtio crate.

In details, it factorizes the vhost-user setup, and reuses the error
types defined by the module instead of defining its own types.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-08-31 17:33:17 +01:00
Sebastien Boeuf
56cad00f2e vm-virtio: Move fs.rs to vhost_user module
vhost-user-net introduced a new module vhost_user inside the vm-virtio
crate. Because virtio-fs is actually vhost-user-fs, it belongs to this
new module and needs to be moved there.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-08-31 17:33:17 +01:00
Cathy Zhang
cc7a96e9d3 main: Add integration test
Use qemu/tests/vhost-user-bridge as the backend for integration
test for vhost-user-net.

Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
2019-08-30 15:00:26 +01:00
Cathy Zhang
f21d54f6b0 main: Add arguments entry for vhost-user-net
Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
2019-08-30 15:00:26 +01:00
Cathy Zhang
584a2cccee vmm: Add vhost-user-net support
Update vm configuration and device initial process to add
vhost-user-net support.

Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
2019-08-30 15:00:26 +01:00
Cathy Zhang
633f51af9c vm-virtio: Add vhost-user-net implementation
vhost-user framwork could provide good performance in data intensive
scenario due to the memory sharing mechanism. Implement vhost-user-net
device to get the benefit for Rust-based VMMs network.

Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
2019-08-30 15:00:26 +01:00
Cathy Zhang
51306555e7 vmm: Add hugetlbfs handling support
The currently directory handling process to open tempfile by
OpenOptions with custom_flags(O_TMPFILE) is workable for tmp
filesystem, but not workable for hugetlbfs, add new directory
handling process which works fine for both tmpfs and hugetlbfs.

Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
2019-08-30 15:00:26 +01:00
dependabot-preview[bot]
ce60ff16c4 build(deps): bump vmm-sys-util from a0b3893 to 829d605
Bumps [vmm-sys-util](https://github.com/rust-vmm/vmm-sys-util) from `a0b3893` to `829d605`.
- [Release notes](https://github.com/rust-vmm/vmm-sys-util/releases)
- [Commits](a0b3893a40...829d605a07)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-30 11:35:54 +00:00
dependabot-preview[bot]
3dd329052c build(deps): bump vmm-sys-util from 2177381 to a0b3893
Bumps [vmm-sys-util](https://github.com/rust-vmm/vmm-sys-util) from `2177381` to `a0b3893`.
- [Release notes](https://github.com/rust-vmm/vmm-sys-util/releases)
- [Commits](2177381ed6...a0b3893a40)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-29 07:59:39 +00:00
Sebastien Boeuf
b2f85cbdc4 vhost_rs: Wait for full request to be satisfied
The recvmsg syscall can split a request in multiple packets unless we
use the flag MSG_WAITALL to make sure the request will wait for the
whole data to be transferred before returning.

This flag is needed to prevent the vhost crate from returning the error
PartialMessage, which occured sporadically when using virtio-fs, and
which was detected as part of our continuous integration testing.

Fixes #182

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-08-29 11:01:32 +08:00
dependabot-preview[bot]
18a8bb0072 build(deps): bump vmm-sys-util from 7222869 to 2177381
Bumps [vmm-sys-util](https://github.com/rust-vmm/vmm-sys-util) from `7222869` to `2177381`.
- [Release notes](https://github.com/rust-vmm/vmm-sys-util/releases)
- [Commits](7222869ed3...2177381ed6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-28 11:35:54 +00:00
dependabot-preview[bot]
151637b647 build(deps): bump cc from 1.0.40 to 1.0.41
Bumps [cc](https://github.com/alexcrichton/cc-rs) from 1.0.40 to 1.0.41.
- [Release notes](https://github.com/alexcrichton/cc-rs/releases)
- [Commits](https://github.com/alexcrichton/cc-rs/compare/1.0.40...1.0.41)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-28 01:13:15 +00:00
dependabot-preview[bot]
c316c161a6 build(deps): bump vm-memory from 1635f25 to 8669369
Bumps [vm-memory](https://github.com/rust-vmm/vm-memory) from `1635f25` to `8669369`.
- [Release notes](https://github.com/rust-vmm/vm-memory/releases)
- [Commits](1635f25afc...8669369d17)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-27 12:48:10 +00:00
dependabot-preview[bot]
808fcaa43b build(deps): bump lazy_static from 1.3.0 to 1.4.0
Bumps [lazy_static](https://github.com/rust-lang-nursery/lazy-static.rs) from 1.3.0 to 1.4.0.
- [Release notes](https://github.com/rust-lang-nursery/lazy-static.rs/releases)
- [Commits](https://github.com/rust-lang-nursery/lazy-static.rs/compare/1.3.0...1.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-26 13:30:59 +00:00
dependabot-preview[bot]
bc87c9f19b build(deps): bump kvm-ioctls from 37669f6 to 30adb02
Bumps [kvm-ioctls](https://github.com/rust-vmm/kvm-ioctls) from `37669f6` to `30adb02`.
- [Release notes](https://github.com/rust-vmm/kvm-ioctls/releases)
- [Commits](37669f60a0...30adb02158)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-26 13:30:36 +00:00
dependabot-preview[bot]
66a7a94a12 build(deps): bump getrandom from 0.1.10 to 0.1.11
Bumps [getrandom](https://github.com/rust-random/getrandom) from 0.1.10 to 0.1.11.
- [Release notes](https://github.com/rust-random/getrandom/releases)
- [Changelog](https://github.com/rust-random/getrandom/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-random/getrandom/compare/v0.1.10...v0.1.11)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-25 18:03:45 +00:00
Sebastien Boeuf
dfb18ef14a net: Make TAP registration functions immutable
By making the registration functions immutable, this patch prevents from
self borrowing issues with the RwLock on self.mem.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-08-22 08:24:15 +01:00
Sebastien Boeuf
0b8856d148 vmm: Add RwLock to the GuestMemoryMmap
Following the refactoring of the code allowing multiple threads to
access the same instance of the guest memory, this patch goes one step
further by adding RwLock to it. This anticipates the future need for
being able to modify the content of the guest memory at runtime.

The reasons for adding regions to an existing guest memory could be:
- Add virtio-pmem and virtio-fs regions after the guest memory was
  created.
- Support future hotplug of devices, memory, or anything that would
  require more memory at runtime.

Because most of the time, the lock will be taken as read only, using
RwLock instead of Mutex is the right approach.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-08-22 08:24:15 +01:00
Sebastien Boeuf
ec0b5567c8 vmm: Share the guest memory instead of cloning it
The VMM guest memory was cloned (copied) everywhere the code needed to
have ownership of it. In order to clean the code, and in anticipation
for future support of modifying this guest memory instance at runtime,
it is important that every part of the code share the same instance.

Because VirtioDevice implementations need to have access to it from
different threads, that's why Arc must be used in this case.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-08-22 08:24:15 +01:00
Rob Bradford
f4d41d600b virtio: net: Remove TAP fd from epoll when no available descriptors
When there are no available descriptors in the queue (observed when the
network interface hasn't been brought up by the kernel) stop waiting for
notifications that the TAP fd should be read from.

This avoids a situation where the TAP device has data avaiable and wakes
up the virtio-net thread only for the virtio-net thread not read that
data as it has nowhere to put it.

When there are descriptors available in the queue then we resume waiting
for the epoll event on the TAP fd.

This bug demonstrated itself as 100% CPU usage for cloud-hypervisor
binary prior to the guest network interface being brought up. The
solution was inspired by the Firecracker virtio-net code.

Fixes: #208

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-08-21 08:41:28 -07:00
dependabot-preview[bot]
582fc7f989 build(deps): bump constant_time_eq from 0.1.3 to 0.1.4
Bumps [constant_time_eq](https://github.com/cesarb/constant_time_eq) from 0.1.3 to 0.1.4.
- [Release notes](https://github.com/cesarb/constant_time_eq/releases)
- [Commits](https://github.com/cesarb/constant_time_eq/compare/0.1.3...0.1.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-21 08:33:30 +00:00
Sebastien Boeuf
44d8ab06ac vm-virtio: Remove unused dependency from unit tests
AtomicSize was imported but not used.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-08-21 08:51:25 +01:00
Sebastien Boeuf
5f52dd2d1e net_util: Fix clippy error
Make sure to explicitly declare trait objects with the keywork "dyn".

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-08-21 08:51:25 +01:00
dependabot-preview[bot]
aface5bca2 build(deps): bump unicode-width from 0.1.5 to 0.1.6
Bumps [unicode-width](https://github.com/unicode-rs/unicode-width) from 0.1.5 to 0.1.6.
- [Release notes](https://github.com/unicode-rs/unicode-width/releases)
- [Commits](https://github.com/unicode-rs/unicode-width/commits/0.1.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-21 07:40:27 +00:00
Sebastien Boeuf
dc31db478a ci: Fix virtio-fs tests
The virtiofsd daemon takes a bit of time creating and listening on the
socket. By adding 10s timeout, we make sure the vhost-user socket has
been properly created before the VMM tries to connect to it.

Also, the daemon needs cap_dac_override capabilities to access debugfs
filesystem.

Last thing, both virtio-fs and virtio-pmem tests were slightly different
from the others since they were not explicitly killing cloud-hypervisor
and virtiofsd processes once the test was done.

Fixes #182

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-08-21 08:16:16 +01:00
dependabot-preview[bot]
b528e99b18 build(deps): bump backtrace from 0.3.34 to 0.3.35
Bumps [backtrace](https://github.com/rust-lang/backtrace-rs) from 0.3.34 to 0.3.35.
- [Release notes](https://github.com/rust-lang/backtrace-rs/releases)
- [Commits](https://github.com/rust-lang/backtrace-rs/compare/0.3.34...0.3.35)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-20 11:14:36 +00:00
dependabot-preview[bot]
e84179994e build(deps): bump blake2b_simd from 0.5.6 to 0.5.7
Bumps [blake2b_simd](https://github.com/oconnor663/blake2_simd) from 0.5.6 to 0.5.7.
- [Release notes](https://github.com/oconnor663/blake2_simd/releases)
- [Commits](https://github.com/oconnor663/blake2_simd/compare/0.5.6...0.5.7)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-20 10:55:39 +00:00
dependabot-preview[bot]
1d9ad9e7b0 build(deps): bump autocfg from 0.1.5 to 0.1.6
Bumps [autocfg](https://github.com/cuviper/autocfg) from 0.1.5 to 0.1.6.
- [Release notes](https://github.com/cuviper/autocfg/releases)
- [Commits](https://github.com/cuviper/autocfg/compare/0.1.5...0.1.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-20 10:55:23 +00:00
Rob Bradford
26a210a83a arch: x86_64: Fix EBDA adddress
This was set to the MP table address rather than the start of the EBDA.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-08-19 16:04:34 +01:00
dependabot-preview[bot]
55f01b2180 build(deps): bump remain from 0.1.3 to 0.1.4
Bumps [remain](https://github.com/dtolnay/remain) from 0.1.3 to 0.1.4.
- [Release notes](https://github.com/dtolnay/remain/releases)
- [Commits](https://github.com/dtolnay/remain/compare/0.1.3...0.1.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-19 10:18:09 +00:00
dependabot-preview[bot]
49a129f3d3 build(deps): bump serde from 1.0.98 to 1.0.99
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.98 to 1.0.99.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.98...v1.0.99)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-19 10:17:57 +00:00
dependabot-preview[bot]
1c23a09cc6 build(deps): bump getrandom from 0.1.9 to 0.1.10
Bumps [getrandom](https://github.com/rust-random/getrandom) from 0.1.9 to 0.1.10.
- [Release notes](https://github.com/rust-random/getrandom/releases)
- [Changelog](https://github.com/rust-random/getrandom/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-random/getrandom/compare/v0.1.9...v0.1.10)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-19 10:17:45 +00:00
Rob Bradford
f0082fecb9 tests: Make panics generate a backtrace
This will help pinpoint issues when debugging test failures.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-08-16 11:13:36 -07:00
Rob Bradford
8b78e1221e tests: Use newgrp to run unit tests
Rather than set filesystem permissions on the /dev/kvm device instead
use the kvm group added by installing qemu for running the unit tests.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-08-16 09:54:07 -07:00
Rob Bradford
f5a6e3c1ca build: Drop vendor directory from rustfmt command
We've not had a vendor directory for some time now.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-08-16 09:54:07 -07:00
Rob Bradford
d6e3b703ab tests: Rename virtiofsd build path
Adjust to reflect that it's QEMU being built here in preparation for
subsequent PRs that also want to build QEMU.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-08-16 09:54:07 -07:00
Rob Bradford
71154d8362 tests: Use "-f" on directory rm commands
When running the script from an interactive environment there are always
some files inside the git directory that rm prompts to delete so instead
pass "-f" to avoid that.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2019-08-16 09:54:07 -07:00
dependabot-preview[bot]
7245cf7c5e build(deps): bump rust-argon2 from 0.5.0 to 0.5.1
Bumps [rust-argon2](https://github.com/sru-systems/rust-argon2) from 0.5.0 to 0.5.1.
- [Release notes](https://github.com/sru-systems/rust-argon2/releases)
- [Changelog](https://github.com/sru-systems/rust-argon2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sru-systems/rust-argon2/compare/0.5.0...0.5.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-16 07:49:03 +00:00