fix 1046: add non-snapshotted disks as unused

This commit is contained in:
Fabian Grünbichler 2016-07-04 13:04:14 +02:00 committed by Wolfgang Bumiller
parent ffc0bacfa5
commit c4a54ed5f1

View File

@ -264,6 +264,35 @@ sub __snapshot_rollback_vm_start {
PVE::QemuServer::vm_start($storecfg, $vmid, $statefile, undef, undef, undef, $forcemachine); PVE::QemuServer::vm_start($storecfg, $vmid, $statefile, undef, undef, undef, $forcemachine);
} }
sub __snapshot_rollback_get_unused {
my ($class, $conf, $snap) = @_;
my $unused = [];
$class->__snapshot_foreach_volume($conf, sub {
my ($vs, $volume) = @_;
return if PVE::QemuServer::drive_is_cdrom($volume);
my $found = 0;
my $volid = $volume->{file};
$class->__snapshot_foreach_volume($snap, sub {
my ($ds, $drive) = @_;
return if $found;
return if PVE::QemuServer::drive_is_cdrom($drive);
$found = 1
if ($drive->{file} && $drive->{file} eq $volid);
});
push @$unused, $volid if !$found;
});
return $unused;
}
sub __snapshot_foreach_volume { sub __snapshot_foreach_volume {
my ($class, $conf, $func) = @_; my ($class, $conf, $func) = @_;