Skip to main content

SnapshotCatalog

Struct SnapshotCatalog 

Source
pub struct SnapshotCatalog { /* private fields */ }
Expand description

Manages the on-disk snapshot catalog for all VMs.

Layout:

{data_dir}/snapshots/{vm_id}/{snapshot_id}/
    vmstate
    mem          (full only)
    meta.json
{data_dir}/snapshots/{vm_id}/.{snapshot_id}.partial/   (being written)

Every catalogued directory carries a readable meta.json, because a snapshot is written into a .partial staging directory and renamed in as a whole (see PendingSnapshot). Readers therefore treat a missing or unparseable record as corruption rather than as a normal lifecycle state.

Implementations§

Source§

impl SnapshotCatalog

Source

pub fn new(data_dir: &str) -> SnapshotCatalog

Create a new catalog rooted at {data_dir}/snapshots.

Source

pub fn begin(&self, vm_id: &str) -> Result<PendingSnapshot<'_>, SnapshotError>

Start a new snapshot for vm_id.

Creates the staging directory; the snapshot enters the catalog only on PendingSnapshot::commit.

Source

pub fn list(&self, vm_id: &str) -> Result<Vec<SnapshotInfo>, SnapshotError>

List all snapshots for a VM, sorted by creation time (oldest first).

Source

pub fn get( &self, vm_id: &str, snapshot_id: &str, ) -> Result<SnapshotMeta, SnapshotError>

Look up a single snapshot by ID.

Source

pub fn delete( &self, vm_id: &str, snapshot_id: &str, ) -> Result<(), SnapshotError>

Delete a snapshot directory from disk.

Source

pub fn sweep_incomplete(&self)

Remove staging directories left behind by a crash mid-checkpoint.

A committed snapshot is renamed into place atomically, so anything still staged when the process died is unfinished by definition — and can be holding a full memory dump.

Source

pub fn find_by_id( &self, snapshot_id: &str, ) -> Result<SnapshotMeta, SnapshotError>

Find a snapshot by ID alone, searching across all owner directories.

Source

pub fn list_all(&self) -> Result<Vec<SnapshotInfo>, SnapshotError>

List all snapshots across every owner directory, sorted by creation time.

Source

pub fn referenced_rootfs_paths( &self, ) -> Result<BTreeSet<PathBuf>, SnapshotError>

Rootfs images that catalogued snapshots depend on.

Restore rebuilds the dm-snapshot origin from SnapshotMeta::rootfs_path, and the guest memory in the snapshot was captured against those exact bytes — re-converting the same image with a different vm-agent produces a different file and is not a substitute. Anything that garbage-collects rootfs images must treat these as pinned.

Source

pub fn delete_by_id(&self, snapshot_id: &str) -> Result<(), SnapshotError>

Delete a snapshot knowing only its ID (searches across all owner directories).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more