#![allow(missing_docs)]
#[allow(unused_imports)]
use crate::GuestPath;
#[allow(unused_imports)]
use crate::pod::mount_pod_store_with_client;
#[allow(unused_imports)]
use crate::pod::spec::GuestFilesystem;
#[allow(unused_imports)]
use crate::{Result, connect_vminitd};
#[allow(unused_imports)]
use firkin_types::BlockDeviceId;
#[allow(unused_imports)]
use firkin_vmm::{Running, VirtualMachine};
#[cfg(test)]
#[allow(unused_imports)]
use std::io;
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct PodStoreSpec {
block_device: BlockDeviceId,
guest_mount: GuestPath,
filesystem: GuestFilesystem,
}
impl PodStoreSpec {
#[must_use]
pub fn ext4(block_device: BlockDeviceId) -> Self {
Self {
block_device,
guest_mount: GuestPath::new("/run/firkin/pod-store")
.expect("default pod-store path is valid"),
filesystem: GuestFilesystem::Ext4,
}
}
#[must_use]
pub const fn block_device(&self) -> BlockDeviceId {
self.block_device
}
#[must_use]
pub const fn guest_mount(&self) -> &GuestPath {
&self.guest_mount
}
#[must_use]
pub const fn filesystem(&self) -> GuestFilesystem {
self.filesystem
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct MountedPodStore {
pub(crate) spec: PodStoreSpec,
}
impl MountedPodStore {
#[must_use]
pub const fn spec(&self) -> &PodStoreSpec {
&self.spec
}
#[must_use]
pub const fn guest_mount(&self) -> &GuestPath {
self.spec.guest_mount()
}
}
pub async fn mount_pod_store(
vm: &VirtualMachine<Running>,
spec: &PodStoreSpec,
) -> Result<MountedPodStore> {
let mut client = connect_vminitd(vm).await?;
mount_pod_store_with_client(&mut client, spec).await
}