Commit Graph

8266 Commits

Author SHA1 Message Date
Songqian Li
ab12e7c294 vmm: fix cargo clippy error for rust 1.77
Since cloning Option<Arc<T>> will clone for Arc<T>, this patch fixes the
follow warning:

warning: this call to `as_ref.map(...)` does nothing
   --> vmm/src/lib.rs:872:13
    |
872 |             self.console_resize_pipe.as_ref().map(Arc::clone),
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `self.console_resize_pipe.clone()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_asref
    = note: `#[warn(clippy::useless_asref)]` on by default

Signed-off-by: Songqian Li <sionli@tencent.com>
2024-09-30 08:18:02 +00:00
Songqian Li
33c15ca273 vmm: remove pub use vm_config in config
This patch removes pub import vm_config in config.rs to eliminate
the ambiguity of vm_comfig reference.

Signed-off-by: Songqian Li <sionli@tencent.com>
2024-09-30 08:18:02 +00:00
Ruoqing He
61e57e1cb1 misc: Further improve imports styling
By introducing `imports_granularity="Module"` format strategy,
effectively groups imports from the same module into one line or block,
improving maintainability and readability.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2024-09-29 16:13:48 +00:00
Rob Bradford
9013d8b4ca build: Move cargo fmt check to nightly toolchain via new workflow
Enforcing group_imports="StdExternalCrate" requires using cargo fmt from
the nightly toolchain. Create a new workflow that runs on nightly to run
cargo fmt.

Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
2024-09-29 13:08:12 +01:00
Rob Bradford
f041c940a7 build: Apply cargo fmt check to fuzz workspace
Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
2024-09-29 13:08:12 +01:00
Rob Bradford
13cf7a1315 build: Make cargo fmt check apply to all packages
Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
2024-09-29 13:08:12 +01:00
Rob Bradford
88a9f79944 misc: Adapt consistent import style formatting
Historically the Cloud Hypervisor coding style has been to ensure that
all imports are ordered and placed in a single group. Unfortunately
cargo fmt has no support for ensuring that all imports are in a single
group so if whitespace lines were added as part of the import statements
then they would only be odered correctly in the group.

By adopting "group_imports="StdExternalCrate" we can enforce a style
where imports are placed in at most three groups for std, external
crates and the crate itself. Choosing a style enforceable by the tooling
reduces the reviewer burden.

Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
2024-09-29 13:08:12 +01:00
BharatNarasimman
6e4aefe66f vmm: Remove console resize for Serial
Serial device doesnt support resize semantics. Setting up the
console resize pipe in the Serial device setup path, overwrites
the setup done as part of virtio-console.

Signed-off-by: BharatNarasimman <bharatn@microsoft.com>
2024-09-28 15:25:08 +00:00
Songqian Li
cc9899e09d vmm: remove unused mutex in api
This patch removes locks in VmCreate request and VmInfo response
since we needn't use a lock here and should ensure that internal
implementation is transparent to the runtime.

Signed-off-by: Songqian Li <sionli@tencent.com>
2024-09-28 14:02:04 +00:00
Songqian Li
7eb70730d1 test_infra: panic when killing with SIGKILL
Killing process with SIGKILL will miss the information since CLH process
needs to end normally to export code coverage information.

Signed-off-by: Songqian Li <sionli@tencent.com>
2024-09-28 13:59:40 +00:00
Songqian Li
0a3ad6153a scripts: add cargo test args for code coverage reports
Add release and target params to `cargo test` since we collect
the code coverage reports from `xx/$BUILD_TARGET/release/`.

Signed-off-by: Songqian Li <sionli@tencent.com>
2024-09-28 13:59:40 +00:00
Songqian Li
9f02839448 scripts: add code coverage script
Fixes: #6507

