The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6758
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
From 4b668a92723290a84256630fea0d7276ff58a179 Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Thu, 23 Jan 2020 19:15:05 +0000 Subject: [PATCH] lxd/storage/drivers/driver/dir: Adds HostPath support Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/storage/drivers/driver_dir.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lxd/storage/drivers/driver_dir.go b/lxd/storage/drivers/driver_dir.go index b894b1de99..027cee0b3f 100644 --- a/lxd/storage/drivers/driver_dir.go +++ b/lxd/storage/drivers/driver_dir.go @@ -50,24 +50,26 @@ func (d *dir) Create() error { d.config["source"] = GetPoolMountPath(d.name) } - if !shared.PathExists(d.config["source"]) { - return fmt.Errorf("Source path '%s' doesn't exist", d.config["source"]) + sourcePath := shared.HostPath(d.config["source"]) + + if !shared.PathExists(sourcePath) { + return fmt.Errorf("Source path '%s' doesn't exist", sourcePath) } // Check that if within LXD_DIR, we're at our expected spot. - cleanSource := filepath.Clean(d.config["source"]) + cleanSource := filepath.Clean(sourcePath) if strings.HasPrefix(cleanSource, shared.VarPath()) && cleanSource != GetPoolMountPath(d.name) { - return fmt.Errorf("Source path '%s' is within the LXD directory", d.config["source"]) + return fmt.Errorf("Source path '%s' is within the LXD directory", cleanSource) } // Check that the path is currently empty. - isEmpty, err := shared.PathIsEmpty(d.config["source"]) + isEmpty, err := shared.PathIsEmpty(sourcePath) if err != nil { return err } if !isEmpty { - return fmt.Errorf("Source path '%s' isn't empty", d.config["source"]) + return fmt.Errorf("Source path '%s' isn't empty", sourcePath) } return nil @@ -103,19 +105,20 @@ func (d *dir) Update(changedConfig map[string]string) error { // Mount mounts the storage pool. func (d *dir) Mount() (bool, error) { path := GetPoolMountPath(d.name) + sourcePath := shared.HostPath(d.config["source"]) // Check if we're dealing with an external mount. - if d.config["source"] == path { + if sourcePath == path { return false, nil } // Check if already mounted. - if sameMount(d.config["source"], path) { + if sameMount(sourcePath, path) { return false, nil } // Setup the bind-mount. - err := TryMount(d.config["source"], path, "none", unix.MS_BIND, "") + err := TryMount(sourcePath, path, "none", unix.MS_BIND, "") if err != nil { return false, err }
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel