Commit Graph

9739 Commits

Author SHA1 Message Date
Anatol Belski
1db64f511e block: vhd: impl Geometry for FixedVhdDiskAsync
Use default DiskTopology with 512 byte sectors.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:16:04 +00:00
Anatol Belski
2973987c81 block: vhd: impl DiskFd for FixedVhdDiskAsync
Delegate to FixedVhd::as_raw_fd().

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:16:04 +00:00
Anatol Belski
42af5913d9 block: vhd: impl PhysicalSize for FixedVhdDiskAsync
Fix .unwrap() bug: use explicit GetFileMetadata match.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:16:04 +00:00
Anatol Belski
d82b1101d9 block: vhd: impl DiskSize for FixedVhdDiskAsync
Delegate to infallible FixedVhd::logical_size().

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:16:04 +00:00
Anatol Belski
15073edf08 block: vhd: Switch FixedVhdDiskAsync::new to BlockResult
Map FixedVhd::new io::Error to BlockError with ErrorOp::Open.
Update vmm CreateFixedVhdDiskAsync source type accordingly.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:16:04 +00:00
Muminul Islam
38eb10d209 block: Remove legacy DiskFile impl from RawFileDiskSync
Remove the legacy async_io::DiskFile implementation from
RawFileDiskSync now that the new disk_file trait impls are
in place.

Remove unused imports: Seek, SeekFrom, DiskFile, and
DiskFileResult.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
4f44cd9ed3 vmm: Switch RawFileDiskSync to DiskBackend::Next
Update device_manager.rs to construct DiskBackend::Next
instead of DiskBackend::Legacy for the synchronous raw
backend.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
afd018f9d1 fuzz: Switch RawFileDiskSync to DiskBackend::Next
Update fuzz/block.rs to construct DiskBackend::Next instead
of DiskBackend::Legacy for the synchronous raw backend.

Remove the unused async_io::DiskFile import.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
662d350cf9 block: Implement AsyncDiskFile trait for RawFileDiskSync
Add disk_file::AsyncDiskFile trait implementation for
RawFileDiskSync with try_clone() and new_async_io() methods.

try_clone() duplicates the underlying file descriptor and
wraps it in a new RawFileDiskSync. new_async_io() creates a
RawFileSync (synchronous fallback) backend, wrapping errors
in BlockError instead of DiskFileError.

Add DiskFileError::Clone variant in async_io.rs for the
try_clone() error path.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
da72a3abfb block: Implement DiskFile marker trait for RawFileDiskSync
Add empty disk_file::DiskFile impl for RawFileDiskSync.
This marker supertrait requires DiskSize + Geometry + Sync,
all of which are now satisfied.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
6b14d27f30 block: Implement Resizable trait for RawFileDiskSync
Add disk_file::Resizable trait implementation for
RawFileDiskSync. Calls file.set_len(size) and wraps the
I/O error in BlockError on failure.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
fe39929a2a block: Implement SparseCapable trait for RawFileDiskSync
Add disk_file::SparseCapable trait implementation for
RawFileDiskSync. Delegates to probe_sparse_support() to
detect whether the underlying file supports hole-punching.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
aa5aa6fe89 block: Implement Geometry trait for RawFileDiskSync
Add disk_file::Geometry trait implementation for
RawFileDiskSync. Probes disk topology from the file,
falling back to defaults on failure. Takes &self instead
of &mut self and uses unwrap_or_else for cleaner error
handling.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
bd026ce4cb block: Implement DiskFd trait for RawFileDiskSync
Add disk_file::DiskFd trait implementation for
RawFileDiskSync. Delegates to file.as_raw_fd() via
BorrowedDiskFd, taking &self instead of &mut self.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
744c365faa block: Implement PhysicalSize trait for RawFileDiskSync
Add disk_file::PhysicalSize trait implementation for
RawFileDiskSync. Returns metadata().len() wrapped in
BlockError on failure, consistent with the DiskSize impl.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
00a355d273 block: Implement DiskSize trait for RawFileDiskSync
Add disk_file::DiskSize trait implementation for
RawFileDiskSync using BlockError and BlockResult. Uses
metadata().len() instead of seek(SeekFrom::End(0)), taking
&self instead of &mut self.