Signed-off-by: Songqian Li <sionli@tencent.com>
2024-09-28 13:59:40 +00:00
dependabot[bot]
eabbeac9c0 build: Bump instant from 0.1.12 to 0.1.13
Bumps [instant](https://github.com/sebcrozet/instant) from 0.1.12 to 0.1.13.
- [Changelog](https://github.com/sebcrozet/instant/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sebcrozet/instant/commits)

---
updated-dependencies:
- dependency-name: instant
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-28 00:00:14 +00:00
Ruoqing He
f436231cba fuzz: Wrap params of FilePair with Arc
The construction of `FilePair` in `virtio_devices` component has changed
in 287887c, wrapping the parameters with `Arc` to fix fuzz build.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2024-09-27 15:58:21 +00:00
Ruoqing He
5a70d7ec69 build: Centralize rust-vmm crates to workspace
Modify `Cargo.toml` in each member crate to follow the dependencies
specified in root `Cargo.toml` file.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2024-09-27 15:58:21 +00:00
dependabot[bot]
ea4be45bb0 build: Bump parking from 2.2.0 to 2.2.1
Bumps [parking](https://github.com/smol-rs/parking) from 2.2.0 to 2.2.1.
- [Release notes](https://github.com/smol-rs/parking/releases)
- [Changelog](https://github.com/smol-rs/parking/blob/master/CHANGELOG.md)
- [Commits](https://github.com/smol-rs/parking/compare/v2.2.0...v2.2.1)

---
updated-dependencies:
- dependency-name: parking
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-27 00:37:05 +00:00
dependabot[bot]
3d73509338 build: Bump landlock from 0.4.0 to 0.4.1 in /fuzz
Bumps [landlock](https://github.com/landlock-lsm/rust-landlock) from 0.4.0 to 0.4.1.
- [Release notes](https://github.com/landlock-lsm/rust-landlock/releases)
- [Changelog](https://github.com/landlock-lsm/rust-landlock/blob/main/CHANGELOG.md)
- [Commits](https://github.com/landlock-lsm/rust-landlock/compare/v0.4.0...v0.4.1)

---
updated-dependencies:
- dependency-name: landlock
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-27 00:19:59 +00:00
BharatNarasimman
a0ae3ad1df vmm: Pass the newly created console resizer pipe during vm reboot
For a VM with virt-console enabled, when a reboot is requested, the
console devices are closed during the shutdown path. As part of this
the sigwinch listener process and the console resizer pipe are closed.
For the new incarnation of the VM, fresh set of console devices are
setup and a new console resizer pipe is created. The new VM should
be setup to use the newly created console devices including the console
resizer pipe.

Reading from the older console resizer pipe results in unexpected eof
error and terminates the cloud hypervisor process.

Signed-off-by: BharatNarasimman <bharatn@microsoft.com>
2024-09-26 20:06:53 +00:00
Rob Bradford
d90fa96bb7 build: Bulk update vm-memory and related dependencies
Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
2024-09-26 12:31:25 +00:00
dependabot[bot]
a9b30a4c4e build: Bump thiserror from 1.0.63 to 1.0.64 in /fuzz
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.63 to 1.0.64.
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.63...1.0.64)

---
updated-dependencies:
- dependency-name: thiserror
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-26 00:29:02 +00:00
dependabot[bot]
0f6cd3b030 build: Bump is_terminal_polyfill from 1.70.0 to 1.70.1
Bumps [is_terminal_polyfill](https://github.com/polyfill-rs/is_terminal_polyfill) from 1.70.0 to 1.70.1.
- [Changelog](https://github.com/polyfill-rs/is_terminal_polyfill/blob/main-v1.70/CHANGELOG.md)
- [Commits](https://github.com/polyfill-rs/is_terminal_polyfill/compare/v1.70.0...v1.70.1)

---
updated-dependencies:
- dependency-name: is_terminal_polyfill
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-26 00:04:47 +00:00
Alyssa Ross
287887c99c vmm: fix console IO safety
Rebooting a VM fails with the following error when debug assertions
are enabled:

	fatal runtime error: IO Safety violation: owned file descriptor already closed

This happens because FromRawFd::from_raw_fd is used on RawFds stored
in ConsoleInfo every time a VM begins to boot, so the second
time (after a reboot, or if the first attempt to boot via the API
failed), the fd will be closed.  Until this assertion is hit, the code
is operating on either closed file descriptors, or new file
descriptors for something completely different.  If debug assertions
are disabled, it will just continue doing this with unpredictable
results.

To fix this, and prevent the problem reocurring, ownership of the
console file descriptors needs to be properly tracked, using Rust's
type system, so this commit refactors the console code to do that.
The file descriptors are now passed around with reference counts, so
they won't be closed prematurely.  The obvious way to do this would be
to just have each member of ConsoleInfo be an Arc<File>, but we need
to accomodate that serial console file descriptors can also be
sockets.  We can't just store an OwnedFd and convert it when it's
used, because we only get a reference from the Arc, so we need to
store the descriptors as their concrete types in an enum.  Since this
basically duplicates the ConsoleOutputMode enum from the config, the
ConsoleOutputMode enum is now not used past constructing the
ConsoleInfo.

So that ownership can be represented consistently, the debug console's
tty mode now uses its own stdout descriptor.

I'm still using .try_clone().unwrap() (i.e. dup()) to clone file
descriptors for Endpoint::FilePair and Endpoint::TtyPair, because I
assume there's a reason for them not just to hold a single file
descriptor.

I've also retained the existing behaviour of having serial manager
ignore the tty file descriptor passed to it (which is stdout), and
instead using stdin.  It looks a lot weirder now, because it has to
explicitly indicate it's ignoring the fd with an underscore binding.

Fixes: 52eebaf6 ("vmm: refactor DeviceManager to use console_info")
Signed-off-by: Alyssa Ross <hi@alyssa.is>
2024-09-25 22:34:43 +00:00
Alyssa Ross
a5df86698b vmm: factor out stdout dup
Signed-off-by: Alyssa Ross <hi@alyssa.is>
2024-09-25 22:34:43 +00:00
Alyssa Ross
bc251fdf46 vmm: fix resizing TTY consoles
The assignment of console_resize_pipe in the TTY case seems to have
been accidentally deleted.  I've put it back, but since this is adding
code, I used the new safe API for checking whether a file is a
terminal, introduced in Rust 1.70.0.  We should probably use that
everywhere, but that's out of scope of this bug fix.

Fixes: 52eebaf6 ("vmm: refactor DeviceManager to use console_info")
Signed-off-by: Alyssa Ross <hi@alyssa.is>
2024-09-25 18:56:18 +00:00
Alyssa Ross
d1214acf2a vmm: remove unused DeviceManager::console method
Fixes: 38a1b457 ("vmm: use the SIGWINCH listener for TTYs too")
Signed-off-by: Alyssa Ross <hi@alyssa.is>
2024-09-25 18:55:42 +00:00
Alyssa Ross
938ff2eeb7 vmm: update serial manager epoll events size
I've moved this so that it's just after the enum definition, which
will hopefully make it less easy to miss if events are added/removed
again in future.

Fixes: 6d1077fc ("vmm: Unix socket backend for serial port")
Signed-off-by: Alyssa Ross <hi@alyssa.is>
2024-09-25 18:55:18 +00:00
Rob Bradford
e810be62cd virtio-devices: vhost_user: Remove unused backend support from virtio-fs
Complete the removal of the DAX support by removing the use of
non-standard messages. These messages have since been removed from the
vhost_user crate (rust-vmm/vhost#246) and so need to be removed from our
implementation since that would otherwise block updating to a newer
version of the crate.

The ability to enable DAX support in Cloud Hypervisor has been disabled
some time ago but this code was residual with no way to enable it.

Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
2024-09-25 19:41:35 +01:00
Nuno Das Neves
9f08aa6dc2 hypervisor: mshv: Update mshv crates to v0.3.0
And modify to code to use the updated interfaces.

Arguments for map_guest_memory, get_dirty_bitmap, vp.run(),
import_isolated_pages, modify_gpa_host_access have changed.
Update these to use the new interfaces, including new MSHV_*
definitions, and remove some redundant arguments.

Update seccomp IOCTLs to reflect interface changes.

Fix irq-related definitions naming.

Bump vfio-ioctls to support mshv v0.3.0.

Signed-off-by: Nuno Das Neves <nudasnev@microsoft.com>
2024-09-25 16:23:45 +00:00
dependabot[bot]
d9ee760f3b build: Bump proc-macro-crate from 3.1.0 to 3.2.0 in /fuzz
Bumps [proc-macro-crate](https://github.com/bkchr/proc-macro-crate) from 3.1.0 to 3.2.0.
- [Release notes](https://github.com/bkchr/proc-macro-crate/releases)
- [Commits](https://github.com/bkchr/proc-macro-crate/commits/v3.2.0)

---
updated-dependencies:
- dependency-name: proc-macro-crate
  dependency-type: indirect
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-25 00:18:44 +00:00
dependabot[bot]
9ca88047a8 build: Bump linux-loader from 0.11.0 to 0.12.0 in /fuzz
Bumps [linux-loader](https://github.com/rust-vmm/linux-loader) from 0.11.0 to 0.12.0.
- [Release notes](https://github.com/rust-vmm/linux-loader/releases)
- [Changelog](https://github.com/rust-vmm/linux-loader/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-vmm/linux-loader/compare/v0.11.0...v0.12.0)

---
updated-dependencies:
- dependency-name: linux-loader
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-24 00:30:53 +00:00
Bo Chen
88c0f268c2 ci: Remove the SGX worker
The SGX worker needs to be removed together with the retirement of the
underline bare-metal system.

Signed-off-by: Bo Chen <chen.bo@intel.com>
2024-09-23 23:11:57 +00:00
Ruoqing He
e8697735d1 hypervisor: cpu: Fix GetRegList comment
`GetRegList` variant will be referenced on both Aarch and RISC-V. Fixed
comment to generalize this error variant.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2024-09-23 12:06:25 +00:00
Ruoqing He
2668dbbd8b hypervisor: cpu: Expand Set/GetCoreRegisters variant
Since RISC-V has its own definition of `CoreRegister`, expand the Aarch
variant to avoid collision of `HypervisorCpuError`.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2024-09-23 12:06:25 +00:00
Ruoqing He
e9f137dc4a hypervisor: cpu: Fix get/set one reg error message
The error message of `SetRegister` and `GetRegister` fail to describe
the reason as the error variant suggests. Fixed error message
accordingly.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2024-09-23 12:06:25 +00:00
Bo Chen
be5fc769e9 tests: Relax rate limit check for group rate limiter
The rate-limiter worker now is running on Azure VMs whose performance
are more prone to be fluctuate, particularly on block performances. This
commit relaxes the limit check for group rate limiter tests to make them
less flaky.

Signed-off-by: Bo Chen <chen.bo@intel.com>
2024-09-21 08:13:32 +00:00
dependabot[bot]
faf11d7e9d build: Bump serde_json from 1.0.125 to 1.0.128 in /fuzz
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.125 to 1.0.128.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/1.0.125...1.0.128)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-21 00:07:24 +00:00
Rob Bradford
60165bbcfa pci: Fix #[cfg(target_arch)] guards for port I/O
Port I/O is only supported on x86_64 - use inverted conditional logic to
match the other architectures rather than calling them out specifically.
This will be relevant when RISC-V support is added.

Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
2024-09-20 16:17:43 +00:00
dependabot[bot]
990ba0666d build: Bump io-uring from 0.6.3 to 0.6.4
Bumps [io-uring](https://github.com/tokio-rs/io-uring) from 0.6.3 to 0.6.4.
- [Commits](https://github.com/tokio-rs/io-uring/commits)

---
updated-dependencies:
- dependency-name: io-uring
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-20 11:57:02 +00:00
Ruoqing He
4644f8a643 github: Remove redundant use-cross
The steps with predicates of `x86_64` targets would never turn on
`use-cross`, removing them from quality check.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2024-09-20 11:13:58 +01:00
Ruoqing He
4d45e89d24 github: Refactor quality matrix
Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2024-09-20 11:13:58 +01:00
dependabot[bot]
fe9626e07a build: Bump gdbstub_arch from 0.3.0 to 0.3.1 in /fuzz
Bumps [gdbstub_arch](https://github.com/daniel5151/gdbstub) from 0.3.0 to 0.3.1.
- [Release notes](https://github.com/daniel5151/gdbstub/releases)
- [Changelog](https://github.com/daniel5151/gdbstub/blob/master/CHANGELOG.md)
- [Commits](https://github.com/daniel5151/gdbstub/commits)

---
updated-dependencies:
- dependency-name: gdbstub_arch
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-20 00:37:10 +00:00
Yuhong Zhong
2ad8fac624 vmm: memory_manager: Fix bound checks for memory hotplug
Bound checks for virtio-mem and ACPI memory hotplug are off by
one and two, respectively. This prevents users to fully use the reserved
memory hotplug size.

For ACPI, if we specific `--memory size=2G,hotplug_size=4G` and run
`ch-remote resize --memory 6G`, cloud-hypervisor will report the
following error because of the incorrect bound check:

`<vmm> ERROR:vmm/src/lib.rs:1631 -- Error when resizing VM:
MemoryManager(InsufficientHotplugRam)`

Similarly, for virtio-mem, cloud-hypervisor will fail the incorrect
bound check and abort the resize. The VM will see the following error
in dmesg:

`virtio_mem virtio3: unknown error, marking device broken: -22`

This patch has fixed both bound checks and ensure that users can
hot add memory up to the reserved hotplug size.

Signed-off-by: Yuhong Zhong <yz@cs.columbia.edu>
2024-09-19 18:02:20 +00:00
dependabot[bot]
1103d531b7 build: Bump syn from 2.0.72 to 2.0.77 in /fuzz
Bumps [syn](https://github.com/dtolnay/syn) from 2.0.72 to 2.0.77.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/2.0.72...2.0.77)

---
updated-dependencies:
- dependency-name: syn
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-19 00:32:45 +00:00
Bo Chen
0277974a36 build: Fix cargo fuzz build
This reverts commit aba5fa8846.

Signed-off-by: Bo Chen <chen.bo@intel.com>
2024-09-18 09:57:06 -07:00
Bo Chen
cbc940d2e2 ci: Move metrics and rate-limiter workers
Since the underline bare-metal system is going to retire, we are moving
the metrics and rate-limiter workers to use Azure VMs.

Signed-off-by: Bo Chen <chen.bo@intel.com>
2024-09-18 09:06:05 +00:00
dependabot[bot]
aba5fa8846 build: Bump virtio-queue from 0.12.0 to 0.13.0 in /fuzz
Bumps [virtio-queue](https://github.com/rust-vmm/vm-virtio) from 0.12.0 to 0.13.0.
- [Release notes](https://github.com/rust-vmm/vm-virtio/releases)
- [Commits](https://github.com/rust-vmm/vm-virtio/compare/virtio-queue-v0.12.0...virtio-queue-v0.13.0)

---
updated-dependencies:
- dependency-name: virtio-queue
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-18 00:07:33 +00:00
dependabot[bot]
a87be264c8 build: Bump unicode-ident from 1.0.12 to 1.0.13 in /fuzz
Bumps [unicode-ident](https://github.com/dtolnay/unicode-ident) from 1.0.12 to 1.0.13.
- [Release notes](https://github.com/dtolnay/unicode-ident/releases)
- [Commits](https://github.com/dtolnay/unicode-ident/compare/1.0.12...1.0.13)

---
updated-dependencies:
- dependency-name: unicode-ident
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-17 14:07:03 +00:00
Alyssa Ross
4ad44caa52 api_client: show response body in ServerResponse
Otherwise, you just see output like "Error running command: Server
responded with an error: InternalServerError", which isn't very
helpful.  The response body used to be include with the message, but
was removed when the Error enum was converted to thiserror.

Fixes: 5d0d56f5 ("api_client: Use thiserror for errors")
Signed-off-by: Alyssa Ross <hi@alyssa.is>
2024-09-13 08:29:37 +00:00
dependabot[bot]
9f53553860 build: Bump quote from 1.0.36 to 1.0.37 in /fuzz
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.36 to 1.0.37.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.36...1.0.37)

---
updated-dependencies:
- dependency-name: quote
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-11 08:41:30 +00:00
Purna Pavan Chandra
d10f6ca714 virtio-devices: Fix seccomp rules for SevSnp
With cd0cdac ("virtio-devices: Fix seccomp rules for SevSnp guest"), the
sys_ioctl rule that was applied in virtio_thread_common, would override
previously specified sys_ioctl rules for individual thread type. This
causes the SevSnp guest to crash with seccomp violation.

Fixes: cd0cdac ("virtio-devices: Fix seccomp rules for SevSnp guest")
Signed-off-by: Purna Pavan Chandra <paekkaladevi@microsoft.com>
2024-09-11 08:41:17 +00:00