mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-08-02 21:49:42 +00:00
check if base volumes are unused before deleting a template
we only checked if a vm had in use base disks when deleting them, at which point we do not stop to delete the vm even when a disk deletion fails, which means we could successfully delete the config and all not used (base) disks of a template, resulting in left over vm disks Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
8f943606bd
commit
5e67a2d2c4
@ -2111,6 +2111,23 @@ sub destroy_vm {
|
||||
|
||||
PVE::QemuConfig->check_lock($conf) if !$skiplock;
|
||||
|
||||
if ($conf->{template}) {
|
||||
# check if any base image is still used by a linked clone
|
||||
foreach_drive($conf, sub {
|
||||
my ($ds, $drive) = @_;
|
||||
|
||||
return if drive_is_cdrom($drive);
|
||||
|
||||
my $volid = $drive->{file};
|
||||
|
||||
return if !$volid || $volid =~ m|^/|;
|
||||
|
||||
die "base volume '$volid' is still in use by linked cloned\n"
|
||||
if PVE::Storage::volume_is_base_and_used($storecfg, $volid);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
# only remove disks owned by this VM
|
||||
foreach_drive($conf, sub {
|
||||
my ($ds, $drive) = @_;
|
||||
|
Loading…
Reference in New Issue
Block a user