(
&self,
overlay_disk: &Path,
tls_paths: Option<&VmDriverTlsPaths>,
sandbox_token: Option<&str>,
preparation: OverlayPreparation,
)
| 1729 | } |
| 1730 | |
| 1731 | async fn prepare_runtime_overlay( |
| 1732 | &self, |
| 1733 | overlay_disk: &Path, |
| 1734 | tls_paths: Option<&VmDriverTlsPaths>, |
| 1735 | sandbox_token: Option<&str>, |
| 1736 | preparation: OverlayPreparation, |
| 1737 | ) -> Result<(), String> { |
| 1738 | let tls_materials = match tls_paths { |
| 1739 | Some(paths) => Some(read_guest_tls_materials(paths).await?), |
| 1740 | None => None, |
| 1741 | }; |
| 1742 | let sandbox_token = sandbox_token.map(str::to_string); |
| 1743 | let overlay_disk = overlay_disk.to_path_buf(); |
| 1744 | let overlay_size_bytes = self |
| 1745 | .config |
| 1746 | .overlay_disk_mib |
| 1747 | .checked_mul(1024 * 1024) |
| 1748 | .ok_or_else(|| { |
| 1749 | format!( |
| 1750 | "overlay disk size {} MiB is too large", |
| 1751 | self.config.overlay_disk_mib |
| 1752 | ) |
| 1753 | })?; |
| 1754 | |
| 1755 | let template_path = overlay_template_image(&self.config.state_dir, overlay_size_bytes); |
| 1756 | if !overlay_template_image_ready(&template_path, overlay_size_bytes).await? { |
| 1757 | let _cache_guard = self.image_cache_lock.lock().await; |
| 1758 | let template_path = template_path.clone(); |
| 1759 | tokio::task::spawn_blocking(move || { |
| 1760 | ensure_sandbox_overlay_template_image(&template_path, overlay_size_bytes) |
| 1761 | }) |
| 1762 | .await |
| 1763 | .map_err(|err| format!("overlay template preparation panicked: {err}"))??; |
| 1764 | } |
| 1765 | |
| 1766 | tokio::task::spawn_blocking(move || { |
| 1767 | prepare_sandbox_overlay_image( |
| 1768 | &template_path, |
| 1769 | &overlay_disk, |
| 1770 | tls_materials.as_ref(), |
| 1771 | sandbox_token.as_deref(), |
| 1772 | preparation, |
| 1773 | overlay_size_bytes, |
| 1774 | ) |
| 1775 | }) |
| 1776 | .await |
| 1777 | .map_err(|err| format!("overlay image preparation panicked: {err}"))? |
| 1778 | } |
| 1779 | |
| 1780 | fn resolved_sandbox_image(&self, sandbox: &Sandbox) -> Option<String> { |
| 1781 | requested_sandbox_image(sandbox) |
no test coverage detected