[pve-devel] [PATCH v2 container 3/4] fix #1904: convert to base image when moving a volume of a template

Fabian Ebner f.ebner at proxmox.com
Thu Mar 19 13:37:35 CET 2020


Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 src/PVE/API2/LXC.pm | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 205743c..c62955a 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -1818,7 +1818,13 @@ __PACKAGE__->register_method({
 		    my $source_storage = PVE::Storage::parse_volume_id($old_volid);
 		    my $movelimit = PVE::Storage::get_bandwidth_limit('move', [$source_storage, $storage], $bwlimit);
 		    $new_volid = PVE::LXC::copy_volume($mpdata, $vmid, $storage, $storage_cfg, $conf, undef, $movelimit);
-		    $mpdata->{volume} = $new_volid;
+		    if (PVE::LXC::Config->is_template($conf)) {
+			PVE::Storage::activate_volumes($storage_cfg, [ $new_volid ]);
+			my $template_volid = PVE::Storage::vdisk_create_base($storage_cfg, $new_volid);
+			$mpdata->{volume} = $template_volid;
+		    } else {
+			$mpdata->{volume} = $new_volid;
+		    }
 
 		    PVE::LXC::Config->lock_config($vmid, sub {
 			my $digest = $conf->{digest};
-- 
2.20.1





More information about the pve-devel mailing list