[pve-devel] [PATCH v4 qemu-server 23/27] sync_disks: use allow_rename to avoid collisions on the target storage

Fabian Ebner f.ebner at proxmox.com
Thu Mar 26 09:09:53 CET 2020


This makes it possible to migrate a VM with volumes store1:vm-123-disk-0
store2:vm-123-disk-0 to some targetstorage. Also prevents migration failure
when there is an orphaned disk with the same volid on the target.

To avoid confusion, the name should not change for 'vmstate'-volumes.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 PVE/QemuMigrate.pm | 3 +++
 PVE/QemuServer.pm  | 1 +
 2 files changed, 4 insertions(+)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index ef31f45..25681a6 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -376,6 +376,8 @@ sub sync_disks {
 
 	    $local_volumes->{$volid}->{ref} = $attr->{referenced_in_config} ? 'config' : 'snapshot';
 
+	    $local_volumes->{$volid}->{is_vmstate} = $attr->{is_vmstate} ? 1 : 0;
+
 	    if ($attr->{cdrom}) {
 		if ($volid =~ /vm-\d+-cloudinit/) {
 		    $local_volumes->{$volid}->{ref} = 'generated';
@@ -534,6 +536,7 @@ sub sync_disks {
 		    'bwlimit' => $bwlimit,
 		    'insecure' => $opts->{migration_type} eq 'insecure',
 		    'with_snapshots' => $local_volumes->{$volid}->{snapshots},
+		    'allow_rename' => !$local_volumes->{$volid}->{is_vmstate},
 		};
 
 		my $new_volid = PVE::Storage::storage_migrate($self->{storecfg}, $volid, $self->{ssh_info},
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 7229ce1..d99eff5 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -4284,6 +4284,7 @@ sub foreach_volid {
     foreach my $snapname (keys %{$conf->{snapshots}}) {
 	my $snap = $conf->{snapshots}->{$snapname};
 	$test_volid->($snap->{vmstate}, 0, 1, $snapname);
+	$volhash->{$snap->{vmstate}}->{is_vmstate} = 1 if $snap->{vmstate};
 	PVE::QemuConfig->foreach_volume($snap, sub {
 	    my ($ds, $drive) = @_;
 	    $test_volid->($drive->{file}, drive_is_cdrom($drive), $drive->{replicate} // 1, $drive->{shared}, $snapname);
-- 
2.20.1





More information about the pve-devel mailing list