MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / build_vm_launch_config

Function build_vm_launch_config

crates/openshell-driver-vm/src/main.rs:467–514  ·  view source on GitHub ↗
(args: &Args)

Source from the content-addressed store, hash-verified

465}
466
467fn build_vm_launch_config(args: &Args) -> std::result::Result<VmLaunchConfig, String> {
468 let root_disk = args
469 .vm_root_disk
470 .clone()
471 .ok_or_else(|| "--vm-root-disk is required in internal VM mode".to_string())?;
472 let overlay_disk = args
473 .vm_overlay_disk
474 .clone()
475 .ok_or_else(|| "--vm-overlay-disk is required in internal VM mode".to_string())?;
476 let image_disk = args.vm_image_disk.clone();
477 let exec_path = args
478 .vm_exec
479 .clone()
480 .ok_or_else(|| "--vm-exec is required in internal VM mode".to_string())?;
481 let console_output = args
482 .vm_console_output
483 .clone()
484 .ok_or_else(|| "--vm-console-output is required in internal VM mode".to_string())?;
485
486 let backend = match args.vm_backend.as_deref() {
487 Some("qemu") => VmBackend::Qemu,
488 Some("libkrun") | None => VmBackend::Libkrun,
489 Some(other) => return Err(format!("unknown VM backend: {other}")),
490 };
491
492 Ok(VmLaunchConfig {
493 root_disk,
494 overlay_disk,
495 image_disk,
496 kernel_image: args.vm_kernel_image.clone(),
497 vcpus: args.vm_vcpus,
498 mem_mib: args.vm_mem_mib,
499 exec_path,
500 args: Vec::new(),
501 env: args.vm_env.clone(),
502 workdir: args.vm_workdir.clone(),
503 log_level: args.vm_krun_log_level,
504 console_output,
505 backend,
506 gpu_bdf: args.vm_gpu_bdf.clone(),
507 tap_device: args.vm_tap_device.clone(),
508 guest_ip: args.vm_guest_ip.clone(),
509 host_ip: args.vm_host_ip.clone(),
510 vsock_cid: args.vm_vsock_cid,
511 guest_mac: args.vm_guest_mac.clone(),
512 gateway_port: args.vm_gateway_port,
513 })
514}
515
516#[cfg(target_os = "macos")]
517fn maybe_reexec_internal_vm_with_runtime_env() -> Result<()> {

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected