]>
git.proxmox.com Git - pve-storage.git/blob - PVE/Storage/LvmThinPlugin.pm
1 package PVE
::Storage
::LvmThinPlugin
;
6 use PVE
::Tools
qw(run_command trim);
7 use PVE
::Storage
::Plugin
;
8 use PVE
::JSONSchema
qw(get_standard_option);
12 use base
qw(PVE::Storage::LVMPlugin);
20 content
=> [ {images
=> 1, rootdir
=> 1}, { images
=> 1, rootdir
=> 1}],
27 description
=> "LVM thin pool LV name.",
28 type
=> 'string', format
=> 'pve-storage-vgname',
35 thinpool
=> { fixed
=> 1 },
36 vgname
=> { fixed
=> 1 },
37 nodes
=> { optional
=> 1 },
38 disable
=> { optional
=> 1 },
39 content
=> { optional
=> 1 },
44 my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
46 die "unsupported format '$fmt'" if $fmt ne 'raw';
48 die "illegal name '$name' - sould be 'vm-$vmid-*'\n"
49 if $name && $name !~ m/^vm-$vmid-/;
55 my ($class, $storeid, $scfg, $volname, $isBase) = @_;
57 my $vg = $scfg->{vgname
};
58 my $cmd = ['/sbin/lvremove', '-f', "$vg/$volname"];
59 run_command
($cmd, errmsg
=> "lvremove '$vg/$volname' error");
65 my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
71 my ($class, $storeid, $scfg, $cache) = @_;
73 my $lvname = "$scfg->{vgname}/$scfg->{thinpool}";
75 my $cmd = ['/sbin/lvs', '--separator', ':', '--noheadings', '--units', 'b',
76 '--unbuffered', '--nosuffix', '--options',
77 'vg_name,lv_name,lv_size,data_percent,metadata_percent,snap_percent', $lvname];
82 run_command
($cmd, outfunc
=> sub {
87 my ($vg, $lv, $size, $data_percent, $meta_percent, $snap_percent) = split(':', $line);
89 return if !$vg || $vg ne $scfg->{vgname
};
90 return if !$lv || $lv ne $scfg->{thinpool
};
97 $used = int((($data_percent + $meta_percent + $snap_percent) * $size)/100)
100 return ($total, $total - $used, $used, 1) if $total;
105 sub activate_volume
{
106 my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
109 sub deactivate_volume
{
110 my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
114 my ($class, $scfg, $storeid, $volname, $size, $running) = @_;
118 sub volume_has_feature
{
119 my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_;
122 copy
=> { base
=> 1, current
=> 1},
125 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) =
126 $class->parse_volname($volname);
132 $key = $isBase ?
'base' : 'current';
134 return 1 if $features->{$feature}->{$key};