X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=PVE%2FStorage.pm;h=c3813944feaefcb86f37526257c0417b16d27501;hb=3881e68025e228023bb8080fd456114888041f8f;hp=bdafdc12dc0ca1c141fdb41ffa110688ec9d3683;hpb=a97d3ee49f21a61d3df10d196140c95dde45ec27;p=pve-storage.git diff --git a/PVE/Storage.pm b/PVE/Storage.pm index bdafdc1..c381394 100755 --- a/PVE/Storage.pm +++ b/PVE/Storage.pm @@ -562,6 +562,25 @@ sub abs_filesystem_path { return $path; } +my $volname_for_storage = sub { + my ($cfg, $volid, $target_storeid) = @_; + + my (undef, $name, $vmid, undef, undef, undef, $format) = parse_volname($cfg, $volid); + my $target_scfg = storage_config($cfg, $target_storeid); + + my (undef, $valid_formats) = PVE::Storage::Plugin::default_format($target_scfg); + my $format_is_valid = grep { $_ eq $format } @$valid_formats; + die "unsupported format '$format' for storage type $target_scfg->{type}\n" if !$format_is_valid; + + (my $name_without_extension = $name) =~ s/\.$format$//; + + if ($target_scfg->{path}) { + return "$vmid/$name_without_extension.$format"; + } else { + return "$name_without_extension"; + } +}; + sub storage_migrate { my ($cfg, $volid, $target_sshinfo, $target_storeid, $opts, $logfunc) = @_; @@ -573,7 +592,6 @@ sub storage_migrate { my $allow_rename = $opts->{allow_rename} ? 1 : 0; my ($storeid, $volname) = parse_volume_id($volid); - my $target_volname = $opts->{target_volname} || $volname; my $scfg = storage_config($cfg, $storeid); @@ -587,6 +605,15 @@ sub storage_migrate { die "content type '$vtype' is not available on storage '$target_storeid'\n" if !$tcfg->{content}->{$vtype}; + my $target_volname; + if ($opts->{target_volname}) { + $target_volname = $opts->{target_volname}; + } elsif ($scfg->{type} eq $tcfg->{type}) { + $target_volname = $volname; + } else { + $target_volname = $volname_for_storage->($cfg, $volid, $target_storeid); + } + my $target_volid = "${target_storeid}:${target_volname}"; my $target_ip = $target_sshinfo->{ip}; @@ -1183,7 +1210,7 @@ sub scan_cifs { sub scan_zfs { - my $cmd = ['zfs', 'list', '-t', 'filesystem', '-H', '-o', 'name,avail,used']; + my $cmd = ['zfs', 'list', '-t', 'filesystem', '-Hp', '-o', 'name,avail,used']; my $res = []; run_command($cmd, outfunc => sub { @@ -1191,8 +1218,8 @@ sub scan_zfs { if ($line =~m/^(\S+)\s+(\S+)\s+(\S+)$/) { my ($pool, $size_str, $used_str) = ($1, $2, $3); - my $size = PVE::Storage::ZFSPoolPlugin::zfs_parse_size($size_str); - my $used = PVE::Storage::ZFSPoolPlugin::zfs_parse_size($used_str); + my $size = $size_str + 0; + my $used = $used_str + 0; # ignore subvolumes generated by our ZFSPoolPlugin return if $pool =~ m!/subvol-\d+-[^/]+$!; return if $pool =~ m!/basevol-\d+-[^/]+$!;