[pve-devel] [PATCH v2 qemu-server 09/16] phase3_cleanup: add finish_block_jobs
Alexandre Derumier
aderumier at odiso.com
Mon Mar 9 16:24:32 CET 2020
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/QemuMigrate.pm | 40 ++++++++++++++++++++++++----------------
1 file changed, 24 insertions(+), 16 deletions(-)
diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index a7d3e48..37db3b8 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -631,22 +631,7 @@ sub phase3_cleanup {
my $tunnel = $self->{tunnel};
- if ($self->{storage_migration}) {
- # finish block-job
- eval { PVE::QemuServer::qemu_drive_mirror_monitor($vmid, undef, $self->{storage_migration_jobs}); };
-
- if (my $err = $@) {
- 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);
- PVE::QemuConfig->write_config($vmid, $conf);
- }
- }
- }
+ finish_block_jobs($self, $vmid);
# transfer replication state before move config
$self->transfer_replication_state() if $self->{replicated_volumes};
@@ -1161,4 +1146,27 @@ sub stop_remote_vm {
}
}
+sub finish_block_jobs {
+ my ($self, $vmid) = @_;
+
+ my $conf = $self->{vmconf};
+
+ if ($self->{storage_migration}) {
+ # finish block-job
+ eval { PVE::QemuServer::qemu_drive_mirror_monitor($vmid, undef, $self->{storage_migration_jobs}); };
+
+ if (my $err = $@) {
+ 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);
+ PVE::QemuConfig->write_config($vmid, $conf);
+ }
+ }
+ }
+}
+
1;
--
2.20.1
More information about the pve-devel
mailing list