[pve-devel] [PATCH qemu-server 1/3] Update unused volumes in config when doing

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


When doing an online migration with --targetstorage unused disks get migrated
to the specified target storage as well.
With this patch we keep track of those volumes and update the VM config with
their new locations. Unused volumes of the VM previously not present in the
config are added as well.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 PVE/QemuMigrate.pm | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 65f39b6..0e9fdcf 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -465,6 +465,12 @@ sub sync_disks {
 	    } else {
 		next if $rep_volumes->{$volid};
 		push @{$self->{volumes}}, $volid;
+
+		if (defined($override_targetsid)) {
+		    my (undef, $targetvolname) = PVE::Storage::parse_volume_id($volid);
+		    push @{$self->{online_unused_volumes}}, "${targetsid}:${targetvolname}";
+		}
+
 		my $opts = $self->{opts};
 		my $insecure = $opts->{migration_type} eq 'insecure';
 		my $with_snapshots = $local_volumes->{$volid}->{snapshots};
@@ -958,6 +964,16 @@ sub phase3_cleanup {
 	}
     }
 
+    if ($self->{online_unused_volumes}) {
+	foreach my $conf_key (keys %{$conf}) {
+	    delete $conf->{$conf_key} if ($conf_key =~ m/^unused\d+$/);
+	}
+	foreach my $targetvolid (@{$self->{online_unused_volumes}}) {
+	    PVE::QemuConfig->add_unused_volume($conf, $targetvolid);
+	}
+	PVE::QemuConfig->write_config($vmid, $conf);
+    }
+
     # transfer replication state before move config
     $self->transfer_replication_state() if $self->{replicated_volumes};
 
-- 
2.20.1





More information about the pve-devel mailing list