[pve-devel] [PATCH qemu-server 09/15] phase3_cleanup: add finish_block_jobs

Alexandre Derumier aderumier at odiso.com
Mon Apr 29 12:01:24 CEST 2019


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuMigrate.pm | 42 +++++++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 920263a..03d601c 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -611,23 +611,8 @@ 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 completed storage migration\n";
-	} else {
-	    foreach my $target_drive (keys %{$self->{target_drive}}) {
-		my $drive = PVE::QemuServer::parse_drive($target_drive, $self->{target_drive}->{$target_drive}->{volid});
-		$conf->{$target_drive} = PVE::QemuServer::print_drive($vmid, $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};
 
@@ -1137,4 +1122,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 completed storage migration\n";
+	} else {
+	    foreach my $target_drive (keys %{$self->{target_drive}}) {
+		my $drive = PVE::QemuServer::parse_drive($target_drive, $self->{target_drive}->{$target_drive}->{volid});
+		$conf->{$target_drive} = PVE::QemuServer::print_drive($vmid, $drive);
+		PVE::QemuConfig->write_config($vmid, $conf);
+	    }
+	}
+    }
+}
+
 1;
-- 
2.11.0




More information about the pve-devel mailing list