@@ -40,46 +40,32 @@ var requiredDriverStoreFiles = []string{
40
40
41
41
// newWSLDriverDiscoverer returns a Discoverer for WSL2 drivers.
42
42
func newWSLDriverDiscoverer (logger logger.Interface , driverRoot string , hookCreator discover.HookCreator , ldconfigPath string ) (discover.Discover , error ) {
43
- err := dxcore .Init ()
44
- if err != nil {
45
- return nil , fmt .Errorf ("failed to initialize dxcore: %v" , err )
43
+ if err := dxcore .Init (); err != nil {
44
+ return nil , fmt .Errorf ("failed to initialize dxcore: %w" , err )
46
45
}
47
46
defer func () {
48
47
if err := dxcore .Shutdown (); err != nil {
49
- logger .Warningf ("failed to shutdown dxcore: %v " , err )
48
+ logger .Warningf ("failed to shutdown dxcore: %w " , err )
50
49
}
51
50
}()
52
51
53
52
driverStorePaths := dxcore .GetDriverStorePaths ()
54
53
if len (driverStorePaths ) == 0 {
55
54
return nil , fmt .Errorf ("no driver store paths found" )
56
55
}
56
+ if len (driverStorePaths ) > 1 {
57
+ logger .Warningf ("Found multiple driver store paths: %v" , driverStorePaths )
58
+ }
57
59
logger .Infof ("Using WSL driver store paths: %v" , driverStorePaths )
58
60
59
- return newWSLDriverStoreDiscoverer (logger , driverRoot , hookCreator , ldconfigPath , driverStorePaths )
60
- }
61
-
62
- // newWSLDriverStoreDiscoverer returns a Discoverer for WSL2 drivers in the driver store associated with a dxcore adapter.
63
- func newWSLDriverStoreDiscoverer (logger logger.Interface , driverRoot string , hookCreator discover.HookCreator , ldconfigPath string , driverStorePaths []string ) (discover.Discover , error ) {
64
- var searchPaths []string
65
- seen := make (map [string ]bool )
66
- for _ , path := range driverStorePaths {
67
- if seen [path ] {
68
- continue
69
- }
70
- searchPaths = append (searchPaths , path )
71
- }
72
- if len (searchPaths ) > 1 {
73
- logger .Warningf ("Found multiple driver store paths: %v" , searchPaths )
74
- }
75
- searchPaths = append (searchPaths , "/usr/lib/wsl/lib" )
61
+ driverStorePaths = append (driverStorePaths , "/usr/lib/wsl/lib" )
76
62
77
- libraries := discover .NewMounts (
63
+ driverStoreMounts := discover .NewMounts (
78
64
logger ,
79
65
lookup .NewFileLocator (
80
66
lookup .WithLogger (logger ),
81
67
lookup .WithSearchPaths (
82
- searchPaths ... ,
68
+ driverStorePaths ... ,
83
69
),
84
70
lookup .WithCount (1 ),
85
71
),
@@ -89,14 +75,14 @@ func newWSLDriverStoreDiscoverer(logger logger.Interface, driverRoot string, hoo
89
75
90
76
symlinkHook := nvidiaSMISimlinkHook {
91
77
logger : logger ,
92
- mountsFrom : libraries ,
78
+ mountsFrom : driverStoreMounts ,
93
79
hookCreator : hookCreator ,
94
80
}
95
81
96
- ldcacheHook , _ := discover .NewLDCacheUpdateHook (logger , libraries , hookCreator , ldconfigPath )
82
+ ldcacheHook , _ := discover .NewLDCacheUpdateHook (logger , driverStoreMounts , hookCreator , ldconfigPath )
97
83
98
84
d := discover .Merge (
99
- libraries ,
85
+ driverStoreMounts ,
100
86
symlinkHook ,
101
87
ldcacheHook ,
102
88
)
0 commit comments