Skip to content

rpc: accept client-opened virtual disks via registered handle - #5196

Merged
Daman Mulye (damanm24) merged 1 commit into
microsoft:mainfrom
damanm24:wsl-upstream-virtual-disks
Nov 23, 2026
Merged

Daman Mulye (damanm24) merged 1 commit into
microsoft:mainfrom
damanm24:wsl-upstream-virtual-disks

Conversation

@damanm24

Copy link
Copy Markdown
Contributor

This PR adds support for attaching a VHD or VHDX that the client has already opened to a VM through the ttrpc/gRPC interface on Windows, so the image is accessed with the client's rights rather than OpenVMM's.

Callers open the image with OpenVirtualDisk, attach it for raw access, register the handle through the resource-passing protocol, and reference it by name with DiskBackend.virtual_disk.handle_name. OpenVMM wraps the handle as a VHDMP disk, so I/O, discard and read-only handling match disks that OpenVMM opens by path. Virtual disks can back virtio-blk devices and NVMe namespaces. Handles that are not attached for raw access are rejected with a specific error.

Add DiskBackend.virtual_disk, which references a VHD or VHDX handle that
the client opened with OpenVirtualDisk, attached for raw access and
registered through the resource-passing protocol. OpenVMM wraps the handle
as a VHDMP disk, so the image is accessed with the client's rights rather
than OpenVMM's own, and I/O, discard and read-only handling match disks
that OpenVMM opens by path.

Virtual disks can back virtio-blk devices and NVMe namespaces, but not a
VMGS or the lower disk of a memory diff overlay. VhdmpDisk rejects handles
that are not attached for raw access with a specific error instead of a
failed metadata query.

A new VMM test passes a VHD handle to OpenVMM, exposes it to the guest over
virtio-blk, and checks the disk size and the data written by both host and
guest. The ttrpc VMM tests now share common pipette setup helpers.
Copilot AI balanced review requested due to automatic review settings November 21, 2026 01:36
@github-actions github-actions Bot added Guide unsafe Related to unsafe code labels Nov 21, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Unsafe Code Detected

This PR modifies files containing unsafe Rust code. Extra scrutiny is required during review.

For more on why we check whole files, instead of just diffs, check out the Rustonomicon

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Reusing a registered handle across multiple disks creates independent I/O locks over the same Windows file object, allowing concurrent I/O to bypass required serialization.

1 open issue
What changed in this PR

Adds Windows RPC support for client-opened VHD/VHDX handles, allowing virtio-blk devices and NVMe namespaces to access images with the client’s rights.

Changes:

  • Adds a registered-handle disk backend to the RPC schema and resource resolution.
  • Wraps supplied handles as VHDMP disks and rejects unattached handles.
  • Adds unit and integration coverage, shared test helpers, and documentation.
File Description
vmm_tests/​vmm_tests/​tests/​tests/​ttrpc/​handle_passing.rs Tests registered virtual-disk attachment and guest/host data visibility.
vmm_tests/​vmm_tests/​tests/​tests/​ttrpc.rs Extracts shared boot, pipette, and device-wait helpers.
vmm_tests/​vmm_tests/​Cargo.toml Adds the Windows VHDMP test dependency.
vm/​devices/​storage/​disk_vhdmp/​src/​lib.rs Supports externally opened handles and checks attachment state.
openvmm/​openvmm_ttrpc_vmservice/​src/​vmservice.proto Defines the virtual-disk backend and its usage contract.
openvmm/​openvmm_ttrpc_vmservice/​src/​resource_passing.md Documents the registered virtual-disk handle field.
openvmm/​openvmm_entry/​src/​ttrpc/​mod.rs Resolves registered handles for storage devices and adds unit tests.
openvmm/​openvmm_entry/​Cargo.toml Adds the Windows VHDMP runtime dependency.
Guide/​src/​reference/​openvmm/​management/​grpc.md Explains client-opened virtual disks through RPC.
Cargo.lock Records the added VHDMP dependencies.

Review effort: Balanced

.resolve(handle_name)
.with_context(|| format!("failed to resolve virtual disk '{handle_name}'"))?
.into();
Ok(disk_vhdmp::OpenVhdmpDiskConfig(disk_vhdmp::Vhd::from_file(file)).into_resource())
@damanm24
Daman Mulye (damanm24) merged commit a1f7b8e into microsoft:main Nov 23, 2026
108 of 109 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Guide unsafe Related to unsafe code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants