Commit Graph

3342 Commits

Author SHA1 Message Date
Rob Bradford
24922ce1e3 tests: Move integration tests to vmm_sys_util::tempdir::TempDir
This removes the dependency on "tempdir" which in turn depends on the
large rand dependency chain.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-23 11:07:48 +00:00
Rob Bradford
c1be41bfbf net_util: Replace use of rand crate with libc::getrandom()
The rand crate provides a full cross platform true cryptographic random
number implementation. As such it brings it lots of othe dependencies
and increases our binary size and compile time. This is excessive for
generating a MAC address.

From the cargo tree output:

│   │   ├── rand v0.8.3
│   │   │   ├── libc v0.2.86
│   │   │   ├── rand_chacha v0.3.0
│   │   │   │   ├── ppv-lite86 v0.2.10
│   │   │   │   └── rand_core v0.6.0
│   │   │   │       └── getrandom v0.2.0
│   │   │   │           ├── cfg-if v0.1.10
│   │   │   │           └── libc v0.2.86
│   │   │   └── rand_core v0.6.0 (*)

And cargo bloat:

 0.0%   0.4% 40.4KiB rand_chacha rand_chacha::guts::refill_wide::impl_sse2
 0.0%   0.4% 40.0KiB rand_chacha rand_chacha::guts::refill_wide::impl_ssse3
 0.0%   0.3% 37.6KiB rand_chacha rand_chacha::guts::refill_wide::impl_avx
 0.0%   0.3% 37.2KiB rand_chacha rand_chacha::guts::refill_wide::impl_sse41
 0.0%   0.2% 26.1KiB rand_chacha rand_chacha::guts::refill_wide::impl_avx2

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-23 11:07:48 +00:00
Bo Chen
d361fc1a36 vmm: config: Fix and complete the help info for the '--disk' option
The help information displayed for our `--disk` option is incorrect and
incomplete, e.g. missing the `direct` and `poll_queue` field.

