Merge pull request #27545 from dfr/freebsd-linux-devices

pkg/specgen/generate: Fix adding host devices on FreeBSD
This commit is contained in:
Brent Baude
2025-11-20 13:59:31 -06:00
committed by GitHub

View File

@@ -50,28 +50,6 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt
g.AddAnnotation(key, val) g.AddAnnotation(key, val)
} }
// Devices
var userDevices []spec.LinuxDevice
if !s.IsPrivileged() {
// add default devices from containers.conf
for _, device := range rtc.Containers.Devices.Get() {
if err = DevicesFromPath(&g, device, rtc); err != nil {
return nil, err
}
}
if len(compatibleOptions.HostDeviceList) > 0 && len(s.Devices) == 0 {
userDevices = compatibleOptions.HostDeviceList
} else {
userDevices = s.Devices
}
// add default devices specified by caller
for _, device := range userDevices {
if err = DevicesFromPath(&g, device.Path, rtc); err != nil {
return nil, err
}
}
}
g.ClearProcessEnv() g.ClearProcessEnv()
for name, val := range s.Env { for name, val := range s.Env {
g.AddProcessEnv(name, val) g.AddProcessEnv(name, val)
@@ -134,6 +112,28 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt
configSpec.Mounts = mounts configSpec.Mounts = mounts
} }
// Devices
var userDevices []spec.LinuxDevice
if !s.IsPrivileged() {
// add default devices from containers.conf
for _, device := range rtc.Containers.Devices.Get() {
if err = DevicesFromPath(&g, device, rtc); err != nil {
return nil, err
}
}
if len(compatibleOptions.HostDeviceList) > 0 && len(s.Devices) == 0 {
userDevices = compatibleOptions.HostDeviceList
} else {
userDevices = s.Devices
}
// add default devices specified by caller
for _, device := range userDevices {
if err = DevicesFromPath(&g, device.Path, rtc); err != nil {
return nil, err
}
}
}
// BIND MOUNTS // BIND MOUNTS
configSpec.Mounts = SupersedeUserMounts(mounts, configSpec.Mounts) configSpec.Mounts = SupersedeUserMounts(mounts, configSpec.Mounts)
// Process mounts to ensure correct options // Process mounts to ensure correct options