[pve-devel] [PATCH 2/3 qemu-server] Avoid collisions of unused disks when doing

Fabian Ebner f.ebner at proxmox.com
Mon Oct 28 10:57:38 CET 2019


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.ebner at proxmox.com>
---
 PVE/QemuMigrate.pm | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 0e9fdcf..a01f0ca 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)) {
-		    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





More information about the pve-devel mailing list