diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-07-20 12:31:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-20 12:31:32 -0400 |
commit | 7944bca4681893971ad6bda4ade4e1b3470b9559 (patch) | |
tree | a829606b854c78edccd041f6d911580c24b5356e /libpod/container_internal.go | |
parent | d433e5612409f9e2207b11b017b1101631a7971b (diff) | |
parent | 85db3f09bff68efb0a8509f7470b61604aefb447 (diff) | |
download | podman-7944bca4681893971ad6bda4ade4e1b3470b9559.tar.gz podman-7944bca4681893971ad6bda4ade4e1b3470b9559.tar.bz2 podman-7944bca4681893971ad6bda4ade4e1b3470b9559.zip |
Merge pull request #1104 from rhatdan/mounting
Let containers/storage keep track of mounts
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r-- | libpod/container_internal.go | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 38099c6ac..55fd7369d 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -753,9 +753,9 @@ func (c *Container) mountStorage() (err error) { mountPoint := c.config.Rootfs if mountPoint == "" { - mountPoint, err = c.runtime.storageService.MountContainerImage(c.ID()) + mountPoint, err = c.mount() if err != nil { - return errors.Wrapf(err, "error mounting storage for container %s", c.ID()) + return err } } c.state.Mounted = true @@ -796,8 +796,7 @@ func (c *Container) cleanupStorage() error { return nil } - // Also unmount storage - if _, err := c.runtime.storageService.UnmountContainerImage(c.ID()); err != nil { + if err := c.unmount(); err != nil { // If the container has already been removed, warn but don't // error // We still want to be able to kick the container out of the @@ -807,7 +806,7 @@ func (c *Container) cleanupStorage() error { return nil } - return errors.Wrapf(err, "error unmounting container %s root filesystem", c.ID()) + return err } c.state.Mountpoint = "" @@ -1285,3 +1284,22 @@ func (c *Container) setupOCIHooks(ctx context.Context, config *spec.Spec) (exten return manager.Hooks(config, c.Spec().Annotations, len(c.config.UserVolumes) > 0) } + +// mount mounts the container's root filesystem +func (c *Container) mount() (string, error) { + mountPoint, err := c.runtime.storageService.MountContainerImage(c.ID()) + if err != nil { + return "", errors.Wrapf(err, "error mounting storage for container %s", c.ID()) + } + return mountPoint, nil +} + +// unmount unmounts the container's root filesystem +func (c *Container) unmount() error { + // Also unmount storage + if _, err := c.runtime.storageService.UnmountContainerImage(c.ID()); err != nil { + return errors.Wrapf(err, "error unmounting container %s root filesystem", c.ID()) + } + + return nil +} |