[pve-devel] [PATCH container 1/2] Add force parameter for migration with bind/dev mp

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Mar 16 15:45:55 CET 2016


Add a new 'force' parameter that allows to force the
migration of a container despite configured bind or device
mountpoints, which will be ignored/skipped.
---
Note: without the undef fix for PVE::ProcFSTools::is_mounted
this produces a lot of noise because of $foo eq undef

This is only for manual migration with pct migrate / direct
API calls, not with the web interface. HA-managed containers
are also excluded for now.

 src/PVE/API2/LXC.pm    |  7 +++++++
 src/PVE/LXC/Migrate.pm | 15 +++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 55d4f4a..ea1e942 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -759,6 +759,13 @@ __PACKAGE__->register_method({
 		description => "Use online/live migration.",
 		optional => 1,
 	    },
+	    force => {
+		type => 'boolean',
+		description => "Force migration despite local bind / device" .
+		    " mounts. WARNING: identical bind / device mounts need to ".
+		    " be available on the target node.",
+		optional => 1,
+	    },
 	},
     },
     returns => {
diff --git a/src/PVE/LXC/Migrate.pm b/src/PVE/LXC/Migrate.pm
index 61e0806..831a80e 100644
--- a/src/PVE/LXC/Migrate.pm
+++ b/src/PVE/LXC/Migrate.pm
@@ -39,10 +39,17 @@ sub prepare {
 	$running = 1;
     }
 
+    my $force = $self->{opts}->{force} // 0;
+
     PVE::LXC::Config->foreach_mountpoint($conf, sub {
 	my ($ms, $mountpoint) = @_;
 
 	my $volid = $mountpoint->{volume};
+
+	# skip dev/bind mps when forced
+	if ($mountpoint->{type} ne 'volume' && $force) {
+	    return;
+	}
 	my ($storage, $volname) = PVE::Storage::parse_volume_id($volid, 1) if $volid;
 	die "can't determine assigned storage for mountpoint '$ms'\n" if !$storage;
 
@@ -87,6 +94,14 @@ sub phase1 {
 	my ($ms, $mountpoint) = @_;
 
 	my $volid = $mountpoint->{volume};
+
+	# already checked in prepare
+	if ($mountpoint->{type} ne 'volume') {
+	    $self->log('info', "ignoring mountpoint '$ms' ('$volid') of type " .
+		"'$mountpoint->{type}', migration is forced.");
+	    return;
+	}
+
 	my ($storage, $volname) = PVE::Storage::parse_volume_id($volid);
 	my $scfg = PVE::Storage::storage_check_node($self->{storecfg}, $storage);
 
-- 
2.1.4





More information about the pve-devel mailing list