Commit graph

8796 commits

Author SHA1 Message Date
Wei Liu
f6568042ce tests: Fix an error message in VHDX expansion test
The VHDX image is generated directly, not converted from a RAW image.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
2025-07-24 01:06:12 +00:00
Oliver Anderson
2ae5b2567b tpm: Use the same libc crate version as other workspace members
The other workspace members in the Cloud-hypervisor workspace
currently declare libc crate version 0.2.167, but the tpm crate
has an older version. This inconsistency is addressed by this PR
which opens the door for declaring libc as a workspace dependency.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
2025-07-24 01:05:08 +00:00
Oliver Anderson
6d70c570f3 tpm: Use the same anyhow version as other workspace members
The other workspace members in the Cloud-hypervisor workspace
currently declare anyhow version 1.0.94, but the tpm crate
has an older version. This inconsistency is addressed by this PR
which opens the door for declaring anyhow as a workspace dependency.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
2025-07-23 16:29:34 +00:00
Wei Liu
930a911862 block: Simplify AsyncAdaptor
It shouldn't be necessary to lock the file for the adaptor. This removes
two layers of indirection for QcowDiskSync and VhdxDiskSync.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
2025-07-22 22:00:35 +00:00
Bo Chen
03b22a510d tests: Disable 'test_virtio_block_dynamic_vhdx_expand'
This issue is tracked via #7209.

Signed-off-by: Bo Chen <bchen@crusoe.ai>
2025-07-22 21:06:54 +00:00
Bo Chen
62001b65e9 build: Release v47.0
Signed-off-by: Bo Chen <bchen@crusoe.ai>
2025-07-22 21:06:54 +00:00
Wei Liu
4be2ca4c10 vhost_user_net: Use Mutex::get_mut() where possible
Signed-off-by: Wei Liu <liuwe@microsoft.com>
2025-07-17 19:20:59 +00:00
Wei Liu
5716af09a5 vhost_user_block: Use Mutex::get_mut() where possible
Signed-off-by: Wei Liu <liuwe@microsoft.com>
2025-07-17 19:20:59 +00:00
Wei Liu
4ea40b4bea rate_limiter: Use Mutex::get_mut() in update_buckets
There is no need to lock. That function already holds a mutable
reference to self.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
2025-07-17 19:20:59 +00:00
Jean-Philippe Brucker
4528e2f1ea devices: rtc_pl031: Disable broken interrupt
The PL031 RTC provides two features: a real-time counter and an alarm
interrupt. To use the alarm, the driver normally writes a time value
into the match register RTCMR, and when the counter reaches that value
the device triggers the interrupt.

At the moment the implementation ignores programming of the alarm, as
the feature seems rarely used in VMs. However the interrupt is still
triggered arbitrarily when the guest writes to registers, and the line
is never cleared. This really confuses the Linux driver, which loops in
the interrupt handler until Linux realizes that no one is dealing with
the interrupt (200000 unanswered calls) and disables the handler.

One way to fix this would be implementing the alarm function properly,
which isn't too difficult but requires adding some async timer logic
which probably won't ever get used. In addition the device's interrupt
is level-triggered and we don't support level interrupts at the moment,
though we could probably get away with changing this interrupt to edge.

The simplest fix, though, is to just disable the interrupt logic
entirely, so that the alarm function still doesn't work but the guest
doesn't see spurious interrupts.

Add a default() implementation to satisfy clippy's new_without_default
check, since Rtc::new() doesn't take a parameter after this change.

Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
2025-07-17 17:21:05 +00:00
Bo Chen
987ad11c90 main: Report errors with 'error!()'
This was missed from #7183, likely because `eprint!` is used instead of
`eprintln!`.

