summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-06-07 15:48:36 -0400
committerGitHub <noreply@github.com>2022-06-07 15:48:36 -0400
commitfef40e2ad384ec6e5e604b7e11e5cbb25ac7c304 (patch)
tree75ac9c7c375cb420432da7f79080e56b44e4de52 /libpod
parentf459c197bdce6c6d6056c7214ce186f360599c94 (diff)
parent8533ea000459403a9a708fe01f875509ed22ffe1 (diff)
downloadpodman-fef40e2ad384ec6e5e604b7e11e5cbb25ac7c304.tar.gz
podman-fef40e2ad384ec6e5e604b7e11e5cbb25ac7c304.tar.bz2
podman-fef40e2ad384ec6e5e604b7e11e5cbb25ac7c304.zip
Merge pull request #14483 from jakecorrenti/restart-privelaged-containers-after-host-device-change
Privileged containers can now restart if the host devices change
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_config.go3
-rw-r--r--libpod/container_internal_linux.go8
-rw-r--r--libpod/options.go14
3 files changed, 25 insertions, 0 deletions
diff --git a/libpod/container_config.go b/libpod/container_config.go
index 30b84adcf..6558f3c89 100644
--- a/libpod/container_config.go
+++ b/libpod/container_config.go
@@ -412,6 +412,9 @@ type ContainerMiscConfig struct {
InitContainerType string `json:"init_container_type,omitempty"`
// PasswdEntry specifies arbitrary data to append to a file.
PasswdEntry string `json:"passwd_entry,omitempty"`
+ // MountAllDevices is an option to indicate whether a privileged container
+ // will mount all the host's devices
+ MountAllDevices bool `json:"mountAllDevices"`
}
// InfraInherit contains the compatible options inheritable from the infra container
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 0056b8e86..b298014df 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -438,6 +438,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 {
diff --git a/libpod/options.go b/libpod/options.go
index 4b6803c3f..8b3b07efa 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -2174,3 +2174,17 @@ func WithPasswdEntry(passwdEntry string) CtrCreateOption {
return nil
}
}
+
+// WithMountAllDevices sets the option to mount all of a privileged container's
+// host devices
+func WithMountAllDevices() CtrCreateOption {
+ return func(ctr *Container) error {
+ if ctr.valid {
+ return define.ErrCtrFinalized
+ }
+
+ ctr.config.MountAllDevices = true
+
+ return nil
+ }
+}