[lxc-devel] [lxd/master] storage: Fix UsedBy for containers and images
stgraber on Github
lxc-bot at linuxcontainers.org
Wed Jul 12 22:06:20 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170712/938072c0/attachment.bin>
-------------- next part --------------
From b6ab338027ae54944e2489a7c061d368b89dd836 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 12 Jul 2017 18:05:47 -0400
Subject: [PATCH] storage: Fix UsedBy for containers and images
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/storage_volumes_utils.go | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/lxd/storage_volumes_utils.go b/lxd/storage_volumes_utils.go
index 0f039588f..fd1da3962 100644
--- a/lxd/storage_volumes_utils.go
+++ b/lxd/storage_volumes_utils.go
@@ -180,6 +180,22 @@ func storagePoolVolumeUpdate(d *Daemon, poolName string, volumeName string, volu
}
func storagePoolVolumeUsedByGet(d *Daemon, volumeName string, volumeTypeName string) ([]string, error) {
+ // Handle container volumes
+ if volumeTypeName == "container" {
+ cName, sName, snap := containerGetParentAndSnapshotName(volumeName)
+
+ if snap {
+ return []string{fmt.Sprintf("/%s/containers/%s/snapshots/%s", version.APIVersion, cName, sName)}, nil
+ }
+
+ return []string{fmt.Sprintf("/%s/containers/%s", version.APIVersion, cName)}, nil
+ }
+
+ // Handle image volumes
+ if volumeTypeName == "image" {
+ return []string{fmt.Sprintf("/%s/images/%s", version.APIVersion, volumeName)}, nil
+ }
+
// Look for containers using the interface
cts, err := dbContainersList(d.db, cTypeRegular)
if err != nil {
More information about the lxc-devel
mailing list