- Created T026-practical-test task.yaml for MVP smoke testing - Added k8shost-server to flake.nix (packages, apps, overlays) - Staged all workspace directories for nix flake build - Updated flake.nix shellHook to include k8shost Resolves: T026.S1 blocker (R8 - nix submodule visibility)
48 lines
1.2 KiB
Rust
48 lines
1.2 KiB
Rust
//! Hypervisor backend registry
|
|
|
|
use dashmap::DashMap;
|
|
use plasmavmc_types::HypervisorType;
|
|
use std::sync::Arc;
|
|
|
|
use crate::HypervisorBackend;
|
|
|
|
/// Registry of available hypervisor backends
|
|
pub struct HypervisorRegistry {
|
|
backends: DashMap<HypervisorType, Arc<dyn HypervisorBackend>>,
|
|
}
|
|
|
|
impl HypervisorRegistry {
|
|
/// Create a new empty registry
|
|
pub fn new() -> Self {
|
|
Self {
|
|
backends: DashMap::new(),
|
|
}
|
|
}
|
|
|
|
/// Register a hypervisor backend
|
|
pub fn register(&self, backend: Arc<dyn HypervisorBackend>) {
|
|
let typ = backend.backend_type();
|
|
self.backends.insert(typ, backend);
|
|
}
|
|
|
|
/// Get a backend by type
|
|
pub fn get(&self, typ: HypervisorType) -> Option<Arc<dyn HypervisorBackend>> {
|
|
self.backends.get(&typ).map(|r| r.value().clone())
|
|
}
|
|
|
|
/// List available backend types
|
|
pub fn available(&self) -> Vec<HypervisorType> {
|
|
self.backends.iter().map(|r| *r.key()).collect()
|
|
}
|
|
|
|
/// Check if a backend is registered
|
|
pub fn has(&self, typ: HypervisorType) -> bool {
|
|
self.backends.contains_key(&typ)
|
|
}
|
|
}
|
|
|
|
impl Default for HypervisorRegistry {
|
|
fn default() -> Self {
|
|
Self::new()
|
|
}
|
|
}
|