(
&self,
sandbox_id: &str,
is_gpu: bool,
gpu_bdf: Option<String>,
plan: &mut LaunchPlan,
)
| 1403 | |
| 1404 | #[allow(clippy::result_large_err)] |
| 1405 | fn configure_qemu_launch_plan( |
| 1406 | &self, |
| 1407 | sandbox_id: &str, |
| 1408 | is_gpu: bool, |
| 1409 | gpu_bdf: Option<String>, |
| 1410 | plan: &mut LaunchPlan, |
| 1411 | ) -> Result<(), Status> { |
| 1412 | plan.backend = VmBackend::Qemu; |
| 1413 | if is_gpu { |
| 1414 | plan.vcpus = self.config.gpu_vcpus; |
| 1415 | plan.mem_mib = self.config.gpu_mem_mib; |
| 1416 | } |
| 1417 | if plan.gpu_bdf.is_none() { |
| 1418 | plan.gpu_bdf = gpu_bdf; |
| 1419 | } |
| 1420 | if has_complete_qemu_network(plan) { |
| 1421 | return Ok(()); |
| 1422 | } |
| 1423 | |
| 1424 | let subnet = self |
| 1425 | .subnet_allocator |
| 1426 | .lock() |
| 1427 | .map_err(|e| Status::internal(format!("subnet allocator lock poisoned: {e}")))? |
| 1428 | .allocate(sandbox_id) |
| 1429 | .map_err(Status::failed_precondition)?; |
| 1430 | let mac = mac_from_sandbox_id(sandbox_id); |
| 1431 | plan.tap_device = Some(tap_device_name(sandbox_id)); |
| 1432 | plan.guest_ip = Some(subnet.guest_ip.to_string()); |
| 1433 | plan.host_ip = Some(subnet.host_ip.to_string()); |
| 1434 | plan.vsock_cid = Some(allocate_vsock_cid()); |
| 1435 | plan.guest_mac = Some(format!( |
| 1436 | "{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}", |
| 1437 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] |
| 1438 | )); |
| 1439 | plan.gateway_port = gateway_port_from_endpoint(&self.config.openshell_endpoint); |
| 1440 | Ok(()) |
| 1441 | } |
| 1442 | |
| 1443 | #[allow(clippy::result_large_err)] |
| 1444 | fn validate_launch_plan_backend(is_gpu: bool, plan: &LaunchPlan) -> Result<(), Status> { |
no test coverage detected