github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/pkg/specgen/config_linux.go (about) 1 package specgen 2 3 //func createBlockIO() (*spec.LinuxBlockIO, error) { 4 // var ret *spec.LinuxBlockIO 5 // bio := &spec.LinuxBlockIO{} 6 // if c.Resources.BlkioWeight > 0 { 7 // ret = bio 8 // bio.Weight = &c.Resources.BlkioWeight 9 // } 10 // if len(c.Resources.BlkioWeightDevice) > 0 { 11 // var lwds []spec.LinuxWeightDevice 12 // ret = bio 13 // for _, i := range c.Resources.BlkioWeightDevice { 14 // wd, err := ValidateweightDevice(i) 15 // if err != nil { 16 // return ret, errors.Wrapf(err, "invalid values for blkio-weight-device") 17 // } 18 // wdStat, err := GetStatFromPath(wd.Path) 19 // if err != nil { 20 // return ret, errors.Wrapf(err, "error getting stat from path %q", wd.Path) 21 // } 22 // lwd := spec.LinuxWeightDevice{ 23 // Weight: &wd.Weight, 24 // } 25 // lwd.Major = int64(unix.Major(wdStat.Rdev)) 26 // lwd.Minor = int64(unix.Minor(wdStat.Rdev)) 27 // lwds = append(lwds, lwd) 28 // } 29 // bio.WeightDevice = lwds 30 // } 31 // if len(c.Resources.DeviceReadBps) > 0 { 32 // ret = bio 33 // readBps, err := makeThrottleArray(c.Resources.DeviceReadBps, bps) 34 // if err != nil { 35 // return ret, err 36 // } 37 // bio.ThrottleReadBpsDevice = readBps 38 // } 39 // if len(c.Resources.DeviceWriteBps) > 0 { 40 // ret = bio 41 // writeBpds, err := makeThrottleArray(c.Resources.DeviceWriteBps, bps) 42 // if err != nil { 43 // return ret, err 44 // } 45 // bio.ThrottleWriteBpsDevice = writeBpds 46 // } 47 // if len(c.Resources.DeviceReadIOps) > 0 { 48 // ret = bio 49 // readIOps, err := makeThrottleArray(c.Resources.DeviceReadIOps, iops) 50 // if err != nil { 51 // return ret, err 52 // } 53 // bio.ThrottleReadIOPSDevice = readIOps 54 // } 55 // if len(c.Resources.DeviceWriteIOps) > 0 { 56 // ret = bio 57 // writeIOps, err := makeThrottleArray(c.Resources.DeviceWriteIOps, iops) 58 // if err != nil { 59 // return ret, err 60 // } 61 // bio.ThrottleWriteIOPSDevice = writeIOps 62 // } 63 // return ret, nil 64 //} 65 66 //func makeThrottleArray(throttleInput []string, rateType int) ([]spec.LinuxThrottleDevice, error) { 67 // var ( 68 // ltds []spec.LinuxThrottleDevice 69 // t *throttleDevice 70 // err error 71 // ) 72 // for _, i := range throttleInput { 73 // if rateType == bps { 74 // t, err = validateBpsDevice(i) 75 // } else { 76 // t, err = validateIOpsDevice(i) 77 // } 78 // if err != nil { 79 // return []spec.LinuxThrottleDevice{}, err 80 // } 81 // ltdStat, err := GetStatFromPath(t.path) 82 // if err != nil { 83 // return ltds, errors.Wrapf(err, "error getting stat from path %q", t.path) 84 // } 85 // ltd := spec.LinuxThrottleDevice{ 86 // Rate: t.rate, 87 // } 88 // ltd.Major = int64(unix.Major(ltdStat.Rdev)) 89 // ltd.Minor = int64(unix.Minor(ltdStat.Rdev)) 90 // ltds = append(ltds, ltd) 91 // } 92 // return ltds, nil 93 //}