Skip to content

microVM: claim a resume snapshot before linking its direct-claimed scratch #565

Closed

Description

Summary

Restoring an instance-checkpoint snapshot whose paired scratch uses the direct-claimed policy hard-links scratch.img into a private directory before OpenVMM claims the snapshot. The architecture guide in doc/design/ orders it the other way: restore claims a resume-policy snapshot in step 8 of the restore sequence and materializes scratch in step 10 (section 5.5.1), and direct-claimed scratch is attached "only after an instance checkpoint has been durably and exclusively claimed" (Table 5.5 in section 5.5.2).

Found while auditing the implementation against the architecture guide.

Where it happens

OpenVMM links are pinned to the gitlink nanvix/openvmm@c6d97c5.

  • lib.rs L2838-L2839 opens the snapshot and calls microvm::prepare_restore. The claim comes later, through SnapshotRestore::prepare at L2982.
  • For direct-claimed, prepare_restore creates a .openvmm-claimed-scratch-* directory beside the snapshot and hard-links the paired scratch into it with link_claimed_paired_scratch_file.
  • prepare.rs L99 then calls snapshot.claim_for_restore(), which creates and flushes resume.claim (restore.rs L419-L463). Its own documentation asks callers to claim "after artifact and configuration validation and before constructing execution-owned workers".

Opening the snapshot rejects an existing resume.claim (restore.rs L472-L475), so a restore that starts after another one has claimed the snapshot fails before it links anything. Two restores that open the snapshot before either claims it both link the claimed instance's scratch. The loser fails at the claim and drops its temporary directory, but a crash between the link and that cleanup leaves a writable hard link to the live instance's scratch beside the snapshot.

The management RPC is unaffected: it rejects snapshots with sandbox blocks.

Intended behavior

A direct-claimed restore links or attaches the paired scratch only after the claim marker is durable, as section 5.5.1 orders it.

Tasks

  • Claim the resume snapshot before prepare_restore materializes direct-claimed scratch, or move the materialization after the claim, in nanvix/openvmm, and promote the pin.
  • Add OpenVMM coverage that a restore that loses the claim never links the paired scratch.

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