Skip to content

openvmm: support long Windows paths in secure snapshot creation #1263

Closed

Description

Scope

OpenVMM-only follow-up to #1253, tracked in the NVX repository.
Implement the source changes in microsoft/openvmm on feature/microvm/dev.
This issue does not include NVX source changes or a submodule-pin update.

Problem and ownership

OpenVMM creates snapshot staging directories and the files inside them. On
Windows, its secure-creation helpers pass ordinary UTF-16 paths directly to
CreateDirectoryW and CreateFileW, without extended-length path conversion.
A staging path around 267 characters can consequently fail with:

failed to create staging directory ...\transaction\.snapshot.staging-...:
The system cannot find the path specified. (os error 3)

Changing the parent-directory creator outside OpenVMM does not fix these
independent Win32 calls. Both secure directory creation and secure file creation
must support long paths.

Source references below use the investigated OpenVMM revision
eda13d80a85e49c16ed0500a9d4ae762ca810304.

Exact production fix

Change support\pal\src\windows\security.rs, in the pal package:
source.

  1. Import std::path::Component and std::path::Prefix.

  2. Add a private secure_create_path helper immediately before
    create_directory_with_security.

  3. Replace the direct U16CString::from_os_str(...) conversion in both
    create_directory_with_security and create_file_with_security with:

    let path = secure_create_path(path)?;

The proposed helper is:

fn secure_create_path(path: &Path) -> std::io::Result<U16CString> {
    let path = std::path::absolute(path)?;
    let name = U16CString::from_os_str(path.as_os_str())
        .map_err(|error| std::io::Error::new(ErrorKind::InvalidInput, error))?;
    if name.len() < 248 {
        return Ok(name);
    }
    let (prefix, skip) = match path.components().next() {
        Some(Component::Prefix(prefix)) => match prefix.kind() {
            Prefix::Disk(_) => (r"\\?\", 0),
            Prefix::UNC(..) => (r"\\?\UNC\", 2),
            _ => ("", 0),
        },
        _ => ("", 0),
    };
    U16CString::from_vec(
        prefix
            .encode_utf16()
            .chain(name.as_slice().iter().copied().skip(skip))
            .collect::<Vec<_>>(),
    )
    .map_err(|error| std::io::Error::new(ErrorKind::InvalidInput, error))
}

Required behavior and invariants:

  • Resolve relative paths and ordinary ./.. components before adding a
    verbatim prefix. Use std::path::absolute, not filesystem canonicalization:
    the object being created does not exist yet.
  • Begin extended-length encoding at 248 UTF-16 code units, excluding the
    terminating NUL. Keep the existing short-path representation below that bound.
  • Encode disk paths as \\?\C:\... and UNC paths as
    \\?\UNC\server\share\..., removing only the UNC path's original leading \\.
    Do not double-prefix existing verbatim/device namespaces.
  • Preserve UTF-16 names without lossy conversion; reject embedded NUL rather
    than operating on a truncated name.
  • Leave SECURITY_ATTRIBUTES, the atomic protected DACL, access/sharing flags,
    exclusive CREATE_NEW behavior, and error propagation unchanged.
    Do not create an object permissively and restrict it afterwards.
  • Apply this conversion only to these filesystem paths, not process working
    directories, named pipes, DLL names, or kernel-object names.

Existing callers: no duplicate path workaround needed

The production snapshot call chain already reaches these PAL functions:

Keep those production callers unchanged; fix the shared Win32 boundary once.

Regression changes

Only two OpenVMM files need edits:

File Change
support\pal\src\windows\security.rs Production helper and both call sites above; add secure_creation_supports_long_paths in the existing test module; make its dacl_sddl test helper use the same path conversion so ACL queries support the long fixtures
openvmm\openvmm_helpers\src\snapshot\publish.rs Add snapshots_are_published_under_long_paths in the existing test module; no production publication change

The PAL regression should create real directories and files below a parent over
320 UTF-16 units, covering ordinary paths, child\.., already-verbatim paths,
and non-BMP leaf names. Reopen/read file contents, compare protected DACLs, and
require AlreadyExists when recreating either object. Preserve the existing
tests that ensure pre-existing objects are not modified.

The publication regression should publish a snapshot using real memory/scratch
fixture files below a long parent, read the manifest back, verify the paired
scratch digest, and ensure the parent contains only the published snapshot
directory, not leftover staging directories. This test needs no running VM.

Validation and acceptance

Run on Windows and Linux from the OpenVMM root:

cargo check -p pal -p openvmm_helpers
cargo clippy --all-targets -p pal -p openvmm_helpers
cargo doc --no-deps -p pal -p openvmm_helpers
cargo nextest run --profile agent -p pal -p openvmm_helpers

Run cargo xtask fmt --fix last before committing, inspect its resulting diff,
and follow the OpenVMM repository's commit requirements.

A local prototype of this scoped patch has already passed these package gates:
160 tests on Windows and 128 on Linux, with no skipped tests in those runs.
That is package-level evidence, not a full OpenVMM workspace or live VM result.
Live WHP/MSHV snapshot capture/clone, a live UNC share, and long-path hard-linked
RAM publication were not specifically exercised and must not be reported as
validated by these unit tests.

Land the reviewed fix on feature/microvm/dev and record the upstream PR and
immutable commit in this tracker.

Activity

  1. changed the title [-]Track OpenVMM Windows long-path support for snapshot publication[/-] [+]openvmm: support long Windows paths in secure snapshot creation[/+] on Nov 4, 2026
  2. ppenna commented on Nov 5, 2026

    @ppenna
    Contributor

    The fix landed on feature/microvm/dev of microsoft/openvmm:

    secure_create_path resolves the path as Win32 would and encodes it as an extended-length path from 248 UTF-16 code units, for both create_directory_with_security and create_file_with_security; the security attributes, CREATE_NEW, sharing, and error propagation are unchanged. Unlike the proposed helper, it also leaves NT (\??\...) and empty paths unchanged, since std::path::absolute would resolve an NT path against the current drive.

    Validation, beyond the package gates of microsoft/openvmm#4916 on Windows and Linux and OpenVMM's checkin gates: on Windows/WHP (nvx-whp-test, a virtual machine), a guest-requested capture below a long TEMP failed at 4713c539a with failed to create staging directory ...: The system cannot find the path specified. (os error 3) and published at 9cec2b892; the snapshot-core and scratch-snapshot microVM scenarios failed there at 4713c539a and passed at 9cec2b892; and NVX's default WHP microVM suite passed, 49 of 49, at #1284's head. Not exercised: a live UNC share.

  3. ppenna commented on Nov 5, 2026

    @ppenna
    Contributor

    Closing as completed. Checked on 2026-11-05:

    Not exercised: a live UNC share.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions