Commit Graph

10437 Commits

Author SHA1 Message Date
Anirudh Rayabharam
fcd69fb707 tests: consolidate test config into nextest profiles
Centralize test configuration (filters, retries, fail-fast,
sequential/parallel scheduling) into nextest profiles, replacing
scattered flags across shell scripts. This simplifies the scripts
and provides a single source of truth for test behavior.

Enable JUnit XML output per profile, giving CI systems structured
test results for better reporting.

Not all test invocations are converted to profiles yet. Just the
ones that are repeated across scripts.

Signed-off-by: Anirudh Rayabharam <anrayabh@microsoft.com>
2026-05-19 09:09:55 +00:00
Anirudh Rayabharam
a4f0a18fb5 ci: update Docker image to use nextest 0.9.128
Update the container image tag to trigger a rebuild. The new image
pins cargo-nextest to version 0.9.128, which supports profile
inheritance, needed for the following nextest configuration changes.

Assisted-by: Copilot-CLI:Claude-Opus-4.7
Signed-off-by: Anirudh Rayabharam <anrayabh@microsoft.com>
2026-05-19 09:09:55 +00:00
tchaton
5080d03714 vmm: openapi: Fix typo in iommu_address_width field name
The JSON parser expects the field to be named
`iommu_address_width_bits`, but the code declared it as
`iommu_address_width`. This mismatch caused the field to be
unrecognized when deserializing configuration from JSON.

Rename the field to `iommu_address_width_bits` to match the
expected schema.

Signed-off-by: tchaton <thomas.chaton.ai@gmail.com>
2026-05-19 08:30:16 +00:00
CMGS
f8f92bd628 virtio-devices: 8 MiB-aligned initial BAR placement
Windows 11 PnP rebalance rewrites peer BARs into the same range CH
packed the initial layout at, causing move_bar() failures and boot
deadlock. Pack Mmio64 BARs at 8 MiB stride. Mmio32 isn't wide enough
for the same stride, but its BARs don't participate in guest BAR
rebalancing.

On restore, pin the BAR to the snapshot address (alignment=None) so a
guest-relocated BAR with smaller alignment is accepted.

Signed-off-by: CMGS <ilskdw@gmail.com>
2026-05-19 08:19:25 +00:00
Dylan Reid
a495841515 virtio-devices: iommu: log per-request errors
IommuEpollHandler::request_queue() can fail because the guest put in a
bad request or because of a fatal error. Handle those cases differently,
letting the guest continue, but see the error if it can.

This makes debugging from the guest easier as one mistake doesn't cause
a VM reset if it's avoidable.

Signed-off-by: Dylan Reid <dgreid@fb.com>
2026-05-19 08:16:33 +00:00
Dylan Reid
ab38a77c01 pci: vfio_user: replace unwrap() with explicit error
VfioUserDmaMapping::map panicked when find_region returned an anonymous
mmap region. Change this so a user gets an error instead of a panic.

When the VMM hotplugs a region into a guest that also has a vfio-user
device, all region's handlers are called. With the anonymous memory
backing (no file=, shared=on, or hugepages), region.file_offset()
returns None and the .unwrap() panics the VMM. Replace the unwrap with
an explicit error and use checked_add for the offset combine.

