]> git.proxmox.com Git - pve-container.git/commitdiff
Add force parameter for migration with bind/dev mp
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 16 Mar 2016 14:45:55 +0000 (15:45 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 16 Mar 2016 15:50:04 +0000 (16:50 +0100)
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.

src/PVE/API2/LXC.pm
src/PVE/LXC/Migrate.pm

index 55d4f4a0dc8a8d15534f4b248a9c68ccfa9752da..ea1e942c600fa44ab5164c5e92b8b06ded65c31b 100644 (file)
@@ -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 => {
index 61e0806f5869d1369f50c04e2e43ed9a92d802fe..831a80e3714f9060993ee652c8192637c1a37b67 100644 (file)
@@ -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);