[pve-devel] [RFC qemu-server 16/16] Update volume IDs in one go
Fabian Ebner
f.ebner at proxmox.com
Wed Jan 29 14:30:14 CET 2020
Use 'update_volume_ids' for the live-migrated disks as well.
Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
PVE/QemuMigrate.pm | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index af1cf01..6a0f034 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -628,6 +628,13 @@ sub phase2 {
$self->{target_drive}->{$targetdrive}->{drivestr} = $drivestr;
$self->{target_drive}->{$targetdrive}->{nbd_uri} = $nbd_uri;
+ my $current_drive = PVE::QemuServer::parse_drive($targetdrive, $conf->{$targetdrive});
+ my $new_drive = PVE::QemuServer::parse_drive($targetdrive, $drivestr);
+ my $current_volid = $current_drive->{file};
+ my $new_volid = $new_drive->{file};
+ $self->{volume_map}->{$current_volid} = $new_volid if $current_volid ne $new_volid;
+ $self->log('info', "volume '$current_volid' is '$new_volid' on the target\n");
+
} elsif ($line =~ m/^QEMU: (.*)$/) {
$self->log('info', "[$self->{node}] $1\n");
}
@@ -963,13 +970,6 @@ sub phase3_cleanup {
my $tunnel = $self->{tunnel};
- # Needs to happen before printing the drives that where migrated via qemu,
- # since a new volume on the target might have the same ID as an old volume
- # on the source and update_volume_ids relies on matching IDs in the config.
- if ($self->{volume_map}) {
- $conf = PVE::QemuConfig->update_volume_ids($conf, $self->{volume_map});
- }
-
if ($self->{storage_migration}) {
# finish block-job
eval { PVE::QemuServer::qemu_drive_mirror_monitor($vmid, undef, $self->{storage_migration_jobs}); };
@@ -978,16 +978,11 @@ sub phase3_cleanup {
eval { PVE::QemuServer::qemu_blockjobs_cancel($vmid, $self->{storage_migration_jobs}) };
eval { PVE::QemuMigrate::cleanup_remotedisks($self) };
die "Failed to complete storage migration: $err\n";
- } else {
- foreach my $target_drive (keys %{$self->{target_drive}}) {
- my $drive = PVE::QemuServer::parse_drive($target_drive, $self->{target_drive}->{$target_drive}->{drivestr});
- $conf->{$target_drive} = PVE::QemuServer::print_drive($drive);
- }
}
}
- # only write after successfully completing the migration
- if ($self->{volume_map} || $self->{storage_migration}) {
+ if ($self->{volume_map}) {
+ $conf = PVE::QemuConfig->update_volume_ids($conf, $self->{volume_map});
PVE::QemuConfig->write_config($vmid, $conf);
}
--
2.20.1
More information about the pve-devel
mailing list