Signed-off-by: Dylan Reid <dgreid@fb.com>
2026-05-19 08:15:54 +00:00
Philipp Schuster
a917f5208a docs: be more explicit in AGENTS.md
Otherwise, codex often says "Codex:GPT-5" which is rather unspecific.
"Codex:GPT-5.4" would be better.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-05-18 21:09:25 +00:00
Philipp Schuster
75baa46816 docs: Mention EditorConfig in agent guide
Tell agents to respect .editorconfig alongside the formatter guidance
from CONTRIBUTING.md.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-05-18 21:09:25 +00:00
Philipp Schuster
466b5a8e08 docs: Move logging guidance to CONTRIBUTING
Keep logging and comment-style guidance in CONTRIBUTING.md and trim
duplicate policy from the agent guide.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-05-18 21:09:25 +00:00
Philipp Schuster
a07097af1f docs: Document supported targets
Move supported architecture and backend guidance from AGENTS.md into
README.md and CONTRIBUTING.md.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-05-18 21:09:25 +00:00
Wei Liu
8ff6114c46 build: make Windows tests blocking again
See #8211. The bug is with a change in memory allocation behaviour, not
with Windows guests.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
2026-05-18 21:05:37 +00:00
Anatol Belski
2c86362674 virtio-devices: Test cap_len of sibling compound virtio PCI caps
Assert VirtioPciNotifyCap and VirtioPciCap64 size cap_len from
their own type. Catches a future regression of the same shape as
the VirtioPciCfgCap one in any of the sibling capabilities.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-05-18 14:30:46 +00:00
Anatol Belski
b776c6d317 virtio-devices: Test cfg_type of VIRTIO_PCI_CAP_PCI_CFG
Assert the emitted VirtioPciCfgCap carries cfg_type 5, the value
assigned to PciCapabilityType::Pci by virtio 1.2 section 4.1.4.1.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-05-18 14:30:46 +00:00
Anatol Belski
e7d394e286 virtio-devices: Test cap_len of VIRTIO_PCI_CAP_PCI_CFG
Regression test for the cap_len fix. The emitted VirtioPciCfgCap
must report cap_len 20, covering the trailing pci_cfg_data window
per virtio 1.2 section 4.1.4.9.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-05-18 14:30:46 +00:00
Anatol Belski
b4dea599a3 virtio-devices: Fix cap_len for VIRTIO_PCI_CAP_PCI_CFG
VirtioPciCfgCap::new built its inner header via VirtioPciCap::new,
which sized cap_len from the bare virtio_pci_cap layout, yielding
16. The emitted capability is VirtioPciCfgCap, which appends a four
byte pci_cfg_data window, so the correct value is 20.

The virtio 1.2 specification defines this cap as virtio_pci_cap
followed by pci_cfg_data[4] and requires cap_len to
cover the whole structure. Build the header inline so cap_len
reflects the actual emitted size, matching VirtioPciNotifyCap and
VirtioPciCap64.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-05-18 14:30:46 +00:00
Rob Bradford
547a78999e vmm: Revert "vmm: create memfd for private mappings"
This reverts commit ced3762a67.

This change lead to a serious memory regression when not using hugepages
or shared=on.

`MAP_PRIVATE` creates an anonymous memory allocation for every page
written when the backing store is a file. This CoW behaviour is useful
but leads to double allocations when the backing store is an empty file
created by `memfd_create()`. When the page is written to, the CoW
semantics require a real page to be created in the memory for the memfd
(previously before the page was touched they would all point to the zero
page). This real page is filled with zeroes because in theory this page
would be accessible via read/write syscalls on the FD even though in our
implementation it is only ever `mmap()`ed.

The intention of the commit was to enable `fallocate()` to be used to
punch holes but that would only affect the inaccessible backing page and
the page in the CoW anonymous memory would be unaffected. Leading it
likely not to have the desired effect.

Fixes: #8211

Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-05-18 07:23:36 -07:00
Chris Webb
7b29691932 vmm: return all-ones for unregistered PIO reads
When reading from an unregistered PIO address, pio_read() wasn't
initialising the buffer, so guests were reading stale bytes from the
previous PIO transaction rather than all 0xff bytes like master abort
on real hardware.

Fill data with 0xff on invalid reads.

Correct 'read to unregistered address' info message to 'read from
unregistered address' while we're touching this block.

Signed-off-by: Chris Webb <chris@arachsys.com>
2026-05-16 15:40:55 +00:00
Chris Webb
4091e965b8 vmm: return all-ones for unregistered MMIO reads
When reading from an unregistered MMIO address, mmio_read() wasn't
initialising the buffer, so guests were reading stale bytes from the
previous MMIO transaction rather than all 0xff bytes like master abort
on real hardware.

Fill data with 0xff on invalid reads.

Correct 'read to unregistered address' info message to 'read from
unregistered address' while we're touching this block.

