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

Method new_with_extensions

crates/openshell-driver-vm/src/driver.rs:411–487  ·  view source on GitHub ↗
(
        config: VmDriverConfig,
        lifecycle_extensions: LifecycleExtensionRegistry,
    )

Source from the content-addressed store, hash-verified

409 }
410
411 pub async fn new_with_extensions(
412 config: VmDriverConfig,
413 lifecycle_extensions: LifecycleExtensionRegistry,
414 ) -> Result<Self, String> {
415 lifecycle_extensions
416 .validate()
417 .map_err(|err| err.message().to_string())?;
418 config.validate_sandbox_identity()?;
419 if config.openshell_endpoint.trim().is_empty() {
420 return Err("openshell endpoint is required".to_string());
421 }
422 validate_openshell_endpoint(&config.openshell_endpoint)?;
423 let _ = config.tls_paths()?;
424
425 #[cfg(target_os = "linux")]
426 if config.gpu_enabled {
427 check_gpu_privileges()?;
428 tokio::task::spawn_blocking(crate::cleanup_stale_tap_interfaces)
429 .await
430 .map_err(|e| format!("cleanup stale TAP interfaces panicked: {e}"))?;
431 }
432
433 let state_root = sandboxes_root_dir(&config.state_dir);
434 create_private_dir_all(&state_root).await.map_err(|err| {
435 format!(
436 "failed to create state dir '{}': {err}",
437 state_root.display()
438 )
439 })?;
440 let image_cache_root = image_cache_root_dir(&config.state_dir);
441 tokio::fs::create_dir_all(&image_cache_root)
442 .await
443 .map_err(|err| {
444 format!(
445 "failed to create state dir '{}': {err}",
446 image_cache_root.display()
447 )
448 })?;
449
450 let launcher_bin = if let Some(path) = config.launcher_bin.clone() {
451 path
452 } else {
453 std::env::current_exe()
454 .map_err(|err| format!("failed to resolve vm driver executable: {err}"))?
455 };
456
457 let gpu_inventory = if config.gpu_enabled {
458 let sysfs = SysfsRoot::system();
459 let inventory = GpuInventory::new(sysfs, &config.state_dir);
460 tracing::info!(
461 gpu_count = inventory.gpu_count(),
462 "GPU inventory initialized"
463 );
464 Some(Arc::new(std::sync::Mutex::new(inventory)))
465 } else {
466 None
467 };
468

Callers

nothing calls this directly

Calls 11

check_gpu_privilegesFunction · 0.85
sandboxes_root_dirFunction · 0.85
create_private_dir_allFunction · 0.85
image_cache_root_dirFunction · 0.85
messageMethod · 0.80
tls_pathsMethod · 0.80
validateMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected