mirror of
				https://github.com/edera-dev/krata.git
				synced 2025-11-03 23:29:39 +00:00 
			
		
		
		
	move ownership of image compilation to controller
This commit is contained in:
		@ -1,4 +1,6 @@
 | 
			
		||||
use crate::error::Result;
 | 
			
		||||
use crate::image::ImageCompiler;
 | 
			
		||||
use ocipkg::ImageName;
 | 
			
		||||
use xenclient::{DomainConfig, XenClient};
 | 
			
		||||
 | 
			
		||||
pub struct Controller {
 | 
			
		||||
@ -7,12 +9,14 @@ pub struct Controller {
 | 
			
		||||
    initrd_path: String,
 | 
			
		||||
    vcpus: u32,
 | 
			
		||||
    mem: u64,
 | 
			
		||||
    image: String,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Controller {
 | 
			
		||||
    pub fn new(
 | 
			
		||||
        kernel_path: String,
 | 
			
		||||
        initrd_path: String,
 | 
			
		||||
        image: String,
 | 
			
		||||
        vcpus: u32,
 | 
			
		||||
        mem: u64,
 | 
			
		||||
    ) -> Result<Controller> {
 | 
			
		||||
@ -21,11 +25,19 @@ impl Controller {
 | 
			
		||||
            client,
 | 
			
		||||
            kernel_path,
 | 
			
		||||
            initrd_path,
 | 
			
		||||
            image,
 | 
			
		||||
            vcpus,
 | 
			
		||||
            mem,
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn compile(&mut self) -> Result<()> {
 | 
			
		||||
        let image = ImageName::parse(&self.image)?;
 | 
			
		||||
        let compiler = ImageCompiler::new()?;
 | 
			
		||||
        let _squashfs = compiler.compile(&image)?;
 | 
			
		||||
        Ok(())
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn launch(&mut self) -> Result<u32> {
 | 
			
		||||
        let config = DomainConfig {
 | 
			
		||||
            max_vcpus: self.vcpus,
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user