mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-28 11:01:13 +00:00
fix #4201: delete cloud-init disk on rollback
If the config doesn't contain the cloud-init disk anymore after the rollback, we have to clean it up since otherwise no further disk can be attached unless the one still existing on the storage is deleted. Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com> Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
This commit is contained in:
parent
d74f424e39
commit
f9408af460
@ -498,7 +498,7 @@ sub __snapshot_rollback_get_unused {
|
||||
$class->foreach_volume($conf, sub {
|
||||
my ($vs, $volume) = @_;
|
||||
|
||||
return if PVE::QemuServer::drive_is_cdrom($volume);
|
||||
return if PVE::QemuServer::drive_is_cdrom($volume, 1);
|
||||
|
||||
my $found = 0;
|
||||
my $volid = $volume->{file};
|
||||
@ -507,7 +507,7 @@ sub __snapshot_rollback_get_unused {
|
||||
my ($ds, $drive) = @_;
|
||||
|
||||
return if $found;
|
||||
return if PVE::QemuServer::drive_is_cdrom($drive);
|
||||
return if PVE::QemuServer::drive_is_cdrom($drive, 1);
|
||||
|
||||
$found = 1
|
||||
if ($drive->{file} && $drive->{file} eq $volid);
|
||||
@ -519,6 +519,19 @@ sub __snapshot_rollback_get_unused {
|
||||
return $unused;
|
||||
}
|
||||
|
||||
sub add_unused_volume {
|
||||
my ($class, $config, $volid) = @_;
|
||||
|
||||
if ($volid =~ m/vm-\d+-cloudinit/) {
|
||||
print "found unused cloudinit disk '$volid', removing it\n";
|
||||
my $storecfg = PVE::Storage::config();
|
||||
PVE::Storage::vdisk_free($storecfg, $volid);
|
||||
return undef;
|
||||
} else {
|
||||
return $class->SUPER::add_unused_volume($config, $volid);
|
||||
}
|
||||
}
|
||||
|
||||
sub load_current_config {
|
||||
my ($class, $vmid, $current) = @_;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user