[pve-devel] [PATCH v2 qemu-server 1/3] Update unused volumes in config when doing online migration with --targetstorage
Fabian Ebner
f.ebner at proxmox.com
Wed Oct 30 10:54:34 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>
---
Changes from v1:
* Check explicitly if it is an online migration and that the volume
is referenced by the storage rather than something else
* Patch 3 fixes another typo
PVE/QemuMigrate.pm | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 626b837..045f3b0 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) && $self->{running} && $ref eq 'storage') {
+ 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