]> git.proxmox.com Git - pve-storage.git/commitdiff
add tagged_only option to LVM storage
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Tue, 21 Jun 2016 13:13:45 +0000 (15:13 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 29 Jun 2016 09:42:03 +0000 (11:42 +0200)
to filter volumes by the 'pve-vm-ID' tag, which is set on
all volumes created via the PVE storage layer.

PVE/Storage/LVMPlugin.pm

index d776e437e8e343c126226f13dcf8fb8799e82e75..673d1cc403e831d256de4e310cfc510534c51b46 100644 (file)
@@ -140,6 +140,7 @@ sub lvm_list_volumes {
            lv_type => $lv_type,
        };
        $d->{pool_lv} = $pool_lv if $pool_lv;
+       $d->{tags} = $tags if $tags;
 
        if ($lv_type eq 't') {
            $data_percent ||= 0;
@@ -183,6 +184,10 @@ sub properties {
            description => "Wipe throughput (cstream -t parameter value).",
            type => 'string',
        },
+       tagged_only => {
+           description => "Only use logical volumes tagged with 'pve-vm-ID'.",
+           type => 'boolean',
+       }
     };
 }
 
@@ -196,6 +201,7 @@ sub options {
         saferemove_throughput => { optional => 1 },
        content => { optional => 1 },
         base => { fixed => 1, optional => 1 },
+       tagged_only => { optional => 1 },
     };
 }
 
@@ -339,6 +345,12 @@ sub free_image {
     return undef;
 }
 
+my $check_tags = sub {
+    my ($tags) = @_;
+
+    return defined($tags) && $tags =~ /(^|,)pve-vm-\d+(,|$)/;
+};
+
 sub list_images {
     my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
 
@@ -357,6 +369,8 @@ sub list_images {
 
            my $info = $dat->{$volname};
 
+           next if $scfg->{tagged_only} && !&$check_tags($info->{tags});
+
            next if $info->{lv_type} ne '-';
 
            my $volid = "$storeid:$volname";