]> git.proxmox.com Git - pve-storage.git/commitdiff
fix path_to_volume_id to work with base volumes and clones
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 31 Jan 2013 07:14:55 +0000 (08:14 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 31 Jan 2013 07:14:55 +0000 (08:14 +0100)
PVE/Storage.pm

index 0dd2345b0cfae29c9d05dde0f0b655b1435b9bdb..78a14f90b98f8f5bebf4428f3e48dd26dafb8825 100755 (executable)
@@ -303,7 +303,15 @@ sub path_to_volume_id {
        if ($path =~ m!^$imagedir/(\d+)/([^/\s]+)$!) {
            my $vmid = $1;
            my $name = $2;
-           return ('images', "$sid:$vmid/$name");
+
+           my $vollist = $plugin->list_images($sid, $scfg, $vmid);
+           foreach my $info (@$vollist) {
+               my ($storeid, $volname) = parse_volume_id($info->{volid});
+               my $volpath = $plugin->path($scfg, $volname, $storeid);
+               if ($volpath eq $path) {
+                   return ('images', $info->{volid});
+               }
+           }
        } elsif ($path =~ m!^$isodir/([^/]+\.[Ii][Ss][Oo])$!) {
            my $name = $1;
            return ('iso', "$sid:iso/$name");