fix #5301: convert added volume disks to base image for templates

This will automatically convert imported volume disks and newly
allocated VM volume disks (i.e. no efidisks, tpmstate disks, cloudinit
images, etc.) to a base volume, if the VM is a template.

Previously, this required a user to manually convert the
imported/allocated disk with `qm template --disk <disk>`.

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

View File

@ -461,6 +461,11 @@ my sub create_disks : prototype($$$$$$$$$$) {
'skip-config-update' => 1,
},
);
# change imported disk to a base volume in case the VM is a template
$dst_volid = PVE::Storage::vdisk_create_base($storecfg, $dst_volid)
if PVE::QemuConfig->is_template($conf);
push @$vollist, $dst_volid;
}
}
@ -490,6 +495,10 @@ my sub create_disks : prototype($$$$$$$$$$) {
$volid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid, "raw", undef, $size);
} else {
$volid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid, $fmt, undef, $size);
# change created disk to a base volume in case the VM is a template
$volid = PVE::Storage::vdisk_create_base($storecfg, $volid)
if PVE::QemuConfig->is_template($conf);
}
push @$vollist, $volid;
$disk->{file} = $volid;