--- Begin Message ---
Allow to resize the underlay vm volume
Signed-off-by: Alexandre Derumier <alexandre.derum...@groupe-cyllene.com>
---
src/PVE/Storage.pm | 18 ++++++++++++++++++
src/PVE/Storage/LVMQcow2Plugin.pm | 12 ++++++++++++
src/PVE/Storage/Plugin.pm | 7 +++++++
3 files changed, 37 insertions(+)
diff --git a/src/PVE/Storage.pm b/src/PVE/Storage.pm
index 385150e..8e0f8f1 100755
--- a/src/PVE/Storage.pm
+++ b/src/PVE/Storage.pm
@@ -317,6 +317,24 @@ sub volume_resize {
}
}
+sub volume_underlay_resize {
+ my ($cfg, $volid, $size) = @_;
+
+ my $padding = (1024 - $size % 1024) % 1024;
+ $size = $size + $padding;
+
+ my ($storeid, $volname) = parse_volume_id($volid, 1);
+ if ($storeid) {
+ my $scfg = storage_config($cfg, $storeid);
+ my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
+ return $plugin->volume_underlay_resize($scfg, $storeid, $volname,
$size);
+ } elsif ($volid =~ m|^(/.+)$| && -e $volid) {
+ die "resize file/device '$volid' is not possible\n";
+ } else {
+ die "unable to parse volume ID '$volid'\n";
+ }
+}
+
sub volume_rollback_is_possible {
my ($cfg, $volid, $snap, $blockers) = @_;
diff --git a/src/PVE/Storage/LVMQcow2Plugin.pm
b/src/PVE/Storage/LVMQcow2Plugin.pm
index 2a56c46..3b98eeb 100644
--- a/src/PVE/Storage/LVMQcow2Plugin.pm
+++ b/src/PVE/Storage/LVMQcow2Plugin.pm
@@ -191,6 +191,18 @@ sub volume_snapshot_delete {
return PVE::Storage::Plugin::volume_snapshot_delete($class, $scfg,
$storeid, $volname, $snap, $running);
}
+sub volume_underlay_resize {
+ my ($class, $scfg, $storeid, $volname, $size) = @_;
+
+ my $path = $class->filesystem_path($scfg, $volname);
+
+ $size = ($size/1024/1024) . "M";
+ my $cmd = ['/sbin/lvextend', '-L', $size, $path];
+
+ #don't use global cluster lock here, use on native local lvm lock
+ run_command($cmd, errmsg => "error resizing volume '$path'");
+}
+
sub volume_has_feature {
my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_;
diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index 6444390..e930102 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -1071,6 +1071,13 @@ sub volume_resize {
return undef;
}
+sub volume_underlay_resize {
+ my ($class, $scfg, $storeid, $volname, $size) = @_;
+
+ # do nothing by default
+ return undef;
+}
+
sub volume_snapshot {
my ($class, $scfg, $storeid, $volname, $snap) = @_;
--
2.39.2
--- End Message ---
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel