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

Method build_vm_launch_plan

crates/openshell-driver-vm/src/driver.rs:1530–1597  ·  view source on GitHub ↗
(
        &self,
        sandbox_id: &str,
        needs_qemu: bool,
        is_gpu: bool,
        gpu_bdf: Option<String>,
    )

Source from the content-addressed store, hash-verified

1528
1529 #[allow(clippy::result_large_err)]
1530 fn build_vm_launch_plan(
1531 &self,
1532 sandbox_id: &str,
1533 needs_qemu: bool,
1534 is_gpu: bool,
1535 gpu_bdf: Option<String>,
1536 ) -> Result<LaunchPlan, Status> {
1537 if !needs_qemu {
1538 return Ok(LaunchPlan {
1539 backend: VmBackend::Libkrun,
1540 vcpus: self.config.vcpus,
1541 mem_mib: self.config.mem_mib,
1542 required_backends: Vec::new(),
1543 required_backend_features: Vec::new(),
1544 kernel_profile: None,
1545 kernel_image: None,
1546 gpu_bdf: None,
1547 tap_device: None,
1548 guest_ip: None,
1549 host_ip: None,
1550 vsock_cid: None,
1551 guest_mac: None,
1552 gateway_port: None,
1553 guest_init_dropins: Vec::new(),
1554 env: Vec::new(),
1555 });
1556 }
1557
1558 let subnet = self
1559 .subnet_allocator
1560 .lock()
1561 .map_err(|e| Status::internal(format!("subnet allocator lock poisoned: {e}")))?
1562 .allocate(sandbox_id)
1563 .map_err(Status::failed_precondition)?;
1564 let vsock_cid = allocate_vsock_cid();
1565 let mac = mac_from_sandbox_id(sandbox_id);
1566 let mac_str = format!(
1567 "{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
1568 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]
1569 );
1570 let tap = tap_device_name(sandbox_id);
1571 let gateway_port = gateway_port_from_endpoint(&self.config.openshell_endpoint);
1572
1573 let (vcpus, mem_mib) = if is_gpu {
1574 (self.config.gpu_vcpus, self.config.gpu_mem_mib)
1575 } else {
1576 (self.config.vcpus, self.config.mem_mib)
1577 };
1578
1579 Ok(LaunchPlan {
1580 backend: VmBackend::Qemu,
1581 vcpus,
1582 mem_mib,
1583 required_backends: Vec::new(),
1584 required_backend_features: Vec::new(),
1585 kernel_profile: None,
1586 kernel_image: None,
1587 gpu_bdf,

Calls 5

allocate_vsock_cidFunction · 0.85
mac_from_sandbox_idFunction · 0.85
tap_device_nameFunction · 0.85
allocateMethod · 0.80