summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_config.go2
-rw-r--r--libpod/container_internal.go12
-rw-r--r--libpod/options.go11
3 files changed, 25 insertions, 0 deletions
diff --git a/libpod/container_config.go b/libpod/container_config.go
index 54d102a71..33ea731fd 100644
--- a/libpod/container_config.go
+++ b/libpod/container_config.go
@@ -153,6 +153,8 @@ type ContainerRootFSConfig struct {
Secrets []*ContainerSecret `json:"secrets,omitempty"`
// SecretPath is the secrets location in storage
SecretsPath string `json:"secretsPath"`
+ // StorageOpts to be used when creating rootfs
+ StorageOpts map[string]string `json:"storageOpts"`
// Volatile specifies whether the container storage can be optimized
// at the cost of not syncing all the dirty files in memory.
Volatile bool `json:"volatile,omitempty"`
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 43f5398a2..994ffeec7 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -445,6 +445,18 @@ func (c *Container) setupStorage(ctx context.Context) error {
},
LabelOpts: c.config.LabelOpts,
}
+
+ nopts := len(c.config.StorageOpts)
+ if nopts > 0 {
+ options.StorageOpt = make(map[string]string, nopts)
+ for _, opt := range c.config.StorageOpts {
+ split2 := strings.SplitN(opt, "=", 2)
+ if len(split2) > 2 {
+ return errors.Wrapf(define.ErrInvalidArg, "invalid storage options %q for %s", opt, c.ID())
+ }
+ options.StorageOpt[split2[0]] = split2[1]
+ }
+ }
if c.restoreFromCheckpoint && !c.config.Privileged {
// If restoring from a checkpoint, the root file-system
// needs to be mounted with the same SELinux labels as
diff --git a/libpod/options.go b/libpod/options.go
index 553af43fd..9762de67e 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -310,6 +310,17 @@ func WithCDI(devices []string) CtrCreateOption {
}
}
+// WithStorageOpts sets the devices to check for for CDI configuration.
+func WithStorageOpts(storageOpts map[string]string) CtrCreateOption {
+ return func(ctr *Container) error {
+ if ctr.valid {
+ return define.ErrCtrFinalized
+ }
+ ctr.config.StorageOpts = storageOpts
+ return nil
+ }
+}
+
// WithDefaultMountsFile sets the file to look at for default mounts (mainly
// secrets).
// Note we are not saving this in the database as it is for testing purposes