@@ -113,19 +113,25 @@ func New(infolib info.Interface, nvmllib nvml.Interface, devicelib device.Interf
113113 return nil , err
114114 }
115115
116- c .cdilibs = make (map [string ]nvcdi.SpecGenerator )
117-
118- c .cdilibs ["gpu" ], err = nvcdi .New (
119- nvcdi .WithInfoLib (c .infolib ),
120- nvcdi .WithNvmlLib (c .nvmllib ),
116+ commonOptions := []nvcdi.Option {
121117 nvcdi .WithDeviceLib (c .devicelib ),
118+ nvcdi .WithDevRoot (c .devRoot ),
119+ nvcdi .WithDriverRoot (c .driverRoot ),
120+ nvcdi .WithInfoLib (c .infolib ),
122121 nvcdi .WithLogger (c .logger ),
123122 nvcdi .WithNVIDIACDIHookPath (c .nvidiaCTKPath ),
124- nvcdi .WithDriverRoot (c .driverRoot ),
125- nvcdi .WithDevRoot (c .devRoot ),
126- nvcdi .WithDeviceNamers (deviceNamer ),
123+ nvcdi .WithNvmlLib (c .nvmllib ),
127124 nvcdi .WithVendor (c .vendor ),
128- nvcdi .WithClass ("gpu" ),
125+ }
126+
127+ c .cdilibs = make (map [string ]nvcdi.SpecGenerator )
128+
129+ c .cdilibs ["gpu" ], err = nvcdi .New (
130+ append (
131+ commonOptions ,
132+ nvcdi .WithDeviceNamers (deviceNamer ),
133+ nvcdi .WithClass ("gpu" ),
134+ )... ,
129135 )
130136 if err != nil {
131137 return nil , fmt .Errorf ("failed to create nvcdi library: %v" , err )
@@ -147,13 +153,10 @@ func New(infolib info.Interface, nvmllib nvml.Interface, devicelib device.Interf
147153
148154 for _ , mode := range c .additionalModes {
149155 lib , err := nvcdi .New (
150- nvcdi .WithInfoLib (c .infolib ),
151- nvcdi .WithLogger (c .logger ),
152- nvcdi .WithNVIDIACDIHookPath (c .nvidiaCTKPath ),
153- nvcdi .WithDriverRoot (c .driverRoot ),
154- nvcdi .WithDevRoot (c .devRoot ),
155- nvcdi .WithVendor (c .vendor ),
156- nvcdi .WithMode (mode ),
156+ append (
157+ commonOptions ,
158+ nvcdi .WithMode (mode ),
159+ )... ,
157160 )
158161 if err != nil {
159162 return nil , fmt .Errorf ("failed to create nvcdi library: %v" , err )
0 commit comments