File tree Expand file tree Collapse file tree 2 files changed +23
-6
lines changed
inspecttypes/dockercompat Expand file tree Collapse file tree 2 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -773,7 +773,18 @@ func withInternalLabels(internalLabels internalLabels) (containerd.NewContainerO
773
773
}
774
774
775
775
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
+ }
777
788
}
778
789
779
790
hostConfigJSON , err := json .Marshal (hostConfigLabel )
Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ type HostConfig struct {
162
162
ShmSize int64 // Size of /dev/shm in bytes. The size must be greater than 0.
163
163
Sysctls map [string ]string // List of Namespaced sysctls used for the container
164
164
Runtime string // Runtime to use with this container
165
- Devices []string // List of devices to map inside the container
165
+ Devices []DeviceMapping // List of devices to map inside the container
166
166
PidMode string // PID namespace to use for the container
167
167
Tmpfs map [string ]string `json:"Tmpfs,omitempty"` // List of tmpfs (mounts) used for the container
168
168
}
@@ -239,9 +239,15 @@ type DNSSettings struct {
239
239
}
240
240
241
241
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
245
251
}
246
252
247
253
type CPUSettings struct {
@@ -485,7 +491,7 @@ func ContainerFromNative(n *native.Container) (*Container, error) {
485
491
}
486
492
c .Config .Hostname = hostname
487
493
488
- c .HostConfig .Devices = hostConfigLabel .DeviceMapping
494
+ c .HostConfig .Devices = hostConfigLabel .Devices
489
495
490
496
var pidMode string
491
497
if n .Labels [labels .PIDContainer ] != "" {
You can’t perform that action at this time.
0 commit comments