summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/libpod/containers_create.go13
-rw-r--r--pkg/machine/qemu/machine.go3
-rw-r--r--pkg/specgen/specgen.go8
-rw-r--r--pkg/specgenutil/volumes.go2
-rw-r--r--pkg/util/mountOpts.go15
5 files changed, 39 insertions, 2 deletions
diff --git a/pkg/api/handlers/libpod/containers_create.go b/pkg/api/handlers/libpod/containers_create.go
index 61f437faf..4f9dc008d 100644
--- a/pkg/api/handlers/libpod/containers_create.go
+++ b/pkg/api/handlers/libpod/containers_create.go
@@ -18,7 +18,18 @@ import (
// the new container ID on success along with any warnings.
func CreateContainer(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
- var sg specgen.SpecGenerator
+ conf, err := runtime.GetConfigNoCopy()
+ if err != nil {
+ utils.InternalServerError(w, err)
+ return
+ }
+
+ // we have to set the default before we decode to make sure the correct default is set when the field is unset
+ sg := specgen.SpecGenerator{
+ ContainerNetworkConfig: specgen.ContainerNetworkConfig{
+ UseImageHosts: conf.Containers.NoHosts,
+ },
+ }
if err := json.NewDecoder(r.Body).Decode(&sg); err != nil {
utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go
index e849bae3f..321c1b99c 100644
--- a/pkg/machine/qemu/machine.go
+++ b/pkg/machine/qemu/machine.go
@@ -859,6 +859,9 @@ func (v *MachineVM) Remove(_ string, opts machine.RemoveOptions) (string, func()
return confirmationMessage, func() error {
for _, f := range files {
if err := os.Remove(f); err != nil {
+ if errors.Is(err, os.ErrNotExist) {
+ continue
+ }
logrus.Error(err)
}
}
diff --git a/pkg/specgen/specgen.go b/pkg/specgen/specgen.go
index 27d77af9f..dfac1d457 100644
--- a/pkg/specgen/specgen.go
+++ b/pkg/specgen/specgen.go
@@ -467,7 +467,13 @@ type ContainerNetworkConfig struct {
// UseImageHosts indicates that /etc/hosts should not be managed by
// Podman, and instead sourced from the image.
// Conflicts with HostAdd.
- UseImageHosts bool `json:"use_image_hosts,omitempty"`
+ // Do not set omitempty here, if this is false it should be set to not get
+ // the server default.
+ // Ideally this would be a pointer so we could differentiate between an
+ // explicitly false/true and unset (containers.conf default). However
+ // specgen is stable so we can not change this right now.
+ // TODO (5.0): change to pointer
+ UseImageHosts bool `json:"use_image_hosts"`
// HostAdd is a set of hosts which will be added to the container's
// /etc/hosts file.
// Conflicts with UseImageHosts.
diff --git a/pkg/specgenutil/volumes.go b/pkg/specgenutil/volumes.go
index 8a861077a..aa07de0af 100644
--- a/pkg/specgenutil/volumes.go
+++ b/pkg/specgenutil/volumes.go
@@ -523,6 +523,8 @@ func getNamedVolume(args []string) (*specgen.NamedVolume, error) {
for _, val := range args {
kv := strings.SplitN(val, "=", 2)
switch kv[0] {
+ case "volume-opt":
+ newVolume.Options = append(newVolume.Options, val)
case "ro", "rw":
if setRORW {
return nil, errors.Wrapf(optionArgError, "cannot pass 'ro' and 'rw' options more than once")
diff --git a/pkg/util/mountOpts.go b/pkg/util/mountOpts.go
index 2a0101791..e37394619 100644
--- a/pkg/util/mountOpts.go
+++ b/pkg/util/mountOpts.go
@@ -57,6 +57,9 @@ func ProcessOptions(options []string, isTmpfs bool, sourcePath string) ([]string
switch splitOpt[0] {
case "O":
foundOverlay = true
+ case "volume-opt":
+ // Volume-opt should be relayed and processed by driver.
+ newOptions = append(newOptions, opt)
case "exec", "noexec":
if foundExec {
return nil, errors.Wrapf(ErrDupeMntOption, "only one of 'noexec' and 'exec' can be used")
@@ -175,3 +178,15 @@ func ProcessOptions(options []string, isTmpfs bool, sourcePath string) ([]string
return newOptions, nil
}
+
+func ParseDriverOpts(option string) (string, string, error) {
+ token := strings.SplitN(option, "=", 2)
+ if len(token) != 2 {
+ return "", "", errors.Wrapf(ErrBadMntOption, "cannot parse driver opts")
+ }
+ opt := strings.SplitN(token[1], "=", 2)
+ if len(opt) != 2 {
+ return "", "", errors.Wrapf(ErrBadMntOption, "cannot parse driver opts")
+ }
+ return opt[0], opt[1], nil
+}