Revert "cos-gpu-installer: Ensure the gsp firmware is in firmware_class.path directory." This reverts commit 805d0f31a50b186ca5ca140f13ac72f5b64a0a3f. Reason for revert: Breaks boltvm suspend and resume nvidia preloading Change-Id: I2778ae06c2138fe2377905fedafbcad1584fcbe5 Reviewed-on: https://cos-review.googlesource.com/c/cos/tools/+/159724 Cloud-Build: 228075978874@cloudbuild.gserviceaccount.com <228075978874@cloudbuild.gserviceaccount.com> Reviewed-by: Miri Amarilio <mirilio@google.com> Reviewed-by: Kevin Berry <kpberry@google.com> Tested-by: Kevin Berry <kpberry@google.com>
diff --git a/src/cmd/cos_gpu_installer/internal/commands/install.go b/src/cmd/cos_gpu_installer/internal/commands/install.go index 2c2b5c1..4e2c81d 100644 --- a/src/cmd/cos_gpu_installer/internal/commands/install.go +++ b/src/cmd/cos_gpu_installer/internal/commands/install.go
@@ -397,7 +397,7 @@ cacher = installer.NewCacher(hostInstallDir, envReader.BuildNumber(), c.driverVersion) if isCached, isOpen, err := cacher.IsCached(); isCached && err == nil { log.V(2).Info("Found cached version, NOT building the drivers.") - if err := installer.ConfigureCachedInstallation(hostRootPath, hostInstallDir, kernelDriversPath, c.test, isOpen, c.noVerify, c.kernelModuleParams); err != nil { + if err := installer.ConfigureCachedInstallation(hostInstallDir, kernelDriversPath, c.test, isOpen, c.noVerify, c.kernelModuleParams); err != nil { c.logError(errors.Wrap(err, "failed to configure cached installation")) return subcommands.ExitFailure } @@ -555,7 +555,7 @@ } func installDriver(ctx context.Context, c *InstallCommand, cacher *installer.Cacher, envReader *cos.EnvReader, downloader *cos.GCSDownloader, kernelDriversPath string) error { - cleanup, err := installer.ConfigureDriverInstallationDirs(hostRootPath, c.hostInstallDir, envReader.KernelRelease(), envReader.Architecture()) + cleanup, err := installer.ConfigureDriverInstallationDirs(filepath.Join(hostRootPath, c.hostInstallDir), envReader.KernelRelease(), envReader.Architecture()) if err != nil { return errors.Wrap(err, "failed to configure GPU driver installation dirs") } @@ -642,7 +642,7 @@ } func installDriverPrebuiltModules(ctx context.Context, c *InstallCommand, cacher *installer.Cacher, envReader *cos.EnvReader, downloader *cos.GCSDownloader, kernelDriversPath string, gpuType deviceinfo.GPUType) error { - cleanup, err := installer.ConfigureDriverInstallationDirs(hostRootPath, c.hostInstallDir, envReader.KernelRelease(), envReader.Architecture()) + cleanup, err := installer.ConfigureDriverInstallationDirs(filepath.Join(hostRootPath, c.hostInstallDir), envReader.KernelRelease(), envReader.Architecture()) if err != nil { return errors.Wrap(err, "failed to configure GPU driver installation dirs") }
diff --git a/src/cmd/cos_gpu_installer/internal/installer/installer.go b/src/cmd/cos_gpu_installer/internal/installer/installer.go index 7a200c9..3c72f5e 100644 --- a/src/cmd/cos_gpu_installer/internal/installer/installer.go +++ b/src/cmd/cos_gpu_installer/internal/installer/installer.go
@@ -33,7 +33,6 @@ gpuInstallDirContainer = "/usr/local/nvidia" gpuDriverProtoBin = "gpu_driver_versions.bin" gpuFirmwareDirContainer = "/usr/local/nvidia/firmware/nvidia" - defaultGpuFirmwareDir = "/var/lib/nvidia/firmware/nvidia" templateGPUDriverFile = "gpu_%s_version" precompiledDriverTemplate = "NVIDIA-Linux-x86_64-%s-custom.run" defaultFilePermission = 0755 @@ -95,15 +94,12 @@ } // ConfigureCachedInstallation updates ldconfig and installs the cached GPU driver kernel modules. -func ConfigureCachedInstallation(hostRootPath, gpuInstallDirHost, kernelDriversPath string, test, kernelOpen, noVerify bool, moduleParameters modules.ModuleParameters) error { +func ConfigureCachedInstallation(gpuInstallDirHost, kernelDriversPath string, test, kernelOpen, noVerify bool, moduleParameters modules.ModuleParameters) error { log.V(2).Info("Configuring cached driver installation") - gpuFirmwareDirHost := getGpuFirmwareDirHost(hostRootPath) + if err := createHostDirBindMount(gpuInstallDirHost, gpuInstallDirContainer); err != nil { return errors.Wrap(err, "failed to create driver installation dir") } - if err := createHostDirBindMount(gpuFirmwareDirHost, gpuFirmwareDirContainer); err != nil { - return errors.Wrap(err, "failed to create firmware installation dir") - } if err := updateContainerLdCache(); err != nil { return errors.Wrap(err, "failed to configure cached driver installation") } @@ -136,20 +132,15 @@ return installerFilename, nil } -// ConfigureDriverInstallationDirs configures GPU driver installation directories by creating mounts. -func ConfigureDriverInstallationDirs(hostRootPath string, gpuInstallDir, kernelRelease, arch string) (func(), error) { +// ConfigureDriverInstallationDirs configures GPU driver installation directories by creating +// mounts. +func ConfigureDriverInstallationDirs(gpuInstallDirHost, kernelRelease, arch string) (func(), error) { log.Info("Configuring driver installation directories") - gpuInstallDirHost := filepath.Join(hostRootPath, gpuInstallDir) - gpuFirmwareDirHost := getGpuFirmwareDirHost(hostRootPath) if err := createHostDirBindMount(gpuInstallDirHost, gpuInstallDirContainer); err != nil { return nil, errors.Wrap(err, "failed to create dirver installation dir") } - if err := createHostDirBindMount(gpuFirmwareDirHost, gpuFirmwareDirContainer); err != nil { - return nil, errors.Wrap(err, "failed to create firmware installation dir") - } - if err := createOverlayFS( "/usr/bin", gpuInstallDirContainer+"/bin", gpuInstallDirContainer+"/bin-workdir"); err != nil { return nil, errors.Wrap(err, "failed to create bin overlay") @@ -180,7 +171,7 @@ return func() { log.Info("Start to clean up mounts...") for _, path := range paths { - if err := syscall.Unmount(path, syscall.MNT_DETACH); err != nil { + if err := syscall.Unmount(path, 0); err != nil { log.Errorf("Failed to unmount %s: %v", path, err) } } @@ -697,20 +688,6 @@ return nil } -func getGpuFirmwareDirHost(hostRootPath string) string { - gpuFirmwareDirHost := filepath.Join(hostRootPath, defaultGpuFirmwareDir) // Default to the host path - content, err := os.ReadFile("/sys/module/firmware_class/parameters/path") - if err != nil { - log.Warningf("Failed to read firmware path from /sys/module/firmware_class/parameters/path: %v, using default %s", err, gpuFirmwareDirHost) - } else { - pathFromFile := strings.TrimSpace(string(content)) - // The path from sysfs is the base, NVIDIA firmware is in an 'nvidia' subdirectory - gpuFirmwareDirHost = filepath.Join(hostRootPath, pathFromFile, "nvidia") - log.Infof("Using host firmware path from /sys/module/firmware_class/parameters/path: %s", gpuFirmwareDirHost) - } - return gpuFirmwareDirHost -} - func GetLoadedNVIDIAKernelModuleVersion(versionFilePath string) string { log.V(2).Infof("Attempting to read version from: %s", versionFilePath) content, err := os.ReadFile(versionFilePath)