Signed-off-by: Chris Webb <chris@arachsys.com>
2026-05-16 15:40:55 +00:00
Muminul Islam
fba55b3d9f tests: poll for source VM exit after live-migration
The post-migration check used a fixed `thread::sleep(3s)` followed by
`try_wait()` to verify the source VM had exited cleanly. That window
is too tight when the source process is the release binary used by
`test_live_upgrade_*` (i.e. `~/workloads/cloud-hypervisor-static`,
pinned to `migratable_version`).

The released binary is older than the locally-built destination and
its virtio-device teardown (resume-paused-thread -> kill -> join
across pmem, block, net, console, rng workers) regularly takes
longer than 3s on contended hosts, causing the test to report:

  thread 'common_parallel::test_live_upgrade_basic' panicked:
  Test failed: source VM was not terminated successfully.

even though the source process eventually exits with status 0.

Replace the fixed sleep with a `wait_until(Duration::from_secs(30),
...)` poll that returns as soon as `try_wait()` reports a reaped
child, then keep the existing `success()` check on the exit status.
This makes the assertion robust against the slower release-binary
shutdown path while still failing fast on a genuine error.

The same pattern was duplicated across eight migration helpers plus
the virtio-fs migration variant; convert all nine call sites for
consistency.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-05-16 00:19:45 +00:00
Philipp Schuster
2168ddf16b vmm: migration: better observe and log invalid states
This increases debugability.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-05-15 17:59:02 +00:00
Philipp Schuster
5899d062bc vm-migration: be explicit about commands
Reordering commands or adding commands in-between is breaking the
migration protocol. By using explicit numbers, we can increase the
attention required when touching this code.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-05-15 17:59:02 +00:00
Philipp Schuster
ba04c4f318 virtio-devices, vmm: replace Vec<T> with Box<[T]> in config structs
I started by looking at all `Option<Vec<T>>` values in config.rs and
vm_config.rs, and replaced them with `Option<Box<[T]>>`. This has the
advantage that one now can see at a glance if this field will ever
resize during operation or not, reducing cognitive load and increasing
maintainability. All fields that need the properties of a Ver or where
this change was not trivial are kept intact.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-05-15 16:05:01 +00:00
Philipp Schuster
29e2319247 vmm: store CPU affinity lists as slices
Each affinity host CPU list is copied from configuration.
It is only iterated afterwards, so a boxed slice is enough.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-05-15 16:05:01 +00:00
Philipp Schuster
74392eccae vmm: store PCI segments as a slice
The PCI segment list is created once from the configured count.
Later code mutates entries, but does not add or remove segments.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-05-15 16:05:01 +00:00
Philipp Schuster
c2c3178038 vmm: store PCI MMIO allocators as slices
The allocator lists are sized from the fixed PCI segment count.
They are only indexed afterwards, so boxed slices fit the use.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-05-15 16:05:01 +00:00
Philipp Schuster
8574bf4c13 docs: remove LTS information from releases.md
Cloud Hypervisor doesn't do LTS releases for quite some time now. This
outdated information already caused confusion [0].

