Skip to main content

HypervisorProbe

Trait HypervisorProbe 

Source
pub trait HypervisorProbe:
    Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> &str;
    fn try_new_resource(&self) -> Result<Option<Resource<HypervisorKind>>>;
    fn new_resource(
        &self,
        params: &[(&str, &str)],
    ) -> Result<Resource<HypervisorKind>>;
}
Expand description

Trait for probing hypervisor backend availability.

Each registered backend provides a probe that can check whether the backend is available and construct a resource for it.

Required Methods§

Source

fn name(&self) -> &str

Short name (e.g. “kvm”, “whp”). Matches the handle’s ResourceId::ID.

Source

fn try_new_resource(&self) -> Result<Option<Resource<HypervisorKind>>>

Checks whether this backend is available and, if so, returns a new [Resource<HypervisorKind>] for it with default settings.

Used for auto-detection: backends are tried in priority order, and Ok(None) means “skip me, try the next one”.

Source

fn new_resource( &self, params: &[(&str, &str)], ) -> Result<Resource<HypervisorKind>>

Constructs a [Resource<HypervisorKind>] for an explicitly selected backend, with optional parameters.

Unlike try_new_resource, this returns Err (not Ok(None)) if the backend is unavailable, so the caller gets a specific error message.

params contains backend-specific key-value pairs parsed from the --hypervisor name:key=val,... CLI syntax. A bare key (no =) is passed as (key, "true"). Backends should return an error for unrecognized keys.

Implementors§