pub fn new(cfg: BootSourceConfig) -> std::result::Result<Self, BootSourceConfigError> {
        use self::BootSourceConfigError::{
            InvalidInitrdPath, InvalidKernelCommandLine, InvalidKernelPath,
        };

        // Validate boot source config.
        let kernel_file = File::open(&cfg.kernel_image_path).map_err(InvalidKernelPath)?;
        let initrd_file: Option<File> = match &cfg.initrd_path {
            Some(path) => Some(File::open(path).map_err(InvalidInitrdPath)?),
            None => None,
        };
        let mut cmdline = linux_loader::cmdline::Cmdline::new(arch::CMDLINE_MAX_SIZE);
        let boot_args = match cfg.boot_args.as_ref() {
            None => DEFAULT_KERNEL_CMDLINE,
            Some(str) => str.as_str(),
        };
        cmdline
            .insert_str(boot_args)
            .map_err(|e| InvalidKernelCommandLine(e.to_string()))?;

        Ok(BootConfig {
            cmdline,
            kernel_file,
            initrd_file,
            // We can simply store original config since it doesn't support updates.
            description: cfg,
        })
    }
/// Creates the BootConfig based on a given configuration.
Creates the BootConfig based on a given configuration.
Creates the BootConfig based on a given configuration .
pub fn new(cfg: BootSourceConfig) -> std::result::Result<Self, BootSourceConfigError> {
        use self::BootSourceConfigError::{
            InvalidInitrdPath, InvalidKernelCommandLine, InvalidKernelPath,
        };
        // Validate boot source config.
        let kernel_file = File::open(&cfg.kernel_image_path).map_err(InvalidKernelPath)?;
        let initrd_file: Option<File> = match &cfg.initrd_path {
            Some(path) => Some(File::open(path).map_err(InvalidInitrdPath)?),
            None => None,
        };
        let mut cmdline = linux_loader::cmdline::Cmdline::new(arch::CMDLINE_MAX_SIZE);
        let boot_args = match cfg.boot_args.as_ref() {
            None => DEFAULT_KERNEL_CMDLINE,
            Some(str) => str.as_str(),
        };
        cmdline
            .insert_str(boot_args)
            .map_err(|e| InvalidKernelCommandLine(e.to_string()))?;
        Ok(BootConfig {
            cmdline,
            kernel_file,
            initrd_file,
            // We can simply store original config since it doesn't support updates.
            description: cfg,
        })
    }
pub fn new ( cfg : BootSourceConfig ) -> std :: result :: Result < Self , BootSourceConfigError > { use self :: BootSourceConfigError :: { InvalidInitrdPath , InvalidKernelCommandLine , InvalidKernelPath , } ; // Validate boot source config. let kernel_file = File :: open ( & cfg . kernel_image_path ) . map_err ( InvalidKernelPath ) ? ; let initrd_file : Option < File > = match & cfg . initrd_path { Some ( path ) => Some ( File :: open ( path ) . map_err ( InvalidInitrdPath ) ? ) , None => None , } ; let mut cmdline = linux_loader :: cmdline :: Cmdline :: new ( arch :: CMDLINE_MAX_SIZE ) ; let boot_args = match cfg . boot_args . as_ref ( ) { None => DEFAULT_KERNEL_CMDLINE , Some ( str ) => str . as_str ( ) , } ; cmdline . insert_str ( boot_args ) . map_err ( | e | InvalidKernelCommandLine ( e . to_string ( ) ) ) ? ; Ok ( BootConfig { cmdline , kernel_file , initrd_file , // We can simply store original config since it doesn't support updates. description : cfg , } ) }
Creates the BootConfig based on a given configuration.
Creates the BootConfig based on a given configuration .
cfg
BootSourceConfig
cfg
BootSourceConfig