[pve-devel] [PATCH 3/4] add get_vm_volumes sub

Alexandre Derumier aderumier at odiso.com
Mon Aug 24 10:13:20 CEST 2015


similar to qemu-server, return only volids with storeid

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 src/PVE/LXC.pm | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 1f14146..8a84284 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1957,4 +1957,28 @@ sub mountpoint_mount {
     warn $@ if $@;
 }
 
+sub get_vm_volumes {
+    my ($conf, $excludems) = @_;
+
+    my $vollist = [];
+
+    PVE::LXC::foreach_mountpoint($conf, sub {
+	my ($ms, $mountpoint) = @_;
+
+	return if $excludems &&  $ms eq $excludems;
+
+	my $volid = $mountpoint->{volume};
+
+        return if !$volid || $volid =~ m|^/|;
+
+        my ($sid, $volname) = PVE::Storage::parse_volume_id($volid, 1);
+        return if !$sid;
+
+        push @$vollist, $volid;
+
+    });
+
+    return $vollist;
+}
+
 1;
-- 
2.1.4




More information about the pve-devel mailing list