[pve-devel] [PATCH v3 container 4/5] fix #1904: convert to base image when moving a volume of a template
Fabian Ebner
f.ebner at proxmox.com
Mon Mar 23 12:18:53 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 c724118..307fd90 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