[pve-devel] [PATCH v2 container 1/2] fix #1147: allow marking non-volume mps as shared

Fabian Grünbichler f.gruenbichler at proxmox.com
Fri Oct 14 12:51:03 CEST 2016


this introduces a new option for non-volume mount points,
modeled after the way we define 'shared' storages: the
boolean flag 'shared' marks a mount point as available on
other nodes (default: false)

when migrating containers with non-volume mount points,
this new property is checked, and a migration is only
allowed if all such mount points are 'shared'.

setting this flag allows containers with non-volume mount
points to be migrated by the ha-manager as well, which was
previously not possible.

for backwards compatibility, the old "workaround" option
'-force' for 'pct migrate' still works, but displays a
warning pointing to the new options.
---
changes to v1: remove "nodes" property

 src/PVE/API2/LXC.pm    |  3 +--
 src/PVE/LXC/Config.pm  |  7 +++++++
 src/PVE/LXC/Migrate.pm | 19 ++++++++++++++-----
 3 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 15ebb87..d0e558a 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -848,8 +848,7 @@ __PACKAGE__->register_method({
 	    force => {
 		type => 'boolean',
 		description => "Force migration despite local bind / device" .
-		    " mounts. WARNING: identical bind / device mounts need to ".
-		    " be available on the target node.",
+		    " mounts. NOTE: deprecated, use 'shared' property of mount point instead.",
 		optional => 1,
 	    },
 	},
diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index 2ec643e..e1b159c 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -245,6 +245,13 @@ my $rootfs_desc = {
 	description => 'Enable user quotas inside the container (not supported with zfs subvolumes)',
 	optional => 1,
     },
+    shared => {
+	type => 'boolean',
+	description => 'Mark this non-volume mount point as available on multiple nodes (see \'nodes\')',
+	verbose_description => "Mark this non-volume mount point as available on all nodes.\n\nWARNING: This option does not share the mount point automatically, it assumes it is shared already!",
+	optional => 1,
+	default => 0,
+    },
 };
 
 PVE::JSONSchema::register_standard_option('pve-ct-rootfs', {
diff --git a/src/PVE/LXC/Migrate.pm b/src/PVE/LXC/Migrate.pm
index 1c168bb..10b2b69 100644
--- a/src/PVE/LXC/Migrate.pm
+++ b/src/PVE/LXC/Migrate.pm
@@ -46,11 +46,21 @@ sub prepare {
 	my ($ms, $mountpoint) = @_;
 
 	my $volid = $mountpoint->{volume};
+	my $type = $mountpoint->{type};
 
-	# skip dev/bind mps when forced
-	if ($mountpoint->{type} ne 'volume' && $force) {
-	    return;
+	# skip dev/bind mps when forced / shared
+	if ($type ne 'volume') {
+	    if ($force) {
+		warn "-force is deprecated, please use the 'shared' property on individual non-volume mount points instead!\n";
+		return;
+	    }
+	    if ($mountpoint->{shared}) {
+		return;
+	    } else {
+		die "cannot migrate local $type mount point '$ms'\n";
+	    }
 	}
+
 	my ($storage, $volname) = PVE::Storage::parse_volume_id($volid, 1) if $volid;
 	die "can't determine assigned storage for mountpoint '$ms'\n" if !$storage;
 
@@ -151,8 +161,7 @@ sub phase1 {
 	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.")
+	    $self->log('info', "ignoring shared '$mountpoint->{type}' mount point '$ms' ('$volid')")
 		if !$snapname;
 	    return;
 	}
-- 
2.1.4





More information about the pve-devel mailing list