Add BlockError, BlockErrorKind, BlockResult, and disk_file
imports needed by this and subsequent trait impls.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
98fedac77f block: Derive Debug on RawFileDiskSync
Add #[derive(Debug)] to RawFileDiskSync. This is required
by the new disk_file traits which have Send + Debug bounds.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
573f3af77d vmm: Switch RawFileDisk to DiskBackend::Next
Update device_manager.rs to construct DiskBackend::Next
instead of DiskBackend::Legacy for the io_uring raw backend.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:14:42 +00:00
Muminul Islam
491c5493c5 block: Implement AsyncDiskFile trait for RawFileDisk
Add disk_file::AsyncDiskFile trait implementation for
RawFileDisk with try_clone() and new_async_io() methods.

try_clone() duplicates the underlying file descriptor and
wraps it in a new RawFileDisk. new_async_io() creates a
RawFileAsync (io_uring) backend, wrapping errors in
BlockError instead of DiskFileError.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:14:42 +00:00
Muminul Islam
607a2c769d block: Implement DiskFile marker trait for RawFileDisk
Add empty disk_file::DiskFile impl for RawFileDisk. This
marker supertrait requires DiskSize + Geometry + Sync, all
of which are now satisfied.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:14:42 +00:00
Muminul Islam
64b65caddd block: Implement Resizable trait for RawFileDisk
Add disk_file::Resizable trait implementation for
RawFileDisk. Calls file.set_len(size) and wraps the I/O
error in BlockError on failure.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:14:42 +00:00
Muminul Islam
899dec4c04 block: Implement SparseCapable trait for RawFileDisk
Add disk_file::SparseCapable trait implementation for
RawFileDisk. Delegates to probe_sparse_support() to detect
whether the underlying file supports hole-punching.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:14:42 +00:00
Muminul Islam
7e514d8d0e block: Implement Geometry trait for RawFileDisk
Add disk_file::Geometry trait implementation for RawFileDisk.
Probes disk topology from the file, falling back to defaults
on failure. Takes &self instead of &mut self and uses
unwrap_or_else for cleaner error handling.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:14:42 +00:00
Muminul Islam
ca1f48a717 block: Implement DiskFd trait for RawFileDisk
Add disk_file::DiskFd trait implementation for RawFileDisk.
Delegates to file.as_raw_fd() via BorrowedDiskFd, taking
&self instead of &mut self.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:14:42 +00:00
Muminul Islam
aa6a7aea0e block: Implement PhysicalSize trait for RawFileDisk
Add disk_file::PhysicalSize trait implementation for
RawFileDisk. Returns metadata().len() wrapped in BlockError
on failure, consistent with the DiskSize impl.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:14:42 +00:00
Muminul Islam
0647202215 block: Implement DiskSize trait for RawFileDisk
Add disk_file::DiskSize trait implementation for RawFileDisk
using BlockError and BlockResult. Uses metadata().len()
instead of seek(SeekFrom::End(0)), taking &self instead of
&mut self.

Add BlockError, BlockErrorKind, BlockResult, and disk_file
imports needed by this and subsequent trait impls.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:14:42 +00:00
Muminul Islam
4586ca133a block: Derive Debug on RawFileDisk
Add #[derive(Debug)] to RawFileDisk. This is required by the
new disk_file traits which have Send + Debug bounds.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:14:42 +00:00
Muminul Islam
6261cad0d8 block: Add DiskFileError::Clone variant
Add a Clone variant to DiskFileError for error handling in
the upcoming AsyncDiskFile::try_clone() implementations.