Signed-off-by: Bo Chen <chen.bo@intel.com>
2021-02-23 08:55:33 +01:00
Wei Liu
49214cf02b hypervisor: emulator: fix MOVZX
According to Intel's mnemonic (which is used by iced-x86) the first
argument is destination while the second is source.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
2021-02-23 07:42:33 +01:00
Rob Bradford
d78b2ec8b5 tests: Use vmm_sys_util::tempfile::Tempfile in integration tests
This removes the requirement for an extra crate and simplifies the
dependency chain.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-22 14:29:53 +01:00
Rob Bradford
946c484590 devices: Remove dependency on tempfile crate
This was completely unused.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-22 14:29:53 +01:00
Rob Bradford
cd700bf449 virtio-devices: Remove dependency on tempfile crate
This was completely unused.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-22 14:29:53 +01:00
Rob Bradford
cf7a05ecb5 block_util: Use vmm_sys_util::tempfile::Tempfile
This removes the requirement for an extra crate.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-22 14:29:53 +01:00
Rob Bradford
0497a7c311 qcow: Use vmm_sys_util::tempfile::Tempfile
This removes the requirement for an extra crate.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-22 14:29:53 +01:00
Rob Bradford
05a2b3fac2 vmm: Remove "tempfile" dependency from vmm
This was completely unused.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-22 14:29:53 +01:00
dependabot-preview[bot]
d33c0563af build(deps): bump once_cell from 1.5.2 to 1.6.0
Bumps [once_cell](https://github.com/matklad/once_cell) from 1.5.2 to 1.6.0.
- [Release notes](https://github.com/matklad/once_cell/releases)
- [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md)
- [Commits](https://github.com/matklad/once_cell/compare/v1.5.2...v1.6.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-22 13:28:54 +00:00
Sebastien Boeuf
4ed0e1a3c8 net_util: Simplify TX/RX queue handling
The main idea behind this commit is to remove all the complexity
associated with TX/RX handling for virtio-net. By using writev() and
readv() syscalls, we could get rid of intermediate buffers for both
queues.

The complexity regarding the TAP registration has been simplified as
well. The RX queue is only processed when some data are ready to be
read from TAP. The event related to the RX queue getting more
descriptors only serves the purpose to register the TAP file if it's not
already.

With all these simplifications, the code is more readable but more
performant as well. We can see an improvement of 10% for a single
queue device.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-02-22 10:39:23 +00:00
dependabot-preview[bot]
5ed2a654e8 build(deps): bump generator from 0.6.23 to 0.6.24
Bumps [generator](https://github.com/Xudong-Huang/generator-rs) from 0.6.23 to 0.6.24.
- [Release notes](https://github.com/Xudong-Huang/generator-rs/releases)
- [Commits](https://github.com/Xudong-Huang/generator-rs/compare/0.6.23...0.6.24)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-22 06:30:32 +00:00
dependabot-preview[bot]
ae04fe432c build(deps): bump signal-hook from 0.3.4 to 0.3.6
Bumps [signal-hook](https://github.com/vorner/signal-hook) from 0.3.4 to 0.3.6.
- [Release notes](https://github.com/vorner/signal-hook/releases)
- [Changelog](https://github.com/vorner/signal-hook/blob/master/CHANGELOG.md)
- [Commits](https://github.com/vorner/signal-hook/compare/v0.3.4...v0.3.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-21 09:36:30 +00:00
dependabot-preview[bot]
c8d142eb55 build(deps): bump crossbeam-utils from 0.8.1 to 0.8.2
Bumps [crossbeam-utils](https://github.com/crossbeam-rs/crossbeam) from 0.8.1 to 0.8.2.
- [Release notes](https://github.com/crossbeam-rs/crossbeam/releases)
- [Changelog](https://github.com/crossbeam-rs/crossbeam/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crossbeam-rs/crossbeam/compare/crossbeam-utils-0.8.1...crossbeam-utils-0.8.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-21 09:36:12 +00:00
dependabot-preview[bot]
8533d63514 build(deps): bump cc from 1.0.66 to 1.0.67
Bumps [cc](https://github.com/alexcrichton/cc-rs) from 1.0.66 to 1.0.67.
- [Release notes](https://github.com/alexcrichton/cc-rs/releases)
- [Commits](https://github.com/alexcrichton/cc-rs/compare/1.0.66...1.0.67)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-19 22:54:50 +00:00
Muminul Islam
0ef69fa592 tests: Use constant instead of static value for windows image name
Signed-off-by: Muminul Islam <muislam@microsoft.com>
2021-02-19 10:09:23 +00:00
Muminul Islam
29f924405a scripts: Check if windows image is in the host
Currently script does not exit early if the image/firmware not present
in the host. We should not progress further if the images are not pre
downloaded.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2021-02-19 10:09:23 +00:00
Muminul Islam
282134a490 scripts: Use variable for with windows image file
Signed-off-by: Muminul Islam <muislam@microsoft.com>
2021-02-19 10:09:23 +00:00
dependabot-preview[bot]
1fbdca16bf build(deps): bump form_urlencoded from 1.0.0 to 1.0.1
Bumps [form_urlencoded](https://github.com/servo/rust-url) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/servo/rust-url/releases)
- [Commits](https://github.com/servo/rust-url/compare/v1.0.0...percent-encoding-v1.0.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-19 09:53:49 +00:00
Rob Bradford
32a2000ecc build: Only build the {kvm,mshv}-{ioctls,bindings} needed
This simplifies the Cloud Hypervisor dependency chain slightly.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-19 08:27:30 +01:00
dependabot-preview[bot]
6a499f02d9 build(deps): bump linux-loader from 2855be1 to 4ab9dad
Bumps [linux-loader](https://github.com/rust-vmm/linux-loader) from `2855be1` to `4ab9dad`.
- [Release notes](https://github.com/rust-vmm/linux-loader/releases)
- [Commits](2855be15a7...4ab9dade2c)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-19 07:14:55 +00:00
dependabot-preview[bot]
0a9c052ebd build(deps): bump thiserror from 1.0.23 to 1.0.24
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.23 to 1.0.24.
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.23...1.0.24)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-19 07:14:39 +00:00
dependabot-preview[bot]
bfb12b7777 build(deps): bump url from 2.2.0 to 2.2.1
Bumps [url](https://github.com/servo/rust-url) from 2.2.0 to 2.2.1.
- [Release notes](https://github.com/servo/rust-url/releases)
- [Commits](https://github.com/servo/rust-url/compare/v2.2.0...v2.2.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-18 21:56:54 +00:00
Rob Bradford
c89095ab85 virtio-devices: Report events for virtio device activation and reset
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-18 16:15:13 +00:00
Rob Bradford
9260c4c10e vmm: Use event!() for some key VM actions
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-18 16:15:13 +00:00
Rob Bradford
4822ed79e1 main: Add "--monitor-fd" to write structured event data to
If supplied then structured JSON event data will be written to that file
descriptor.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-18 16:15:13 +00:00
Rob Bradford
ddbef7450d event_monitor: Add new crate for event reporting
This crate exposes the abililty for the VMM to set a file that events
should be written to. The event!() macro provides an interface to report
those events allowing the specification of an event source, an event
type and optional extra data. This will be written to the provided file
descriptor as JSON data.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-18 16:15:13 +00:00
Rob Bradford
c1d9edbfc0 vmm: seccomp: Add getrandom to vCPU thread filter
This can be triggered upon device reset.

Fixes: #2278

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-18 16:15:13 +00:00
dependabot-preview[bot]
0d209e135e build(deps): bump idna from 0.2.1 to 0.2.2
Bumps [idna](https://github.com/servo/rust-url) from 0.2.1 to 0.2.2.
- [Release notes](https://github.com/servo/rust-url/releases)
- [Commits](https://github.com/servo/rust-url/compare/v0.2.1...idna-v0.2.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-18 09:26:35 +00:00
Wei Liu
e22b6ec768 hypervisor: x86: emulate MOVS instruction
Signed-off-by: Wei Liu <liuwe@microsoft.com>
2021-02-17 09:36:19 +01:00
Wei Liu
b59243f6cf hypervisor: mshv: support reading and writing guest memory in emulator
We don't have an easy way to figure out if a GPA points to normal memory
or device memory, but the guest's normal memory regions shouldn't
overlap with device regions. We can simply try to do a normal memory
read / write, and proceed to do device memory read / write if that
fails.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
2021-02-17 09:36:19 +01:00
Rob Bradford
07a09eda27 hypervisor: kvm: Remove whitespace from use statements
This allows cargo fmt to correctly order the statements.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-16 18:38:57 +01:00
Rob Bradford
38c41a5074 vmm: memory_manager: Extract code for allocating new memory
This function can then be used by the TDX code to allocate the memory at
specific locations required for the TDVF to run from.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-16 18:38:57 +01:00
Rob Bradford
6e4c90f305 arch: Include "thiserror" crate as well as "anyhow"
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-16 18:38:57 +01:00
Rob Bradford
707bb0ba72 vmm: Simplify return path of vm_boot
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-16 18:38:57 +01:00
Wei Liu
29881a2d6a hypervisor: mshv: explicitly skip a few IO ports
OVMF would use string IO on those ports. String IO has not been
implemented, so that leads to panics.

Skip them explicitly in MSHV. Leave a long-ish comment in code to
explain the situation. We should properly implement string IO once it
becomes feasible / necessary.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
2021-02-16 10:04:58 +01:00
Rob Bradford
a330a1569a arch, arch_gen, hypervisor: Remove some unnecessary clippy attributes
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-15 18:03:27 +01:00
Wei Liu
cf6480f012 hypervisor: mshv: drop some clippy attributes
They were used to suppress warnings during development. At this stage
they aren't needed anymore.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
2021-02-15 14:52:26 +01:00
Bo Chen
a838d0bde1 scripts, tests: Rustify the network setup commands for tests
Fixes: #2218

Signed-off-by: Bo Chen <chen.bo@intel.com>
2021-02-15 08:34:23 +00:00
Rob Bradford
f58b6f8417 build, release-notes.md, rpm: Release 0.13.0
Update version numbers and release notes for new release.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-12 10:38:48 +00:00
dependabot-preview[bot]
71ae9cfe06 build(deps): bump quote from 1.0.8 to 1.0.9
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.8 to 1.0.9.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.8...1.0.9)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-12 08:16:19 +00:00
dependabot-preview[bot]
f0b7a09a49 build(deps): bump env_logger from 0.8.2 to 0.8.3
Bumps [env_logger](https://github.com/env-logger-rs/env_logger) from 0.8.2 to 0.8.3.
- [Release notes](https://github.com/env-logger-rs/env_logger/releases)
- [Changelog](https://github.com/env-logger-rs/env_logger/blob/master/CHANGELOG.md)
- [Commits](https://github.com/env-logger-rs/env_logger/compare/v0.8.2...v0.8.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-12 08:15:55 +00:00
Rob Bradford
bc84a1c79b build: Remove nested matches
Update for clippy in Rust 1.50.0:

error: Unnecessary nested match
   --> vmm/src/vm.rs:419:17
    |
419 | /                 if let vm_device::BusError::MissingAddressRange = e {
420 | |                     warn!("Guest MMIO write to unregistered address 0x{:x}", gpa);
421 | |                 }
    | |_________________^
    |
    = note: `-D clippy::collapsible-match` implied by `-D warnings`
help: The outer pattern can be modified to include the inner pattern.
   --> vmm/src/vm.rs:418:17
    |
418 |             Err(e) => {
    |                 ^ Replace this binding
419 |                 if let vm_device::BusError::MissingAddressRange = e {
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ with this pattern
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-11 18:18:44 +00:00
Rob Bradford
9c5be6f660 build: Remove unnecessary Result<> returns
If the function can never return an error this is now a clippy failure:

error: this function's return value is unnecessarily wrapped by `Result`
   --> virtio-devices/src/watchdog.rs:215:5
    |
215 | /     fn set_state(&mut self, state: &WatchdogState) -> io::Result<()> {
216 | |         self.common.avail_features = state.avail_features;
217 | |         self.common.acked_features = state.acked_features;
218 | |         // When restoring enable the watchdog if it was previously enabled. We reset the timer
...   |
223 | |         Ok(())
224 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_wraps

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-11 18:18:44 +00:00
Rob Bradford
8e9a5a0dbb vm-migration: Use vm-memory's ByteValued instead of own AsBytes
This addresses a newly added clippy issue:

error: methods called `as_*` usually take self by reference or self by mutable reference; consider choosing a less ambiguous name
  --> vm-migration/src/protocol.rs:57:34
   |
57 |     fn as_mut_bytes<T: Sized>(p: &mut T) -> &mut [u8] {
   |                                  ^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention

error: aborting due to 2 previous errors

error: could not compile `vm-migration`

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-11 18:18:44 +00:00
Bo Chen
d561b45552 tests: Add integration test test_macvtap
This integration test mimics the instructions from
`docs/macvtap-bridge.md`.

Fixes: #2215

Signed-off-by: Bo Chen <chen.bo@intel.com>
2021-02-11 15:25:32 +00:00
Sebastien Boeuf
9353856426 vmm: Fix seccomp filters for vCPUs
Depending on the host OS the code for looking up the time for the CMOS
make require extra syscalls to be permitted for the vCPU thread.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-11 11:24:57 +00:00
Sebastien Boeuf
9af477e964 pci: vfio: Check VFIO device interrupt's support
In case the VFIO device does not support MSI or MSI-X, the capabilities
should not be parsed, avoiding the exposure of unsupported capabilities.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-02-10 17:34:56 +00:00
Sebastien Boeuf
27515a6ec4 pci: vfio: Propagate errors when enabling interrupts
Make sure to propagate the error coming from VfioDevice when trying to
enable INTx, MSI or MSI-X interrutps.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-02-10 17:34:56 +00:00