[lxc-devel] [lxd/master] storage: Use HostPath for dir/btrfs

stgraber on Github lxc-bot at linuxcontainers.org
Tue Dec 5 06:21:09 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 526 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20171205/563da8ef/attachment.bin>
-------------- next part --------------
From 215e8425299923da9ae1712ff70039d81cad97cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 5 Dec 2017 01:20:12 -0500
Subject: [PATCH] storage: Use HostPath for dir/btrfs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

dir and btrfs allow the bind-mounting of an existing fs path, as this
can be outside of the snap's mount namespace, we need to wrap those
paths using shared.HostPath.

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/storage_btrfs.go | 6 +++---
 lxd/storage_dir.go   | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lxd/storage_btrfs.go b/lxd/storage_btrfs.go
index 4b4bf37b8..20a2dd45b 100644
--- a/lxd/storage_btrfs.go
+++ b/lxd/storage_btrfs.go
@@ -108,7 +108,7 @@ func (s *storageBtrfs) StoragePoolCreate() error {
 	s.pool.Config["volatile.initial_source"] = s.pool.Config["source"]
 
 	isBlockDev := false
-	source := s.pool.Config["source"]
+	source := shared.HostPath(s.pool.Config["source"])
 	if source == "" {
 		source = filepath.Join(shared.VarPath("disks"), fmt.Sprintf("%s.img", s.pool.Name))
 		s.pool.Config["source"] = source
@@ -259,7 +259,7 @@ func (s *storageBtrfs) StoragePoolCreate() error {
 func (s *storageBtrfs) StoragePoolDelete() error {
 	logger.Infof("Deleting BTRFS storage pool \"%s\".", s.pool.Name)
 
-	source := s.pool.Config["source"]
+	source := shared.HostPath(s.pool.Config["source"])
 	if source == "" {
 		return fmt.Errorf("no \"source\" property found for the storage pool")
 	}
@@ -324,7 +324,7 @@ func (s *storageBtrfs) StoragePoolDelete() error {
 func (s *storageBtrfs) StoragePoolMount() (bool, error) {
 	logger.Debugf("Mounting BTRFS storage pool \"%s\".", s.pool.Name)
 
-	source := s.pool.Config["source"]
+	source := shared.HostPath(s.pool.Config["source"])
 	if source == "" {
 		return false, fmt.Errorf("no \"source\" property found for the storage pool")
 	}
diff --git a/lxd/storage_dir.go b/lxd/storage_dir.go
index 3f59d3ec0..78e562fa7 100644
--- a/lxd/storage_dir.go
+++ b/lxd/storage_dir.go
@@ -56,7 +56,7 @@ func (s *storageDir) StoragePoolCreate() error {
 
 	poolMntPoint := getStoragePoolMountPoint(s.pool.Name)
 
-	source := s.pool.Config["source"]
+	source := shared.HostPath(s.pool.Config["source"])
 	if source == "" {
 		source = filepath.Join(shared.VarPath("storage-pools"), s.pool.Name)
 		s.pool.Config["source"] = source
@@ -128,7 +128,7 @@ func (s *storageDir) StoragePoolCreate() error {
 func (s *storageDir) StoragePoolDelete() error {
 	logger.Infof("Deleting DIR storage pool \"%s\".", s.pool.Name)
 
-	source := s.pool.Config["source"]
+	source := shared.HostPath(s.pool.Config["source"])
 	if source == "" {
 		return fmt.Errorf("no \"source\" property found for the storage pool")
 	}
@@ -163,7 +163,7 @@ func (s *storageDir) StoragePoolDelete() error {
 }
 
 func (s *storageDir) StoragePoolMount() (bool, error) {
-	source := s.pool.Config["source"]
+	source := shared.HostPath(s.pool.Config["source"])
 	if source == "" {
 		return false, fmt.Errorf("no \"source\" property found for the storage pool")
 	}


More information about the lxc-devel mailing list