@@ -191,31 +191,42 @@ func (b *blkioController) readEntry(devices map[deviceKey]string, path, name str
191191}
192192
193193func createBlkioSettings (blkio * specs.LinuxBlockIO ) []blkioSettings {
194- settings := []blkioSettings {
195- {
196- name : "weight" ,
197- value : blkio .Weight ,
198- format : uintf ,
199- },
200- {
201- name : "leaf_weight" ,
202- value : blkio .LeafWeight ,
203- format : uintf ,
204- },
205- }
206- for _ , wd := range blkio .WeightDevice {
194+ settings := []blkioSettings {}
195+
196+ if blkio .Weight != nil {
207197 settings = append (settings ,
208198 blkioSettings {
209- name : "weight_device" ,
210- value : wd ,
211- format : weightdev ,
212- },
199+ name : "weight" ,
200+ value : blkio .Weight ,
201+ format : uintf ,
202+ })
203+ }
204+ if blkio .LeafWeight != nil {
205+ settings = append (settings ,
213206 blkioSettings {
214- name : "leaf_weight_device " ,
215- value : wd ,
216- format : weightleafdev ,
207+ name : "leaf_weight " ,
208+ value : blkio . LeafWeight ,
209+ format : uintf ,
217210 })
218211 }
212+ for _ , wd := range blkio .WeightDevice {
213+ if wd .Weight != nil {
214+ settings = append (settings ,
215+ blkioSettings {
216+ name : "weight_device" ,
217+ value : wd ,
218+ format : weightdev ,
219+ })
220+ }
221+ if wd .LeafWeight != nil {
222+ settings = append (settings ,
223+ blkioSettings {
224+ name : "leaf_weight_device" ,
225+ value : wd ,
226+ format : weightleafdev ,
227+ })
228+ }
229+ }
219230 for _ , t := range []struct {
220231 name string
221232 list []specs.LinuxThrottleDevice
@@ -265,12 +276,12 @@ func uintf(v interface{}) []byte {
265276
266277func weightdev (v interface {}) []byte {
267278 wd := v .(specs.LinuxWeightDevice )
268- return []byte (fmt .Sprintf ("%d:%d %d" , wd .Major , wd .Minor , wd .Weight ))
279+ return []byte (fmt .Sprintf ("%d:%d %d" , wd .Major , wd .Minor , * wd .Weight ))
269280}
270281
271282func weightleafdev (v interface {}) []byte {
272283 wd := v .(specs.LinuxWeightDevice )
273- return []byte (fmt .Sprintf ("%d:%d %d" , wd .Major , wd .Minor , wd .LeafWeight ))
284+ return []byte (fmt .Sprintf ("%d:%d %d" , wd .Major , wd .Minor , * wd .LeafWeight ))
274285}
275286
276287func throttleddev (v interface {}) []byte {
0 commit comments