[pve-devel] [PATCH v2 container 1/3] collect and log origin of found local volumes

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Jul 11 12:03:34 CEST 2016


just knowing that local disks prevent a migration is not
very helpful, so be a bit more verbose here.
---
 src/PVE/LXC/Migrate.pm | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/PVE/LXC/Migrate.pm b/src/PVE/LXC/Migrate.pm
index fbcb8c7..185be07 100644
--- a/src/PVE/LXC/Migrate.pm
+++ b/src/PVE/LXC/Migrate.pm
@@ -100,7 +100,7 @@ sub phase1 {
     }
 
     $self->{volumes} = []; # list of already migrated volumes
-    my $volhash = {}; # 1 for local volumes
+    my $volhash = {}; # 'config', 'snapshot' or 'storage' for local volumes
 
     my $test_volid = sub {
 	my ($volid, $snapname) = @_;
@@ -115,6 +115,8 @@ sub phase1 {
 
 	return if $scfg->{shared};
 
+	$volhash->{$volid} = defined($snapname) ? 'snapshot' : 'config';
+
 	my ($path, $owner) = PVE::Storage::path($self->{storecfg}, $volid);
 
 	die "can't migrate volume '$volid' - owned by other guest (owner = $owner)\n"
@@ -124,12 +126,9 @@ sub phase1 {
 	    # we cannot migrate shapshots on local storage
 	    # exceptions: 'zfspool'
 	    if (($scfg->{type} eq 'zfspool')) {
-		$volhash->{$volid} = 1;
 		return;
 	    }
 	    die "can't migrate snapshot of local volume '$volid'\n";
-	} else {
-	    $volhash->{$volid} = 1;
 	}
     };
 
@@ -151,7 +150,6 @@ sub phase1 {
 	if (!$scfg->{shared}) {
 	    $self->log('info', "copy mountpoint '$ms' ($volid) to node ' $self->{node}'")
 		if !$snapname;
-	    $volhash->{$volid} = 1;
 	} else {
 	    $self->log('info', "mountpoint '$ms' is on shared storage '$storage'")
 		if !$snapname;
@@ -189,7 +187,7 @@ sub phase1 {
 
 	    $self->log('info', "copy volume '$volid' to node '$self->{node}'")
 		if !$volhash->{$volid};
-	    $volhash->{$volid} = 1;
+	    $volhash->{$volid} = 'storage' if !defined($volhash->{$volid});
 	});
     }
 
@@ -210,6 +208,18 @@ sub phase1 {
 	}
     }
 
+    foreach my $volid (sort keys %$volhash) {
+	if ($volhash->{$volid} eq 'storage') {
+	    $self->log('info', "found local volume '$volid' (via storage)\n");
+	} elsif ($volhash->{$volid} eq 'config') {
+	    $self->log('info', "found local volume '$volid' (in current VM config)\n");
+	} elsif ($volhash->{$volid} eq 'snapshot') {
+	    $self->log('info', "found local volume '$volid' (referenced by snapshot(s))\n");
+	} else {
+	    $self->log('info', "found local volume '$volid'\n");
+	}
+    }
+
     foreach my $volid (keys %$volhash) {
 	my ($sid, $volname) = PVE::Storage::parse_volume_id($volid);
 	push @{$self->{volumes}}, $volid;
-- 
2.1.4





More information about the pve-devel mailing list