@@ -76,32 +76,31 @@ func (l *nvcdilib) newDriverVersionDiscoverer() (discover.Discover, error) {
7676
7777// NewDriverLibraryDiscoverer creates a discoverer for the libraries associated with the specified driver version.
7878func (l * nvcdilib ) NewDriverLibraryDiscoverer (version string , libcudaSoParentDirPath string ) (discover.Discover , error ) {
79- libraryPaths , err := getVersionLibs ( l . logger , l . driver , version )
79+ versionSuffixLibraryMounts , err := l . getVersionSuffixDriverLibraryMounts ( version )
8080 if err != nil {
81- return nil , fmt .Errorf ("failed to get libraries for driver version: %v" , err )
81+ return nil , err
82+ }
83+ explicitLibraryMounts , err := l .getExplicitDriverLibraryMounts ()
84+ if err != nil {
85+ return nil , err
8286 }
8387
84- libraries := discover .NewMounts (
85- l .logger ,
86- lookup .NewFileLocator (
87- lookup .WithLogger (l .logger ),
88- lookup .WithRoot (l .driver .Root ),
89- ),
90- l .driver .Root ,
91- libraryPaths ,
88+ libraries := discover .Merge (
89+ versionSuffixLibraryMounts ,
90+ explicitLibraryMounts ,
9291 )
9392
9493 var discoverers []discover.Discover
9594
9695 driverDotSoSymlinksDiscoverer := discover .WithDriverDotSoSymlinks (
9796 l .logger ,
9897 libraries ,
99- version ,
98+ // Since we don't only match version suffixes, we now need to match on wildcards.
99+ "" ,
100100 l .hookCreator ,
101101 )
102102 discoverers = append (discoverers , driverDotSoSymlinksDiscoverer )
103103
104- // TODO: The following should use the version directly.
105104 cudaCompatLibHookDiscoverer := discover .NewCUDACompatHookDiscoverer (l .logger , l .hookCreator , version )
106105 discoverers = append (discoverers , cudaCompatLibHookDiscoverer )
107106
@@ -126,6 +125,59 @@ func (l *nvcdilib) NewDriverLibraryDiscoverer(version string, libcudaSoParentDir
126125 return d , nil
127126}
128127
128+ func (l * nvcdilib ) getVersionSuffixDriverLibraryMounts (version string ) (discover.Discover , error ) {
129+ versionSuffixLibraryPaths , err := getVersionLibs (l .logger , l .driver , version )
130+ if err != nil {
131+ return nil , fmt .Errorf ("failed to get libraries for driver version: %v" , err )
132+ }
133+
134+ mounts := discover .NewMounts (
135+ l .logger ,
136+ lookup .NewFileLocator (
137+ lookup .WithLogger (l .logger ),
138+ lookup .WithRoot (l .driver .Root ),
139+ ),
140+ l .driver .Root ,
141+ versionSuffixLibraryPaths ,
142+ )
143+
144+ return mounts , nil
145+ }
146+
147+ func (l * nvcdilib ) getExplicitDriverLibraryMounts () (discover.Discover , error ) {
148+ // List of explicit libraries to locate
149+ // TODO(ArangoGutierrez): we should load the version of the libraries from
150+ // the sandboxutils-filelist or have a way to allow users to specify the
151+ // libraries to mount from the config file.
152+ explicitLibraries := []string {
153+ "libEGL.so.1.1.0" ,
154+ "libGL.so.1.7.0" ,
155+ "libGLESv1_CM.so.1.2.0" ,
156+ "libGLESv2.so.2.1.0" ,
157+ "libGLX.so.0" ,
158+ "libGLdispatch.so.0" ,
159+ "libOpenCL.so.1.0.0" ,
160+ "libOpenGL.so.0" ,
161+ "libnvidia-api.so.1" ,
162+ "libnvidia-egl-xcb.so.1.0.0" ,
163+ "libnvidia-egl-xlib.so.1.0.0" ,
164+ }
165+
166+ driverLibraryLocator , err := l .driver .DriverLibraryLocator ()
167+ if err != nil {
168+ return nil , fmt .Errorf ("failed to get driver library locator: %w" , err )
169+ }
170+ mounts := discover .NewMounts (
171+ l .logger ,
172+ driverLibraryLocator ,
173+ l .driver .Root ,
174+ explicitLibraries ,
175+ )
176+
177+ return mounts , nil
178+
179+ }
180+
129181func getUTSRelease () (string , error ) {
130182 utsname := & unix.Utsname {}
131183 if err := unix .Uname (utsname ); err != nil {
0 commit comments