Skip to content

Commit 91183a4

Browse files
committed
pkg/specgen/generate: Fix adding host devices on FreeBSD
This was not working when emulating Linux container images on FreeBSD. The code to handle host devices on FreeBSD relies on the container having a devfs mount. Unfortunately, the Linux emulation code which adds this was happening after the host device handling. This changes the logic so that host device management happens after Linux emulation. Signed-off-by: Doug Rabson <[email protected]>
1 parent af91cae commit 91183a4

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

pkg/specgen/generate/oci_freebsd.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,6 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt
5050
g.AddAnnotation(key, val)
5151
}
5252

53-
// Devices
54-
var userDevices []spec.LinuxDevice
55-
if !s.IsPrivileged() {
56-
// add default devices from containers.conf
57-
for _, device := range rtc.Containers.Devices.Get() {
58-
if err = DevicesFromPath(&g, device, rtc); err != nil {
59-
return nil, err
60-
}
61-
}
62-
if len(compatibleOptions.HostDeviceList) > 0 && len(s.Devices) == 0 {
63-
userDevices = compatibleOptions.HostDeviceList
64-
} else {
65-
userDevices = s.Devices
66-
}
67-
// add default devices specified by caller
68-
for _, device := range userDevices {
69-
if err = DevicesFromPath(&g, device.Path, rtc); err != nil {
70-
return nil, err
71-
}
72-
}
73-
}
74-
7553
g.ClearProcessEnv()
7654
for name, val := range s.Env {
7755
g.AddProcessEnv(name, val)
@@ -134,6 +112,28 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt
134112
configSpec.Mounts = mounts
135113
}
136114

115+
// Devices
116+
var userDevices []spec.LinuxDevice
117+
if !s.IsPrivileged() {
118+
// add default devices from containers.conf
119+
for _, device := range rtc.Containers.Devices.Get() {
120+
if err = DevicesFromPath(&g, device, rtc); err != nil {
121+
return nil, err
122+
}
123+
}
124+
if len(compatibleOptions.HostDeviceList) > 0 && len(s.Devices) == 0 {
125+
userDevices = compatibleOptions.HostDeviceList
126+
} else {
127+
userDevices = s.Devices
128+
}
129+
// add default devices specified by caller
130+
for _, device := range userDevices {
131+
if err = DevicesFromPath(&g, device.Path, rtc); err != nil {
132+
return nil, err
133+
}
134+
}
135+
}
136+
137137
// BIND MOUNTS
138138
configSpec.Mounts = SupersedeUserMounts(mounts, configSpec.Mounts)
139139
// Process mounts to ensure correct options

0 commit comments

Comments
 (0)