This variant will be used by RawFileDisk and RawFileDiskSync
when cloning the underlying file descriptor fails.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:14:42 +00:00
Anatol Belski
823ab99e02 virtio-devices: block: Use error specific status in sync fallback path
The sync fallback path in process_queue_submit() hardcoded
VIRTIO_BLK_S_IOERR for all errors. This caused unsupported
request errors to report IOERR to the guest instead of the
correct VIRTIO_BLK_S_UNSUPP.

Use ExecuteError::status() to return the appropriate status
code for each error variant.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 21:21:19 +00:00
Anirudh Rayabharam
cbe7018f84 vmm: cpu: fix broken URL
Fix broken URL reported by Lychee. The binutils-gdb github repo no
longer exists. Use the equivalent sourceware.org link.

Signed-off-by: Anirudh Rayabharam <anrayabh@microsoft.com>
2026-03-30 17:21:15 +00:00
Demi Marie Obenour
9b9950335f ci: Run pull_request_target workflows with no permisisons
The MSHV tests need access to secrets so that they can run workloads in
Azure.  It does not need privileged access to GitHub.  Ensure its
GITHUB_TOKEN has no permissions.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2026-03-30 17:21:08 +00:00
Bo Chen
ea0a0393b5 build: Fix the vfio integration test workflow
Switch the workspace ownership fix from 'runner' to 'github-runner'
to match the new dedicated service account used on the self-hosted
VFIO runner.

Signed-off-by: Bo Chen <bchen@crusoe.ai>
2026-03-28 08:20:08 +00:00
Bo Chen
ce3b3fa1b2 build: Enable the vfio CI worker
This reverts commit 8aaf3734aa.

Fixes: #7751

Signed-off-by: Saravanan D <saravanand@crusoe.ai>
Signed-off-by: Bo Chen <bchen@crusoe.ai>
2026-03-28 08:20:08 +00:00
Rob Bradford
baacaea35e build: Bump vfio-ioctls to 0.6.0
This version is identical but with a new version number as the old
version is yanked due to a semver break.

Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-03-28 08:19:31 +00:00
Philipp Schuster
c06f6c3293 tests: fix CI flakiness
This test has failed at least once in upstream CI. With the applied
stress workload, reducing the downtime to 1 ms makes it virtually
impossible for CI runners with various speeds to complete VM migration.

In other words: we will always be able to cancel.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2026-03-27 16:29:28 +00:00
Rob Bradford
0bc3ca1103 tests: Add snapshot/restore integration test for virtio-fs
Add test_snapshot_restore_virtio_fs which validates that virtio-fs
continues to work correctly across a snapshot/restore cycle.

Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-03-27 14:18:27 +00:00
Rob Bradford
cd3334a3c2 virtio-devices: vhost_user: Enable snapshot/restore for vhost-user-*
Enable the DEVICE_STATE protocol feature negotiation for all vhost-user
devices (block, fs, net, and generic). Restoring the state (including
the backend state if present) and vrings.

Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-03-27 14:18:27 +00:00
Rob Bradford
2fbb98e2c3 virtio-devices: vhost_user: Add common code for restoring state
Add a common method for validating the state (checking vrings &
device_state) and then restoring the backend state if present.

Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-03-27 14:18:27 +00:00
Rob Bradford
02688993a0 virtio-devices: vhost_user: Fetch and store the backend state/vring
Fetch the opaque device state from the backend and store it along with
the last vring used in the state used for the snapshot.

Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-03-27 14:18:27 +00:00
Rob Bradford
a6b9455402 virtio-devices: vhost_user: Add get/set of backend state support
The vhost-user protocol now has support for the backend to provide an
opaque blob of data (read or written through a pipe) that the VMM can
use to save/restore state after snapshot/restore or live migration.

