(sandbox: &Sandbox)
| 3198 | |
| 3199 | #[allow(clippy::result_large_err)] |
| 3200 | fn vm_gpu_device_id(sandbox: &Sandbox) -> Result<Option<String>, Status> { |
| 3201 | let Some(spec) = sandbox.spec.as_ref() else { |
| 3202 | return Ok(None); |
| 3203 | }; |
| 3204 | let gpu_device_ids = VmSandboxDriverConfig::from_sandbox(sandbox) |
| 3205 | .map_err(Status::invalid_argument)? |
| 3206 | .gpu_device_ids |
| 3207 | .unwrap_or_default(); |
| 3208 | let gpu_requirements = driver_gpu_requirements(spec.resource_requirements.as_ref()); |
| 3209 | validate_specific_gpu_device_request( |
| 3210 | gpu_requirements, |
| 3211 | &gpu_device_ids, |
| 3212 | "driver_config.gpu_device_ids", |
| 3213 | ) |
| 3214 | .map_err(Status::invalid_argument)?; |
| 3215 | if gpu_device_ids.len() > 1 { |
| 3216 | return Err(Status::invalid_argument( |
| 3217 | "vm driver currently supports at most one gpu_device_ids entry", |
| 3218 | )); |
| 3219 | } |
| 3220 | |
| 3221 | Ok(gpu_requirements |
| 3222 | .is_some() |
| 3223 | .then(|| gpu_device_ids.into_iter().next().unwrap_or_default())) |
| 3224 | } |
| 3225 | |
| 3226 | #[allow(clippy::result_large_err)] |
| 3227 | fn validate_sandbox_id(sandbox_id: &str) -> Result<(), Status> { |
no test coverage detected