mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-04 05:31:32 +00:00
feat: oci compliance work (#85)
* chore: rework oci crate to be more composable * feat: image pull is now internally explicit * feat: utilize vfs for assembling oci images * feat: rework oci to preserve permissions via a vfs
This commit is contained in:
@ -17,7 +17,6 @@ use self::{
|
||||
autoloop::AutoLoop,
|
||||
launch::{GuestLaunchRequest, GuestLauncher},
|
||||
};
|
||||
use krataoci::{cache::ImageCache, progress::OciProgressContext};
|
||||
|
||||
pub mod autoloop;
|
||||
pub mod cfgblk;
|
||||
@ -51,8 +50,6 @@ pub struct GuestInfo {
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct RuntimeContext {
|
||||
pub oci_progress_context: OciProgressContext,
|
||||
pub image_cache: ImageCache,
|
||||
pub autoloop: AutoLoop,
|
||||
pub xen: XenClient,
|
||||
pub kernel: String,
|
||||
@ -60,7 +57,7 @@ pub struct RuntimeContext {
|
||||
}
|
||||
|
||||
impl RuntimeContext {
|
||||
pub async fn new(oci_progress_context: OciProgressContext, store: String) -> Result<Self> {
|
||||
pub async fn new(store: String) -> Result<Self> {
|
||||
let mut image_cache_path = PathBuf::from(&store);
|
||||
image_cache_path.push("cache");
|
||||
fs::create_dir_all(&image_cache_path)?;
|
||||
@ -68,13 +65,10 @@ impl RuntimeContext {
|
||||
let xen = XenClient::open(0).await?;
|
||||
image_cache_path.push("image");
|
||||
fs::create_dir_all(&image_cache_path)?;
|
||||
let image_cache = ImageCache::new(&image_cache_path)?;
|
||||
let kernel = RuntimeContext::detect_guest_file(&store, "kernel")?;
|
||||
let initrd = RuntimeContext::detect_guest_file(&store, "initrd")?;
|
||||
|
||||
Ok(RuntimeContext {
|
||||
oci_progress_context,
|
||||
image_cache,
|
||||
autoloop: AutoLoop::new(LoopControl::open()?),
|
||||
xen,
|
||||
kernel,
|
||||
@ -254,24 +248,22 @@ impl RuntimeContext {
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Runtime {
|
||||
oci_progress_context: OciProgressContext,
|
||||
store: Arc<String>,
|
||||
context: RuntimeContext,
|
||||
launch_semaphore: Arc<Semaphore>,
|
||||
}
|
||||
|
||||
impl Runtime {
|
||||
pub async fn new(oci_progress_context: OciProgressContext, store: String) -> Result<Self> {
|
||||
let context = RuntimeContext::new(oci_progress_context.clone(), store.clone()).await?;
|
||||
pub async fn new(store: String) -> Result<Self> {
|
||||
let context = RuntimeContext::new(store.clone()).await?;
|
||||
Ok(Self {
|
||||
oci_progress_context,
|
||||
store: Arc::new(store),
|
||||
context,
|
||||
launch_semaphore: Arc::new(Semaphore::new(1)),
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn launch<'a>(&self, request: GuestLaunchRequest<'a>) -> Result<GuestInfo> {
|
||||
pub async fn launch(&self, request: GuestLaunchRequest) -> Result<GuestInfo> {
|
||||
let mut launcher = GuestLauncher::new(self.launch_semaphore.clone())?;
|
||||
launcher.launch(&self.context, request).await
|
||||
}
|
||||
@ -328,7 +320,7 @@ impl Runtime {
|
||||
}
|
||||
|
||||
pub async fn dupe(&self) -> Result<Runtime> {
|
||||
Runtime::new(self.oci_progress_context.clone(), (*self.store).clone()).await
|
||||
Runtime::new((*self.store).clone()).await
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user