Skip to content

Commit 7cac871

Browse files
committed
fix deviceMapping
Signed-off-by: Arjun Raja Yogidas <[email protected]>
1 parent 92a7a5b commit 7cac871

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

pkg/cmd/container/create.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,18 @@ func withInternalLabels(internalLabels internalLabels) (containerd.NewContainerO
773773
}
774774

775775
if len(internalLabels.deviceMapping) > 0 {
776-
hostConfigLabel.DeviceMapping = internalLabels.deviceMapping
776+
for i := range internalLabels.deviceMapping {
777+
var deviceMapping dockercompat.DeviceMapping
778+
device := internalLabels.deviceMapping[i]
779+
devPath, conPath, mode, err := ParseDevice(device)
780+
if err != nil {
781+
return nil, err
782+
}
783+
deviceMapping.CgroupPermissions = mode
784+
deviceMapping.PathInContainer = conPath
785+
deviceMapping.PathOnHost = devPath
786+
hostConfigLabel.Devices = append(hostConfigLabel.Devices, deviceMapping)
787+
}
777788
}
778789

779790
hostConfigJSON, err := json.Marshal(hostConfigLabel)

pkg/inspecttypes/dockercompat/dockercompat.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,15 @@ type DNSSettings struct {
239239
}
240240

241241
type HostConfigLabel struct {
242-
BlkioWeight uint16
243-
CidFile string
244-
DeviceMapping []string
242+
BlkioWeight uint16
243+
CidFile string
244+
Devices []DeviceMapping
245+
}
246+
247+
type DeviceMapping struct {
248+
PathOnHost string
249+
PathInContainer string
250+
CgroupPermissions string
245251
}
246252

247253
type CPUSettings struct {

0 commit comments

Comments
 (0)