(
&self,
bootstrap_root_disk: &Path,
prep_disk: &Path,
run_dir: &Path,
)
| 2449 | } |
| 2450 | |
| 2451 | async fn run_image_prep_vm( |
| 2452 | &self, |
| 2453 | bootstrap_root_disk: &Path, |
| 2454 | prep_disk: &Path, |
| 2455 | run_dir: &Path, |
| 2456 | ) -> Result<(), Status> { |
| 2457 | let console_output = run_dir.join("image-prep-console.log"); |
| 2458 | let mut command = Command::new(&self.launcher_bin); |
| 2459 | command.kill_on_drop(true); |
| 2460 | command.stdin(Stdio::null()); |
| 2461 | command.stdout(Stdio::inherit()); |
| 2462 | command.stderr(Stdio::inherit()); |
| 2463 | command.arg("--internal-run-vm"); |
| 2464 | command.arg("--vm-root-disk").arg(bootstrap_root_disk); |
| 2465 | command.arg("--vm-overlay-disk").arg(prep_disk); |
| 2466 | command.arg("--vm-exec").arg(sandbox_guest_init_path()); |
| 2467 | command.arg("--vm-workdir").arg("/"); |
| 2468 | command.arg("--vm-console-output").arg(&console_output); |
| 2469 | command.arg("--vm-vcpus").arg(self.config.vcpus.to_string()); |
| 2470 | command |
| 2471 | .arg("--vm-mem-mib") |
| 2472 | .arg(self.config.mem_mib.to_string()); |
| 2473 | command |
| 2474 | .arg("--vm-krun-log-level") |
| 2475 | .arg(self.config.krun_log_level.to_string()); |
| 2476 | command |
| 2477 | .arg("--vm-env") |
| 2478 | .arg(format!("OPENSHELL_VM_INIT_MODE={IMAGE_PREP_INIT_MODE}")); |
| 2479 | |
| 2480 | let mut child = command |
| 2481 | .spawn() |
| 2482 | .map_err(|err| Status::internal(format!("failed to run image-prep vm: {err}")))?; |
| 2483 | let status = child |
| 2484 | .wait() |
| 2485 | .await |
| 2486 | .map_err(|err| Status::internal(format!("failed to wait for image-prep vm: {err}")))?; |
| 2487 | if status.success() { |
| 2488 | return Ok(()); |
| 2489 | } |
| 2490 | let console = tokio::fs::read_to_string(&console_output) |
| 2491 | .await |
| 2492 | .unwrap_or_default(); |
| 2493 | Err(Status::failed_precondition(format!( |
| 2494 | "image-prep vm exited with status {status}: {console}" |
| 2495 | ))) |
| 2496 | } |
| 2497 | |
| 2498 | fn publish_prepared_cache_hit( |
| 2499 | &self, |
no test coverage detected