(&mut self)
| 2781 | } |
| 2782 | |
| 2783 | pub fn boot(&mut self) -> Result<()> { |
| 2784 | trace_scoped!("Vm::boot"); |
| 2785 | let current_state = self.state; |
| 2786 | if current_state == VmState::Paused { |
| 2787 | return self.resume().map_err(Error::Resume); |
| 2788 | } |
| 2789 | |
| 2790 | // We acquire all advisory disk image locks here and not on device creation |
| 2791 | // to enable live-migration without locking issues. |
| 2792 | self.device_manager |
| 2793 | .lock() |
| 2794 | .unwrap() |
| 2795 | .try_lock_disks() |
| 2796 | .map_err(Error::LockingError)?; |
| 2797 | |
| 2798 | let new_state = if self.stop_on_boot { |
| 2799 | VmState::BreakPoint |
| 2800 | } else { |
| 2801 | VmState::Running |
| 2802 | }; |
| 2803 | |
| 2804 | current_state.valid_transition(new_state)?; |
| 2805 | |
| 2806 | #[cfg(feature = "fw_cfg")] |
| 2807 | { |
| 2808 | let fw_cfg_enabled = self |
| 2809 | .config |
| 2810 | .lock() |
| 2811 | .unwrap() |
| 2812 | .payload |
| 2813 | .as_ref() |
| 2814 | .is_some_and(|p| p.fw_cfg_config.is_some()); |
| 2815 | if fw_cfg_enabled { |
| 2816 | let fw_cfg_config = self |
| 2817 | .config |
| 2818 | .lock() |
| 2819 | .unwrap() |
| 2820 | .payload |
| 2821 | .as_ref() |
| 2822 | .map(|p| p.fw_cfg_config.clone()) |
| 2823 | .unwrap_or_default() |
| 2824 | .ok_or(Error::VmMissingConfig)?; |
| 2825 | #[cfg(target_arch = "x86_64")] |
| 2826 | let kvm_sev_snp_enabled = { |
| 2827 | #[cfg(feature = "sev_snp")] |
| 2828 | { |
| 2829 | self.config.lock().unwrap().is_sev_snp_enabled() |
| 2830 | && self.hypervisor.hypervisor_type() == hypervisor::HypervisorType::Kvm |
| 2831 | } |
| 2832 | #[cfg(not(feature = "sev_snp"))] |
| 2833 | { |
| 2834 | false |
| 2835 | } |
| 2836 | }; |
| 2837 | |
| 2838 | Self::populate_fw_cfg( |
| 2839 | &fw_cfg_config, |
| 2840 | &self.device_manager, |
no test coverage detected