pub fn from_json(
        config_json: &str,
        firecracker_version: &str,
    ) -> std::result::Result<Self, Error> {
        let vmm_config: VmmConfig = serde_json::from_slice::<VmmConfig>(config_json.as_bytes())
            .map_err(|_| Error::InvalidJson)?;

        if let Some(logger) = vmm_config.logger {
            init_logger(logger, firecracker_version).map_err(Error::Logger)?;
        }

        if let Some(metrics) = vmm_config.metrics {
            init_metrics(metrics).map_err(Error::Metrics)?;
        }

        let mut resources: Self = Self::default();
        if let Some(machine_config) = vmm_config.machine_config {
            resources
                .set_vm_config(machine_config)
                .map_err(Error::VmConfig)?;
        }
        resources
            .set_boot_source(vmm_config.boot_source)
            .map_err(Error::BootSource)?;
        for drive_config in vmm_config.block_devices.into_iter() {
            resources
                .set_block_device(drive_config)
                .map_err(Error::BlockDevice)?;
        }
        for net_config in vmm_config.net_devices.into_iter() {
            resources
                .set_net_device(net_config)
                .map_err(Error::NetDevice)?;
        }
        if let Some(vsock_config) = vmm_config.vsock_device {
            resources.set_vsock_device(vsock_config);
        }
        Ok(resources)
    }
/// Configures Vmm resources as described by the `config_json` param.
Configures Vmm resources as described by the `config_json` param.
Configures Vmm resources as described by the ` config_json ` param .
pub fn from_json(
        config_json: &str,
        firecracker_version: &str,
    ) -> std::result::Result<Self, Error> {
        let vmm_config: VmmConfig = serde_json::from_slice::<VmmConfig>(config_json.as_bytes())
            .map_err(|_| Error::InvalidJson)?;
        if let Some(logger) = vmm_config.logger {
            init_logger(logger, firecracker_version).map_err(Error::Logger)?;
        }
        if let Some(metrics) = vmm_config.metrics {
            init_metrics(metrics).map_err(Error::Metrics)?;
        }
        let mut resources: Self = Self::default();
        if let Some(machine_config) = vmm_config.machine_config {
            resources
                .set_vm_config(machine_config)
                .map_err(Error::VmConfig)?;
        }
        resources
            .set_boot_source(vmm_config.boot_source)
            .map_err(Error::BootSource)?;
        for drive_config in vmm_config.block_devices.into_iter() {
            resources
                .set_block_device(drive_config)
                .map_err(Error::BlockDevice)?;
        }
        for net_config in vmm_config.net_devices.into_iter() {
            resources
                .set_net_device(net_config)
                .map_err(Error::NetDevice)?;
        }
        if let Some(vsock_config) = vmm_config.vsock_device {
            resources.set_vsock_device(vsock_config);
        }
        Ok(resources)
    }
pub fn from_json ( config_json : & str , firecracker_version : & str , ) -> std :: result :: Result < Self , Error > { let vmm_config : VmmConfig = serde_json :: from_slice :: < VmmConfig > ( config_json . as_bytes ( ) ) . map_err ( | _ | Error :: InvalidJson ) ? ; if let Some ( logger ) = vmm_config . logger { init_logger ( logger , firecracker_version ) . map_err ( Error :: Logger ) ? ; } if let Some ( metrics ) = vmm_config . metrics { init_metrics ( metrics ) . map_err ( Error :: Metrics ) ? ; } let mut resources : Self = Self :: default ( ) ; if let Some ( machine_config ) = vmm_config . machine_config { resources . set_vm_config ( machine_config ) . map_err ( Error :: VmConfig ) ? ; } resources . set_boot_source ( vmm_config . boot_source ) . map_err ( Error :: BootSource ) ? ; for drive_config in vmm_config . block_devices . into_iter ( ) { resources . set_block_device ( drive_config ) . map_err ( Error :: BlockDevice ) ? ; } for net_config in vmm_config . net_devices . into_iter ( ) { resources . set_net_device ( net_config ) . map_err ( Error :: NetDevice ) ? ; } if let Some ( vsock_config ) = vmm_config . vsock_device { resources . set_vsock_device ( vsock_config ) ; } Ok ( resources ) }
Configures Vmm resources as described by the `config_json` param.
Configures Vmm resources as described by the ` config_json ` param .
config_json
&str
firecracker_version
&str
config_json
&str
firecracker_version
&str