Signed-off-by: Bo Chen <bchen@crusoe.ai>
2025-07-17 16:18:56 +00:00
Wei Liu
cea708deb9 performance-metrics: Fix the names of the kernels
In 2b05753716, the names of the reference kernels are changed.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
2025-07-16 20:20:32 +00:00
Songqian Li
e32fa593e5 build: clean up unused dependencies
Signed-off-by: Songqian Li <sionli@tencent.com>
2025-07-15 07:16:36 +00:00
Alyssa Ross
ec8fceb4a6 virtio-devices: stop corrupting vsock commands
The read_exact() call was introduced in 82ac114b8 ("virtio-devices:
vsock: handle short read in muxer") to solve a crash when a connection
disconnected without sending any data, but it introduced a problem of
its own: because the socket is non-blocking, read_exact() may read
some data, then return ErrorKind::WouldBlock.  In that case, the data
it read will be discarded.  So for example if it read "CONNECT ",
and then nothing else was available to read yet, "CONNECT " would be
discarded, and so the next time this function was called, when epoll
triggered again for the socket, only the following data would end up
in command.buf, causing an error due to just a port number being an
invalid command.

Contrary to that commit message, this code was actually designed to
handle short reads just fine — in the case of a short read, it stores
the data it has read in command, and returns
Error::UnixRead(ErrorKind::WouldBlock), which is ignored by the
caller, and the function gets called again when there is more data to
read, building up command potentially over the course of several
reads.  The only thing it didn't handle correctly, as far as I can
tell, was a 0-byte read, which happens when a client disconnects from
the socket without writing anything.  All that's needed to fix this is
to avoid an invalid subtraction in that case, so this change reverts
82ac114b8, fixing the issue with partial commands being discarded, and
instead handles the 0-byte read by using slice::get, and treating an
empty command as an incomplete command, which of course it is.

Fixes: 82ac114b8 ("virtio-devices: vsock: handle short read in muxer")
Signed-off-by: Alyssa Ross <hi@alyssa.is>
2025-07-14 18:07:07 +00:00
Alyssa Ross
01aed9733c build: add missing dependency features
This makes it possible to run cargo test just for the virtio-devices
crate (as long as either KVM or MSHV is specified).

Signed-off-by: Alyssa Ross <hi@alyssa.is>
2025-07-14 18:06:54 +00:00
Nuno Das Neves
a5cd1b4fbe build: Bump mshv-ioctls and mshv-bindings to v0.5.2
Also update the version in the fuzz crate.

Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
2025-07-12 01:17:26 +00:00
Muminul Islam
b268e88ba3 virtio-devices: remove unnecessary parentheses
Cargo fuzz build report an warning:

warning: unnecessary parentheses around closure body
--> virtio-devices/src/iommu.rs:578:41
|
578 |.retain(|&x, _| (x < req.virt_start || x > req.virt_end));
|                                         ^
|
= note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
|
578 -.retain(|&x, _| (x < req.virt_start || x > req.virt_end));
578 +.retain(|&x, _| x < req.virt_start || x > req.virt_end);
|

warning: `virtio-devices` (lib) generated 1 warning
(run `cargo fix --lib -p virtio-devices` to apply 1 suggestion)

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2025-07-11 22:02:15 +00:00
dependabot[bot]
0659eaeba1 build: Bump async-signal from 0.2.10 to 0.2.11
Bumps [async-signal](https://github.com/smol-rs/async-signal) from 0.2.10 to 0.2.11.
- [Release notes](https://github.com/smol-rs/async-signal/releases)
- [Changelog](https://github.com/smol-rs/async-signal/blob/master/CHANGELOG.md)
- [Commits](https://github.com/smol-rs/async-signal/compare/v0.2.10...v0.2.11)

---
updated-dependencies:
- dependency-name: async-signal
  dependency-version: 0.2.11
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-11 00:38:49 +00:00
Bo Chen
96528f84f9 build: Bump gdbstub from 0.7.1 to 0.7.6
Bumps [gdbstub](https://github.com/daniel5151/gdbstub) from 0.7.1 to 0.7.6.
- [Release notes](https://github.com/daniel5151/gdbstub/releases)
- [Changelog](https://github.com/daniel5151/gdbstub/blob/master/CHANGELOG.md)
- [Commits](https://github.com/daniel5151/gdbstub/compare/0.7.1...0.7.6)

---
updated-dependencies:
- dependency-name: gdbstub
  dependency-version: 0.7.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Bo Chen <bchen@crusoe.ai>
2025-07-10 19:46:28 +00:00
Ruoqing He
6da5c32fd9 hypervisor: aarch64: Use offset_of for nested fields
`std::mem::offset_of` could be used for calculating nested fields, use
this feature to shorten aarch64 reg offset calculation.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-07-10 16:39:39 +00:00
Ruoqing He
07cc1f6545 hypervisor: aarch64: Remove manually implemented offset_of
Manually implemented `offset_of` in `arch/aarch64/mod.rs` is not used
now, remove it.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-07-10 16:39:39 +00:00
Ruoqing He
008f259aff hypervisor: aarch64: Use offset_of from std::mem
`std::mem::offset_of` is stabilized since Rust 1.77, let's use
implementation provided by std instead of manual implementation.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-07-10 16:39:39 +00:00
Ruoqing He
aa6fefa80f hypervisor: riscv64: Remove manually implemented offset_of
Manually implemented `_offset_of` and `offset_of` in
`arch/riscv64/mod.rs` are not used now, remove them.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-07-10 16:39:39 +00:00
Ruoqing He
87e74719ec hypervisor: riscv64: Use offset_of from std::mem
`std::mem::offset_of` supports calculating offset of nested structures,
let's use implementation provided by std instead of manual
implementation.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-07-10 16:39:39 +00:00
Maximilian Güntner
072f06ff4c misc: vhost_user_net: replace eprintln with log::error
Other lines are already logged using `log::error!` and
`env_logger` is initialized before calling
`start_net_backend` in `main()`.

Signed-off-by: Maximilian Güntner <code@mguentner.de>
2025-07-10 16:36:54 +00:00
Maximilian Güntner
50b33db718 vmm: replace eprintln with log::error
Unify log formatting and printing as `eprintln!` and `log::error!`
would be used alongside each other.
When using e.g. `env_logger` lines printed with `eprintln!` would
lack formatting / colors.
Currently only relevant in `ch-remote` + `cli_print_error_chain`.

Note that the replaced messages now also end up in the logfile of
`cloud-hypervisor` when configured and not any longer in stderr.

Signed-off-by: Maximilian Güntner <code@mguentner.de>
2025-07-10 16:36:54 +00:00
Maximilian Güntner
19dc733267 ch-remote: add env_logger, log messages to stderr
Until now all messages generated using `log::level!`
(e.g., `warn!`) have not been printed as `ch-remote` did not
register a logger.
Furthermore, replace all `eprintln!` with `error!`
to align formatting for consistency.

Signed-off-by: Maximilian Güntner <code@mguentner.de>
2025-07-10 16:36:54 +00:00
Maximilian Güntner
6ba949d741 build: consolidate env_logger to workspace, update to 0.11.8
Signed-off-by: Maximilian Güntner <code@mguentner.de>
2025-07-10 16:36:54 +00:00
Philipp Schuster
9d4408ba76 vmm: add directory path to error message
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
2025-07-10 16:24:50 +00:00
Maximilian Güntner
f9c134471a vmm: warn about deprecation of default IP address + mask
Issue: #7083

Signed-off-by: Maximilian Güntner <code@mguentner.de>
2025-07-08 19:05:45 +00:00
ninollei
3d5b4d0b0c vmm: acpi: Use correct table name in error message
Fix a copy-paste error using the wrong table name in the assertion

Signed-off-by: ninollei <ninollx@hotmail.com>
2025-07-08 09:02:40 +00:00
dependabot[bot]
ea32b67098 build: Bump proc-macro-crate from 3.2.0 to 3.3.0
Bumps [proc-macro-crate](https://github.com/bkchr/proc-macro-crate) from 3.2.0 to 3.3.0.
- [Release notes](https://github.com/bkchr/proc-macro-crate/releases)
- [Commits](https://github.com/bkchr/proc-macro-crate/compare/v3.2.0...v3.3.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-07 17:23:51 +00:00
Jinank Jain
190d90196f build: Bump vfio and all the dependent crates to latest version
Recently vfio crates have moved to crates.io, thus we should start
consuming the crate from crates.io instead git url.

This results in better versioning instead of tracking some git commit
sha.

Signed-off-by: Jinank Jain <jinankjain@microsoft.com>
2025-07-07 03:05:38 +00:00
Jinank Jain
fe422a45af build: Move away from actions-rs/cross
Since action-rs/cross is deprecrated, thus move to
houseabsolute/actions-rust-cross.

We should pin the cross-version to the latest version to fix the build
issues with virtio-bindings crate.

Signed-off-by: Jinank Jain <jinankjain@microsoft.com>
2025-07-07 03:05:38 +00:00
Wei Liu
da5fae3814 docs: Fix the chown command in macvtap-bridge.md
When invoking the script chown shows a warning.

    chown: warning: '.' should be ':': ‘1000.1000’

From `info coreutils 'chown invocation'`.

   Some older scripts may still use ‘.’ in place of the ‘:’ separator.
POSIX 1003.1-2001 (*note Standards conformance::) does not require
support for that, but for backward compatibility GNU ‘chown’ supports
‘.’ so long as no ambiguity results, although it issues a warning and
support may be removed in future versions.  New scripts should avoid the
use of ‘.’ because it is not portable, and because it has undesirable
results if the entire OWNER‘.’GROUP happens to identify a user whose
name contains ‘.’.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
2025-07-01 15:12:03 +00:00
dependabot[bot]
8a78043e2f build: Bump crate-ci/typos from 1.33.1 to 1.34.0
Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.33.1 to 1.34.0.
- [Release notes](https://github.com/crate-ci/typos/releases)
- [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crate-ci/typos/compare/v1.33.1...v1.34.0)

---
updated-dependencies:
- dependency-name: crate-ci/typos
  dependency-version: 1.34.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-01 02:50:46 +00:00
Wei Liu
fdeb778210 block: Add back UUID crate's v4 feature
That feature was dropped when consolidating the UUID dependency because
somehow building the whole project worked. The CI system was happy.

However, building the block crate alone is broken. The vhdx code uses
Uuid::new_v4, which requires `v4` to be enabled.

Add the feature back.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
2025-06-30 10:54:54 +00:00
dependabot[bot]
13c222a879 build: Bump proc-macro2 from 1.0.93 to 1.0.95
Bumps [proc-macro2](https://github.com/dtolnay/proc-macro2) from 1.0.93 to 1.0.95.
- [Release notes](https://github.com/dtolnay/proc-macro2/releases)
- [Commits](https://github.com/dtolnay/proc-macro2/compare/1.0.93...1.0.95)

---
updated-dependencies:
- dependency-name: proc-macro2
  dependency-version: 1.0.95
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-28 00:18:30 +00:00
dependabot[bot]
b27d9ccfab build: Bump rustix from 0.38.34 to 0.38.44
Bumps [rustix](https://github.com/bytecodealliance/rustix) from 0.38.34 to 0.38.44.
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Changelog](https://github.com/bytecodealliance/rustix/blob/main/CHANGES.md)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.34...v0.38.44)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-26 23:56:47 +00:00
Philipp Schuster
d580ed55c6 seccomp: add SYS_getcwd (79) to support proper Rust backtraces
When a proper Rust backtrace is printed, the Rust std wants to use the
SYS_getcwd(79) system call to prettify some paths while printing. In
Cloud Hypervisor, this is at least relevant for printing panics or if
a `anyhow::Error` value is printed using `{e:?}` (but not `{e:#?}`).

The syscall cause can be found in `impl fmt::Display for Backtrace {}`
in `library/std/src/backtrace.rs`.

Without this addition, the seccomp violation of the SYS_getcwd (79)
hinders the proper error message including a full backtrace from showing
up. This annoying behaviour already delayed many debugging efforts. With
this fix, things just work. The new syscall itself should be pretty
harmless for normal operation.

```
thread 'vmm' panicked at virtio-devices/src/rng.rs:224:9:
Yikes, things went horribly wrong!

==== Possible seccomp violation ====
Try running with `strace -ff` to identify the cause and open an issue: https://github.com/cloud-hypervisor/cloud-hypervisor/issues/new
[1]    287683 invalid system call (core dumped)  RUST_BACKTRACE=full cargo run --bin cloud-hypervisor -- --api-socket  --kerne
```

```
thread 'vmm' panicked at virtio-devices/src/rng.rs:224:9:
Yikes, things went horribly wrong!
stack backtrace:
   0:     0x557d91286b62 - std::backtrace_rs::backtrace::libunwind::trace::hc20b48b31ee52608
                               at /rustc/17067e9ac6d7ecb70e50f92c1944e545188d2359/library/std/src/../../backtrace/src/backtrace/libunwind.rs:117:9
   1:     0x557d91286b62 - std::backtrace_rs::backtrace::trace_unsynchronized::h5d207cd20f193d88
                               at /rustc/17067e9ac6d7ecb70e50f92c1944e545188d2359/library/std/src/../../backtrace/src/backtrace/mod.rs:66:14

...

  67:                0x0 - <unknown>
Error: Cloud Hypervisor exited with the following error:
  Failed to join on VMM thread: Any { .. }

Debug Info: ThreadJoin(Any { .. })
```

- add any panic, for example into the create or drop function of a
  device
- add --seccomp=true|log to analyze the situation

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
2025-06-26 20:50:57 +00:00
dependabot[bot]
2cb8c41adc build: Bump remain from 0.2.14 to 0.2.15
Bumps [remain](https://github.com/dtolnay/remain) from 0.2.14 to 0.2.15.
- [Release notes](https://github.com/dtolnay/remain/releases)
- [Commits](https://github.com/dtolnay/remain/compare/0.2.14...0.2.15)

---
updated-dependencies:
- dependency-name: remain
  dependency-version: 0.2.15
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-26 00:37:52 +00:00
Philipp Schuster
48b67ed03b net_util: code readability improvements
Small cleanup to improve code readability.
Specifically, refactoring a huge loop body into
a function call.

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
2025-06-25 16:22:16 +00:00
Philipp Schuster
e0f0065cbd net_util: improve Error types
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
2025-06-25 16:22:16 +00:00
dependabot[bot]
1866a85a3d build: Bump zerocopy from 0.8.24 to 0.8.26
Bumps [zerocopy](https://github.com/google/zerocopy) from 0.8.24 to 0.8.26.
- [Release notes](https://github.com/google/zerocopy/releases)
- [Changelog](https://github.com/google/zerocopy/blob/main/CHANGELOG.md)
- [Commits](https://github.com/google/zerocopy/compare/v0.8.24...v0.8.26)

---
updated-dependencies:
- dependency-name: zerocopy
  dependency-version: 0.8.26
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-25 10:07:20 +00:00
Hengqi Chen
8338fa642f net_util: Drop duplicated virtio_features_to_tap_offload
The virtio_features_to_tap_offload() defined in ctrl_queue.rs
is duplicated. Remove it and use the one defined in lib.rs
instead.

Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
2025-06-24 17:43:22 +00:00
Wei Liu
a5287c6f67 build: Consolidate UUID crate to workspace
Signed-off-by: Wei Liu <liuwe@microsoft.com>
2025-06-24 16:50:35 +00:00
Philipp Schuster
fe07617f5d misc: add __pycache__ to gitignore
Running `gitlint` locally produces a __pycache__ directory in
`scripts/gitlint/rules/`. It makes sense to exclude this directory.

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
2025-06-24 11:22:00 +00:00
dependabot[bot]
1820c22ba4 build: Bump cc from 1.2.23 to 1.2.27
Bumps [cc](https://github.com/rust-lang/cc-rs) from 1.2.23 to 1.2.27.
- [Release notes](https://github.com/rust-lang/cc-rs/releases)
- [Changelog](https://github.com/rust-lang/cc-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.23...cc-v1.2.27)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-24 04:25:02 +00:00
dependabot[bot]
f828e16d62 build: Bump syn from 2.0.87 to 2.0.104
Bumps [syn](https://github.com/dtolnay/syn) from 2.0.87 to 2.0.104.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/2.0.87...2.0.104)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-24 02:37:24 +00:00
Demi Marie Obenour
24998c1672 vmm: do not treat libc::MAP_FAILED as a pointer
It will likely be safely rejected by the kernel, but it's still wrong.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2025-06-23 09:06:32 +00:00