[lxc-devel] [lxd/master] Storage: Create snapshot mount path before mounting
tomponline on Github
lxc-bot at linuxcontainers.org
Mon Apr 6 16:03:27 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 361 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200406/527d2c41/attachment.bin>
-------------- next part --------------
From e16ef85a171ff6959e30db579a44a4d44f883c5b Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Mon, 6 Apr 2020 17:02:49 +0100
Subject: [PATCH] lxd/storage: Create snapshot mount path before mounting
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/storage/backend_lxd.go | 6 ++++++
lxd/storage/drivers/volume.go | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/lxd/storage/backend_lxd.go b/lxd/storage/backend_lxd.go
index 4621290a7f..03c4f55486 100644
--- a/lxd/storage/backend_lxd.go
+++ b/lxd/storage/backend_lxd.go
@@ -1888,6 +1888,12 @@ func (b *lxdBackend) MountInstanceSnapshot(inst instance.Instance, op *operation
// Get the volume.
vol := b.newVolume(volType, contentType, volStorageName, rootDiskConf)
+ // Create mount directory if missing.
+ err = vol.EnsureMountPath()
+ if err != nil {
+ return false, err
+ }
+
return b.driver.MountVolumeSnapshot(vol, op)
}
diff --git a/lxd/storage/drivers/volume.go b/lxd/storage/drivers/volume.go
index e52f7ad685..4b3acc8d65 100644
--- a/lxd/storage/drivers/volume.go
+++ b/lxd/storage/drivers/volume.go
@@ -164,6 +164,12 @@ func (v Volume) MountTask(task func(mountPath string, op *operations.Operation)
if isSnap {
unlock := locking.Lock(v.pool, string(v.volType), v.name)
+ // Create mount directory if missing.
+ err := v.EnsureMountPath()
+ if err != nil {
+ return err
+ }
+
ourMount, err := v.driver.MountVolumeSnapshot(v, op)
if err != nil {
unlock()
More information about the lxc-devel
mailing list