[pve-devel] [PATCH storage] lvmthin: activate base volumes

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Mar 14 16:21:39 CET 2016


create_base() uses '-ky' to prevent base images from being
activated by default, similar to snapshots. This means we
need to activate them like snapshots with the '-K' option.
---
Without this you cannot clone template VMs with disks on LVM-thin.

On a related note: We need to special-case the cloning of a VM onto
thin storage (lvmthin and perhaps zvol, rbd...) since
`qemu-img convert` will write over the entire volume making lvm-thin
as target for a clone effectively pointless.

 PVE/Storage/LvmThinPlugin.pm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/PVE/Storage/LvmThinPlugin.pm b/PVE/Storage/LvmThinPlugin.pm
index c8b48f0..c834a22 100644
--- a/PVE/Storage/LvmThinPlugin.pm
+++ b/PVE/Storage/LvmThinPlugin.pm
@@ -209,6 +209,9 @@ sub activate_volume {
 	my $snapvol = "snap_${volname}_$snapname";
 	my $cmd = ['/sbin/lvchange', '-ay', '-K', "$vg/$snapvol"];
 	run_command($cmd, errmsg => "activate_volume '$vg/$snapvol' error");
+    } elsif ($volname =~ /^base-/) {
+	my $cmd = ['/sbin/lvchange', '-ay', '-K', "$vg/$volname"];
+	run_command($cmd, errmsg => "activate_volume '$vg/$volname' error");
     } else {
 	# other volumes are active by default
     }
@@ -224,6 +227,9 @@ sub deactivate_volume {
 	my $snapvol = "snap_${volname}_$snapname";
 	my $cmd = ['/sbin/lvchange', '-an', "$vg/$snapvol"];
 	run_command($cmd, errmsg => "deactivate_volume '$vg/$snapvol' error");
+    } elsif ($volname =~ /^base-/) {
+	my $cmd = ['/sbin/lvchange', '-an', "$vg/$volname"];
+	run_command($cmd, errmsg => "deactivate_volume '$vg/$volname' error");
     } else {
 	# other volumes are kept active
     }
-- 
2.1.4





More information about the pve-devel mailing list