+ # check if storage is available on target node
+ my $targetsid = PVE::JSONSchema::map_id($self->{opts}->{storagemap}, $storeid);
+ my $target_scfg = PVE::Storage::storage_check_enabled($self->{storecfg}, $targetsid, $self->{node});
+
+ die "content type 'rootdir' is not available on storage '$targetsid'\n"
+ if !$target_scfg->{content}->{rootdir};
+
+ PVE::Storage::foreach_volid($dl, sub {
+ my ($volid, $sid, $volname) = @_;
+
+ $volhash->{$volid}->{ref} = 'storage';
+ $volhash->{$volid}->{targetsid} = $targetsid;
+ });
+ }
+
+ # then all volumes referenced in snapshots
+ foreach my $snapname (keys %{$conf->{snapshots}}) {
+ &$test_volid($conf->{snapshots}->{$snapname}->{'vmstate'}, 0, undef)
+ if defined($conf->{snapshots}->{$snapname}->{'vmstate'});
+ PVE::LXC::Config->foreach_volume($conf->{snapshots}->{$snapname}, $test_mp, $snapname);
+ }
+
+ # finally all current volumes
+ PVE::LXC::Config->foreach_volume_full($conf, { include_unused => 1 }, $test_mp);
+
+ # additional checks for local storage
+ foreach my $volid (keys %$volhash) {
+ eval {
+ my ($sid, $volname) = PVE::Storage::parse_volume_id($volid);
+ my $scfg = PVE::Storage::storage_config($self->{storecfg}, $sid);
+
+ my $migratable = ($scfg->{type} eq 'dir') || ($scfg->{type} eq 'zfspool')
+ || ($scfg->{type} eq 'lvmthin') || ($scfg->{type} eq 'lvm')
+ || ($scfg->{type} eq 'btrfs');
+
+ die "storage type '$scfg->{type}' not supported\n"
+ if !$migratable;
+
+ # image is a linked clone on local storage, se we can't migrate.
+ if (my $basename = (PVE::Storage::parse_volname($self->{storecfg}, $volid))[3]) {
+ die "clone of '$basename'";
+ }
+ };
+ &$log_error($@, $volid) if $@;
+ }
+
+ foreach my $volid (sort keys %$volhash) {
+ my $ref = $volhash->{$volid}->{ref};
+ if ($ref eq 'storage') {
+ $self->log('info', "found local volume '$volid' (via storage)\n");
+ } elsif ($ref eq 'config') {
+ $self->log('info', "found local volume '$volid' (in current VM config)\n");
+ } elsif ($ref eq 'snapshot') {
+ $self->log('info', "found local volume '$volid' (referenced by snapshot(s))\n");