check base image use count inside vdisk_free

To make it work with all storage types.
This commit is contained in:
Dietmar Maurer
2013-02-01 06:55:39 +01:00
parent c803c3963c
commit 32437ed279
8 changed files with 27 additions and 24 deletions

View File

@ -520,7 +520,26 @@ sub vdisk_free {
# lock shared storage
$plugin->cluster_lock_storage($storeid, $scfg->{shared}, undef, sub {
my $cleanup_worker = $plugin->free_image($storeid, $scfg, $volname);
my ($vtype, $name, $vmid, undef, undef, $isBase) =
$plugin->parse_volname($volname);
if ($isBase) {
my $vollist = $plugin->list_images($storeid, $scfg);
foreach my $info (@$vollist) {
my (undef, $tmpvolname) = parse_volume_id($info->{volid});
my (undef, undef, undef, $basename, $basevmid) =
$plugin->parse_volname($tmpvolname);
if ($basename && $basevmid == $vmid && $basename eq $name) {
die "base volume '$volname' is still in use " .
"(use by '$tmpvolname')\n";
}
}
}
my $cleanup_worker = $plugin->free_image($storeid, $scfg, $volname, $isBase);
});
return if !$cleanup_worker;