[0] https://github.com/NixOS/nixpkgs/pull/520434#issuecomment-4460008719

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-05-15 15:40:01 +00:00
dependabot[bot]
078d57e6b9 build(deps): bump the non-rust-vmm group across 2 directories with 7 updates
Bumps the non-rust-vmm group with 5 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [serde_with](https://github.com/jonasbb/serde_with) | `3.18.0` | `3.19.0` |
| [cc](https://github.com/rust-lang/cc-rs) | `1.2.61` | `1.2.62` |
| [hybrid-array](https://github.com/RustCrypto/hybrid-array) | `0.4.11` | `0.4.12` |
| [winnow](https://github.com/winnow-rs/winnow) | `1.0.0` | `1.0.2` |
| [zvariant](https://github.com/z-galaxy/zbus) | `5.10.1` | `5.11.0` |

Bumps the non-rust-vmm group with 3 updates in the /fuzz directory: [serde_with](https://github.com/jonasbb/serde_with), [cc](https://github.com/rust-lang/cc-rs) and [hybrid-array](https://github.com/RustCrypto/hybrid-array).


Updates `serde_with` from 3.18.0 to 3.19.0
- [Release notes](https://github.com/jonasbb/serde_with/releases)
- [Commits](https://github.com/jonasbb/serde_with/compare/v3.18.0...v3.19.0)

Updates `cc` from 1.2.61 to 1.2.62
- [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.61...cc-v1.2.62)

Updates `hybrid-array` from 0.4.11 to 0.4.12
- [Changelog](https://github.com/RustCrypto/hybrid-array/blob/master/CHANGELOG.md)
- [Commits](https://github.com/RustCrypto/hybrid-array/compare/v0.4.11...v0.4.12)

Updates `serde_with_macros` from 3.18.0 to 3.20.0
- [Release notes](https://github.com/jonasbb/serde_with/releases)
- [Commits](https://github.com/jonasbb/serde_with/compare/v3.18.0...v3.20.0)

Updates `winnow` from 1.0.0 to 1.0.2
- [Changelog](https://github.com/winnow-rs/winnow/blob/main/CHANGELOG.md)
- [Commits](https://github.com/winnow-rs/winnow/compare/v1.0.0...v1.0.2)

Updates `zvariant` from 5.10.1 to 5.11.0
- [Release notes](https://github.com/z-galaxy/zbus/releases)
- [Changelog](https://github.com/z-galaxy/zbus/blob/main/release-plz.toml)
- [Commits](https://github.com/z-galaxy/zbus/compare/zvariant-5.10.1...zvariant-5.11.0)

Updates `zvariant_derive` from 5.10.1 to 5.11.0
- [Release notes](https://github.com/z-galaxy/zbus/releases)
- [Changelog](https://github.com/z-galaxy/zbus/blob/main/release-plz.toml)
- [Commits](https://github.com/z-galaxy/zbus/compare/zvariant_derive-5.10.1...zvariant_derive-5.11.0)

Updates `serde_with` from 3.18.0 to 3.19.0
- [Release notes](https://github.com/jonasbb/serde_with/releases)
- [Commits](https://github.com/jonasbb/serde_with/compare/v3.18.0...v3.19.0)

Updates `cc` from 1.2.61 to 1.2.62
- [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.61...cc-v1.2.62)

Updates `hybrid-array` from 0.4.11 to 0.4.12
- [Changelog](https://github.com/RustCrypto/hybrid-array/blob/master/CHANGELOG.md)
- [Commits](https://github.com/RustCrypto/hybrid-array/compare/v0.4.11...v0.4.12)

Updates `serde_with_macros` from 3.18.0 to 3.20.0
- [Release notes](https://github.com/jonasbb/serde_with/releases)
- [Commits](https://github.com/jonasbb/serde_with/compare/v3.18.0...v3.20.0)

---
updated-dependencies:
- dependency-name: serde_with
  dependency-version: 3.19.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: non-rust-vmm
- dependency-name: cc
  dependency-version: 1.2.62
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: hybrid-array
  dependency-version: 0.4.12
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: serde_with_macros
  dependency-version: 3.20.0
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: non-rust-vmm
- dependency-name: winnow
  dependency-version: 1.0.2
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: zvariant
  dependency-version: 5.11.0
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: non-rust-vmm
- dependency-name: zvariant_derive
  dependency-version: 5.11.0
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: non-rust-vmm
- dependency-name: serde_with
  dependency-version: 3.19.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: non-rust-vmm
- dependency-name: cc
  dependency-version: 1.2.62
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: hybrid-array
  dependency-version: 0.4.12
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: serde_with_macros
  dependency-version: 3.20.0
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: non-rust-vmm
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-15 00:59:24 +00:00
Wei Liu
7d7f24382c tests: add block device integration tests
Assisted-by: Claude:Opus-4.7
Signed-off-by: Wei Liu <liuwe@microsoft.com>
2026-05-14 22:35:02 +00:00
Wei Liu
2fe775fce2 block: use BLKDISCARD/BLKZEROOUT ioctls for block devices
Some block devices (ZFS volume) may require BLKDISCARD and BLKZEROOUT
ioctls for discard and write_zeroes operations respectively.

There is no good way to probe whether fallocate is supported on a block
device. Arguably, punch_hole and write_zeroes are rare. Instead of
having a complex scheme for the IO uring backend, we force it to always
use ioctls. The code can be changed if the synchronized ioctls become a
performance issue.

Changes:
- Detect block devices at construction time
- Use BLKDISCARD ioctl for punch_hole (discard) on block devices
- Use BLKZEROOUT ioctl for write_zeroes on block devices
- Add BLKDISCARD/BLKZEROOUT to VirtioBlock seccomp whitelist
- Keep fallocate() path for regular files (no behavior change)
- Consolidate some helper functions to the new sparse module

Signed-off-by: Wei Liu <liuwe@microsoft.com>
2026-05-14 22:35:02 +00:00
Wei Liu
12919dbce9 block: extract is_block_device() helper and dedupe inline fstat probes
probe_sparse_support() and DiskTopology::is_block_device() each carry
their own copy of the same fstat()+S_IFMT dance to ask "is this fd a
block device?". Hoist a single pub helper

    pub(crate) fn is_block_device(fd: RawFd) -> bool

into block::lib and route both call sites through it. Drop the
MaybeUninit gymnastics in favour of mem::zeroed() since libc::stat is
POD.

Drop DiskTopology::is_block_device since it is now just a one line
wrapper around the new helper function.

Pure refactor in preparation for the BLKDISCARD/BLKZEROOUT support,
which needs the same probe in three more backends.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
2026-05-14 22:35:02 +00:00
Bo Chen
1314ac883c build: Release v52.0
Signed-off-by: Bo Chen <bchen@crusoe.ai>
v52.0
2026-05-14 19:53:22 +00:00
Dylan Reid
6b44e7b190 block: raw_async: reject batch atomically when SQ lacks capacity
submit_batch_requests pushed each BatchRequest into the io_uring SQ in
turn and used `?` to bail on the first push failure.
Leaving the initial SQEs visible to the kernel — but submitter.submit()
was never called, and every other call site in this file gates submit()
behind a preceding sq.push() that now also fails on the full ring.

This could allow a guest to DoS it's own queue or worse if the buffer is
freed early.

Signed-off-by: Dylan Reid <dgreid@fb.com>
2026-05-14 19:53:22 +00:00
Dylan Reid
273e6d53b8 block: AlignedOperation owns its bounce buffer via Drop
The bounce buffer for an unaligned descriptor was allocated in
execute_async and leaked on error paths, even though, for the sync case
the kernel already had a pointer to the buffer.

Clean this up by moving ownership of the buffer to the AlignedOperation
type. To make it actually safe, stop stashing a guest memory pointer for
the duration of the op. Instead, save the guest address and pass guest
memory back to the complete function.

Signed-off-by: Dylan Reid <dgreid@fb.com>
2026-05-14 19:53:22 +00:00
Dylan Reid
094f214f78 virtio-devices: block: track non-batch inflight reqs immediately
For non-batch backends execute_async submits the kernel I/O inline
before returning. An early return while processing before inserting in
inflight_requests, meant the request went untracked, the local batch
list was never appended to inflight_requests, even though the request is
pending in the kernel.

To track it, insert into self.inflight_requests as soon as execute_async
returns Ok. The completion path's find_inflight_request now matches the
orphan and the bounce buffer is freed only after the kernel signals it
is done.

Signed-off-by: Dylan Reid <dgreid@fb.com>
2026-05-14 19:53:22 +00:00
Bo Chen
730677730e virtio-devices: block: reject duplicate in-flight head_index
A malicious or buggy guest can violate virtio by making the same
descriptor head available twice before the first chain has been placed
on the used ring. The submit path pushed both chains onto the
VecDeque-backed inflight_requests keyed by head_index, and on completion
find_inflight_request() returned the first linear match. That Request's
complete_async() freed its bounce buffer while the other chain's
io_uring op was still targeting it, producing a use-after-free the
kernel could then scribble into.

Signed-off-by: Dylan Reid <dgreid@fb.com>
Signed-off-by: Bo Chen <bchen@crusoe.ai>
2026-05-14 19:53:22 +00:00
Bo Chen
b4b99824d6 vmm: Deprecate image type auto detection
Signed-off-by: Bo Chen <bchen@crusoe.ai>
2026-05-14 18:18:14 +00:00
Anatol Belski
9d487a8abc vmm: Disable sector 0 writes for autodetected VHD images
When no image_type is specified, sector 0 writes are disabled as a
safety measure for autodetected raw images. Extend this protection
to autodetected fixed VHD images, which carry metadata in the last
sector and are equally susceptible to accidental overwrites of the
first sector when the format is not explicitly acknowledged.

Update the corresponding warning in the virtio block worker to be
format agnostic.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-05-14 17:27:04 +00:00
CMGS
1ad9920713 vmm: document move_bar allocator rollback paths
Explanatory comments for the rollback paths in both PCI BAR
relocation branches.

Assisted-by: Claude (Anthropic)
Signed-off-by: CMGS <ilskdw@gmail.com>
2026-05-14 15:54:12 +00:00
CMGS
e65cca3bf5 vmm: roll back mem64/IO allocator on failed move_bar
After free(old_base), if allocate(new_base) fails the allocator
treats old_base as free even though the MMIO/PIO bus still maps the
device there. Subsequent allocations pick old_base, mmio_bus.insert
hits the live mapping and returns Overlap.

Restore old_base on the failure path in both the Memory*BitRegion
and IoRegion branches before bubbling the error up.

PR #7950 added restore_bar_addr() so the BAR config register stays
consistent on failed move_bar(); this completes the same picture
for the allocator side.

Signed-off-by: CMGS <ilskdw@gmail.com>
2026-05-14 15:54:12 +00:00
Alyssa Ross
4efb8b7951 virtio-devices: ack requests from backends
Quoting the spec:

> If VHOST_USER_PROTOCOL_F_REPLY_ACK is negotiated, and the back-end
> sets the VHOST_USER_NEED_REPLY flag, the front-end must respond with
> zero when operation is successfully completed, or non-zero
> otherwise.

cloud-hypervisor would previously not send a response to a
VHOST_USER_BACKEND_CONFIG_CHANGE_MSG message, even if
VHOST_USER_PROTOCOL_F_REPLY_ACK had been negotiated and
VHOST_USER_NEED_REPLY was set, in violation of the spec.

Link: https://qemu-project.gitlab.io/qemu/interop/vhost-user.html#back-end-message-types
Fixes: 8d6213338 ("virtio-devices: generic-vhost-user: Config change notification")
Signed-off-by: Alyssa Ross <hi@alyssa.is>
2026-05-14 15:53:24 +00:00
Alyssa Ross
1ad68e8df1 misc: gitlint: allow Closes and Link trailers
Both of these might be used with long URLs.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
2026-05-14 15:56:04 +01:00
Philipp Schuster
b0f92d01fc tests: avoid event wait log spam
Event expectation helpers print detailed diagnostics when the observed
event stream does not match the expected one. That is useful for direct
assertions, but it becomes extremely noisy [0] when the helper is used
as the predicate for wait_until(), because every polling attempt emits
the full mismatch dump.

Add quiet wait wrappers for event polling and emit the existing detailed
diagnostics only once after the timeout expires.

[0] https://github.com/cloud-hypervisor/cloud-hypervisor/actions/runs/25745401604/job/75619840718?pr=8021

On-behalf-of: Philipp Schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-05-13 22:16:29 +00:00
Muminul Islam
96c83168a1 tests: Avoid IPv6 autoconf races in test_vdpa_net
The test_vdpa_net integration test brings the vDPA-backed interface
(ens6) up and then asserts that both TX and RX packet counters are
exactly zero before sending an explicit ping. On guest kernels that
perform IPv6 link-local autoconfiguration quickly enough, however,
Router Solicitation / Neighbor Discovery frames are emitted as soon
as the link comes up. The vdpa_sim_net device loops those frames back
to the interface, so by the time the test queries

    ip -j -p -s link show ens6 | grep -c '"packets": 0'

the TX and RX counters are already non-zero and the precondition
assertion fails (observed reliably with the Microsoft internal guest
kernel running on MSHV).

Disable IPv6 / accept_ra / autoconf on ens6 before bringing the link
up. With IPv6 disabled no autoconf traffic is generated, the counters
remain at zero until the explicit 'ping 172.16.1.10 -c 6' generates
exactly the 6 packets the rest of the test expects on each direction,
and the vDPA-specific portion of the test is unchanged.

Verified on an MSHV Azure VM (Linux 6.6.121.mshv2):

    test common_parallel::test_vdpa_net ... ok
    test result: ok. 1 passed; 0 failed; ...; finished in 26.13s

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-05-13 22:15:19 +00:00
Julian Schindel
466d9491c3 main: Use UTC in wallclock time log
Using `jiff::Timestamp::now()` instead of `jiff::Zoned::now()` skips the
timezone logic required for `Zoned`. This makes the timestamp UTC, with
the appropriate `Z` suffix.

On-behalf-of: SAP julian.schindel@sap.com
Signed-off-by: Julian Schindel <julian.schindel@cyberus-technology.de>
2026-05-13 22:14:57 +00:00
Dylan Reid
1176552b6e virtio-devices: vhost_user: refuse activate when disconnected
If a guest observes DEVICE_NEEDS_RESET, resets the device, and tries to
re-initialize it, but the VMM knows the backend is disconnected, we can
short-circuit the doomed activation.

This is not incorrect, but saves the VMM from making several round-trip
calls to a peer process that doesn't exist. It'll also make the logs
cleaner.

Signed-off-by: Dylan Reid <dgreid@fb.com>
2026-05-13 22:14:52 +00:00
Dylan Reid
99ec20ff97 virtio-devices: vhost_user: skip resume for disconnected backends
resume() mirrors pause() for backend communication: it skips the
vhost-user backend call when the device is already disconnected, and it
marks newly failed resume_vhost_user() calls disconnected only when the
classifier identifies transport loss.

Signed-off-by: Dylan Reid <dgreid@fb.com>
2026-05-13 22:14:52 +00:00
Dylan Reid
f56bfdaeb7 virtio-devices: vhost_user: skip pause for disconnected backends
pause() returns DeviceDisconnected without calling into the backend when
VhostUserCommon already knows the socket is gone. DeviceManager treats
only that sentinel as log-and-continue, so one dead vhost-user device
does not abort the whole pause iteration.

Signed-off-by: Dylan Reid <dgreid@fb.com>
2026-05-13 22:14:52 +00:00
Dylan Reid
db79150303 virtio-devices: vhost_user: memory update error handling
For add memory region, if the backend is disconnected or returns an
error, forward the appropriate error type to the caller. If the error
indicates that the vhost user backend has disconnected, mark it as such.

Signed-off-by: Dylan Reid <dgreid@fb.com>
2026-05-13 22:14:52 +00:00
Dylan Reid
c03e7055cd virtio-devices: vhost_user: skip backend reset when disconnected
reset() is teardown and must still clean up local state even if the
vhost-user backend has already gone away. When the disconnected flag is
already set, it skips reset_vhost_user() and proceeds with kill-event,
worker-unblock, event logging, and interrupt callback cleanup.

Signed-off-by: Dylan Reid <dgreid@fb.com>
2026-05-13 22:14:52 +00:00
Dylan Reid
198ab1447d virtio-devices: vhost_user: remove unused restore_backend_connection
This function hasn't been used since '22.
All callers removed with:
1f0e5eb66 vmm: virtio-devices: Restore every VirtioDevice upon creation

TEST: build and cargo test all still pass, grep returns no results.

Signed-off-by: Dylan Reid <dgreid@fb.com>
2026-05-13 22:14:52 +00:00