summaryrefslogtreecommitdiff
path: root/libpod/container_internal_linux.go
diff options
context:
space:
mode:
authorJake Correnti <jcorrenti13@gmail.com>2022-06-03 11:25:45 -0400
committerJake Correnti <jcorrenti13@gmail.com>2022-06-06 14:14:22 -0400
commit8533ea000459403a9a708fe01f875509ed22ffe1 (patch)
treec817ceeb84ab0682428db61ea12c3dceffe34bad /libpod/container_internal_linux.go
parentf5389dbb44d8d83c3af08b3b183c8e7805c99d88 (diff)
downloadpodman-8533ea000459403a9a708fe01f875509ed22ffe1.tar.gz
podman-8533ea000459403a9a708fe01f875509ed22ffe1.tar.bz2
podman-8533ea000459403a9a708fe01f875509ed22ffe1.zip
Privileged containers can now restart if the host devices change
If a privileged container is running, stops, and the devices on the host change, such as a USB device is unplugged, then a container would no longer start. Previously, the devices from the host were only being added to the container once: when the container was created. Now, this happens every time the container starts. I did this by adding a boolean to the container config that indicates whether to mount all of the devices or not, which can be set via an option. During spec generation, if the `MountAllDevices` option is set in the container config, all host devices are added to the container. Additionally, a couple of functions from `pkg/specgen/generate/config_linux.go` were moved into `pkg/util/utils_linux.go` as they were needed in multiple packages. Closes #13899 Signed-off-by: Jake Correnti <jcorrenti13@gmail.com>
Diffstat (limited to 'libpod/container_internal_linux.go')
-rw-r--r--libpod/container_internal_linux.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index e19d75deb..67f813547 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -407,6 +407,14 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
//nolint:staticcheck
g := generate.NewFromSpec(c.config.Spec)
+ // If the flag to mount all devices is set for a privileged container, add
+ // all the devices from the host's machine into the container
+ if c.config.MountAllDevices {
+ if err := util.AddPrivilegedDevices(&g); err != nil {
+ return nil, err
+ }
+ }
+
// If network namespace was requested, add it now
if c.config.CreateNetNS {
if c.config.PostConfigureNetNS {