[pve-devel] [PATCH qemu-server 08/11] cleanup_remotedisks: simplify and also include those migrated with storage_migrate

Fabian Ebner f.ebner at proxmox.com
Wed May 20 10:20:43 CEST 2020


by using the information from volume_map. Call cleanup_remotedisks in
phase1_cleanup as well, because that's where we end if sync_disks
fails and some disks might already have been transfered successfully.

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

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 481e1ba..421b9d7 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -619,16 +619,11 @@ sub sync_offline_local_volumes {
 sub cleanup_remotedisks {
     my ($self) = @_;
 
-    foreach my $target_drive (keys %{$self->{target_drive}}) {
-	my $drivestr = $self->{target_drive}->{$target_drive}->{drivestr};
-	next if !defined($drivestr);
-
-	my $drive = PVE::QemuServer::parse_drive($target_drive, $drivestr);
-
+    foreach my $volid (values %{$self->{volume_map}}) {
 	# don't clean up replicated disks!
-	next if defined($self->{replicated_volumes}->{$drive->{file}});
+	next if defined($self->{replicated_volumes}->{$volid});
 
-	my ($storeid, $volname) = PVE::Storage::parse_volume_id($drive->{file});
+	my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid);
 
 	my $cmd = [@{$self->{rem_ssh}}, 'pvesm', 'free', "$storeid:$volname"];
 
@@ -683,11 +678,9 @@ sub phase1_cleanup {
 	$self->log('err', $err);
     }
 
-    if ($self->{volumes}) {
-	foreach my $volid (@{$self->{volumes}}) {
-	    $self->log('err', "found stale volume copy '$volid' on node '$self->{node}'");
-	    # fixme: try to remove ?
-	}
+    eval { $self->cleanup_remotedisks() };
+    if (my $err = $@) {
+	$self->log('err', $err);
     }
 
     eval { $self->cleanup_bitmaps() };
-- 
2.20.1





More information about the pve-devel mailing list