It also adds a command for checking the backend accepts the uploaded
device state. One quirk of saving the state is that GET_VRING_BASE must
be used first to quiesce the state of the backend and flush any
in-flight requests. This then also requires saving that index for use on
the restore.

Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-03-27 14:18:27 +00:00
Rob Bradford
afc3cb8e1f virtio-devices: vhost_user: Rename update_supports_migration
Rename update_supports_migration() to update_supported_features() as
this method will be extended to track additional capability flags beyond
just migration support (e.g. DEVICE_STATE for snapshot/restore.)

Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-03-27 14:18:27 +00:00
Rob Bradford
8536a2536e virtio-devices: vhost_user: Adapt state() to return Result
This is a refactoring step in preparation for fetching backend device
state via SET_DEVICE_STATE_FD which can fail.

Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-03-27 14:18:27 +00:00
Rob Bradford
3e233af654 virtio-devices: vhost_user: Access acked_protocol_features directly
In GenericVhostUser's read_config and write_config, access
vu_common.acked_protocol_features directly instead of going through
the state() method which creates a struct. This removes creating the
struct just to access two fields that are already directly accessible.

Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-03-27 14:18:27 +00:00
Rob Bradford
bd56214d54 virtio-devices: vhost_user: Add VhostUserCommon::state() helper
With a common state structure for all vhost-user devices the state()
methods can also be refactored for reuse. This will make it easier to
add new common fields in the future for snapshot/restore.

Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-03-27 14:18:27 +00:00
Rob Bradford
a77f89847e virtio-devices: vhost_user: Consolidate device State into VhostUserState
Each vhost-user device type had near identical State structs.
Deduplicate those by introducing a new common struct (and parameterising
it when it needs to embed a config member.) This will make it easier to
reuse more code in the future and to add more struct members to handle
the requirements of snapshot/restore.

These changes have been designed to have no impact on the existing
snapshot/restore state.

Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-03-27 14:18:27 +00:00
Alyssa Ross
e1e6d0a25b vmm: fix rebooting with landlock and pty console
When landlock support was added, creation of file descriptors was
moved out into a function called pre_create_console_devices, with the
idea being that this could be run before Landlock rules are applied
and access to all the necessary paths are dropped.

This idea didn't take reboots into account, though.  When a VM is
rebooted, pre_create_console_devices is called again, but now the
Landlock rules have been applied, so they need to allow access to all
those paths anyway.

I imagine the way this was intended to work was that file descriptors
would be preserved across reboot, but that's not currently the case,
and it's not a trivial change to make because they get dropped when
the VM is destroyed.  Longer term it would be ideal if Cloud
Hypervisor's implementation was more focused on file descriptors than
paths[1], and if created VMs only took references to file descriptors,
so they were easily preserved across reboots.

Fixes: b3e5738b4 ("vmm: Introduce ApplyLandlock trait")
Closes: https://github.com/cloud-hypervisor/cloud-hypervisor/issues/7547
Link: https://github.com/cloud-hypervisor/cloud-hypervisor/issues/7704 [1]
Signed-off-by: Alyssa Ross <hi@alyssa.is>
2026-03-27 11:11:26 +00:00
Anatol Belski
c21d6bb856 block: Add unit tests for query_device_size()
Test regular file with odd size (not page/sector aligned), sparse
file with punch hole verifying physical < logical, and char device
rejection, etc.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-27 11:05:07 +00:00
Anatol Belski
a21b9588ec virtio-devices: block: Use logical_size() for advisory lock range
Use logical_size() instead of physical_size() for the byte-range
advisory lock. physical_size() returns st_blocks*512 which is the
actual host allocation and can be smaller than the guest visible
extent on sparse files, leaving part of the range unprotected.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-27 11:05:07 +00:00
Anatol Belski
8b6eb83f2a block: qcow: raw_file: Use query_device_size() for size queries
Use query_device_size() instead of metadata().len() to correctly
handle block device and regular file handles.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-27 11:05:07 +00:00
Anatol Belski
1b92af5534 block: raw_async_aio: Use query_device_size() for size queries
Use query_device_size() instead of seek(End(0)) and metadata().len()
to correctly handle block device and regular file handles.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-27 11:05:07 +00:00