]> git.proxmox.com Git - pve-container.git/blobdiff - src/PVE/LXC/Migrate.pm
fix typos
[pve-container.git] / src / PVE / LXC / Migrate.pm
index 831a80e3714f9060993ee652c8192637c1a37b67..2db6111f838206f6b93c0b47f80c8aac1e22994a 100644 (file)
@@ -26,7 +26,7 @@ sub prepare {
 
     $self->{storecfg} = PVE::Storage::config();
 
-    # test is VM exist
+    # test if CT exists
     my $conf = $self->{vmconf} = PVE::LXC::Config->load_config($vmid);
 
     PVE::LXC::Config->check_lock($conf);
@@ -35,11 +35,12 @@ sub prepare {
     if (PVE::LXC::check_running($vmid)) {
        die "lxc live migration is currently not implemented\n";
 
-       die "cant migrate running container without --online\n" if !$online;
+       die "can't migrate running container without --online\n" if !$online;
        $running = 1;
     }
 
     my $force = $self->{opts}->{force} // 0;
+    my $need_activate = [];
 
     PVE::LXC::Config->foreach_mountpoint($conf, sub {
        my ($ms, $mountpoint) = @_;
@@ -57,13 +58,23 @@ sub prepare {
        my $scfg = PVE::Storage::storage_check_node($self->{storecfg}, $storage);
        PVE::Storage::storage_check_node($self->{storecfg}, $storage, $self->{node});
 
-       die "unable to migrate local mountpoint '$volid' while CT is running"
-           if !$scfg->{shared} && $running;
+
+       if ($scfg->{shared}) {
+           # PVE::Storage::activate_storage checks this for non-shared storages
+           my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
+           warn "Used shared storage '$storage' is not online on source node!\n"
+               if !$plugin->check_connection($storage, $scfg);
+       } else {
+           # only activate if not shared
+           push @$need_activate, $volid;
+
+           die "unable to migrate local mountpoint '$volid' while CT is running"
+               if $running;
+       }
 
     });
 
-    my $volid_list = PVE::LXC::Config->get_vm_volumes($conf);
-    PVE::Storage::activate_volumes($self->{storecfg}, $volid_list);
+    PVE::Storage::activate_volumes($self->{storecfg}, $need_activate);
 
     # todo: test if VM uses local resources
 
@@ -107,11 +118,11 @@ sub phase1 {
 
        if (!$scfg->{shared}) {
 
-           $self->log('info', "copy mointpoint '$ms' ($volid) to node ' $self->{node}'");
+           $self->log('info', "copy mountpoint '$ms' ($volid) to node ' $self->{node}'");
            PVE::Storage::storage_migrate($self->{storecfg}, $volid, $self->{nodeip}, $storage);
            push @{$self->{volumes}}, $volid;
        } else {
-           $self->log('info', "mointpoint '$ms' is on shared storage '$storage'");
+           $self->log('info', "mountpoint '$ms' is on shared storage '$storage'");
        }
     });