importdisk: convert imported volume disks to base images for templates

Automatically converts any imported volume disk to a base volume image
if the VM is a template and the volume was imported using the
"target-disk" option, as "unused" disks are not needed to be converted
as they won't be cloned with either linked nor full clones.

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
This commit is contained in:
Daniel Kral 2024-10-17 13:51:22 +02:00 committed by Thomas Lamprecht
parent 585ec70a2b
commit 60d7d9c748

View File

@ -624,7 +624,13 @@ __PACKAGE__->register_method ({
},
);
print "Successfully imported disk as '$drive_id:$volid'\n";
$vm_conf = PVE::QemuConfig->load_config($vmid);
# change imported _used_ disk to a base volume in case the VM is a template
PVE::QemuServer::template_create($vmid, $vm_conf, $drive_id)
if is_valid_drivename($drive_id) && PVE::QemuConfig->is_template($vm_conf);
print "$drive_id: successfully imported disk '$vm_conf->{$drive_id}'\n";
return;
}});