Doing an online migration with --targetstorage and two unused disks with the
same name on different storages failed, because they would collide on the
target storage. This patch makes sure that we don't use the same name twice.

Signed-off-by: Fabian Ebner <f.eb...@proxmox.com>
---
 PVE/QemuMigrate.pm | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 045f3b0..94c5764 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -10,6 +10,7 @@ use PVE::INotify;
 use PVE::Tools;
 use PVE::Cluster;
 use PVE::Storage;
+use PVE::Storage::Plugin;
 use PVE::QemuServer;
 use Time::HiRes qw( usleep );
 use PVE::RPCEnvironment;
@@ -466,9 +467,12 @@ sub sync_disks {
                next if $rep_volumes->{$volid};
                push @{$self->{volumes}}, $volid;
 
+               my $targetvolname = undef;
                if (defined($override_targetsid) && $self->{running} && $ref eq 
'storage') {
-                   my (undef, $targetvolname) = 
PVE::Storage::parse_volume_id($volid);
+                   my $scfg = PVE::Storage::storage_config($self->{storecfg}, 
$targetsid);
+                   $targetvolname = 
PVE::Storage::Plugin::get_next_vm_diskname($self->{online_unused_volumes}, 
$targetsid, $vmid, undef, $scfg, 0);
                    push @{$self->{online_unused_volumes}}, 
"${targetsid}:${targetvolname}";
+                   $self->log('info', "$volid will become 
${targetsid}:${targetvolname} on the target node");
                }
 
                my $opts = $self->{opts};
@@ -480,7 +484,7 @@ sub sync_disks {
                $bwlimit = $bwlimit * 1024 if defined($bwlimit);
 
                PVE::Storage::storage_migrate($self->{storecfg}, $volid, 
$self->{ssh_info}, $targetsid,
-                                             undef, undef, undef, $bwlimit, 
$insecure, $with_snapshots);
+                                             $targetvolname, undef, undef, 
$bwlimit, $insecure, $with_snapshots);
            }
        }
     };
-- 
2.20.1


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to