]> git.proxmox.com Git - pve-container.git/blobdiff - src/PVE/LXC/Migrate.pm
add vm_stop helper
[pve-container.git] / src / PVE / LXC / Migrate.pm
index fb33e8c61d2e276e912cc520f20628030c846139..df85ef74e80405dd6e6a02fdfc23a702fdd9207c 100644 (file)
@@ -105,12 +105,7 @@ sub prepare {
 
        $self->log('info', "shutdown CT $vmid\n");
 
-       my $cmd = ['lxc-stop', '-n', $vmid, '--timeout', $timeout];
-       $self->cmd($cmd, timeout => $timeout + 5);
-
-       # make sure container is stopped
-       $cmd = ['lxc-wait',  '-n', $vmid, '-t', 5, '-s', 'STOPPED'];
-       $self->cmd($cmd);
+       PVE::LXC::vm_stop($vmid, 0, $timeout);
 
        $running = 0;
     }
@@ -160,7 +155,8 @@ sub phase1 {
            return;
        }
 
-       $volhash->{$volid} = defined($snapname) ? 'snapshot' : 'config';
+       $volhash->{$volid}->{ref} = defined($snapname) ? 'snapshot' : 'config';
+       $volhash->{$volid}->{snapshots} = defined($snapname);
 
        my ($path, $owner) = PVE::Storage::path($self->{storecfg}, $volid);
 
@@ -213,7 +209,7 @@ sub phase1 {
        PVE::Storage::foreach_volid($dl, sub {
            my ($volid, $sid, $volname) = @_;
 
-           $volhash->{$volid} = 'storage';
+           $volhash->{$volid}->{ref} = 'storage';
        });
     }
 
@@ -249,11 +245,12 @@ sub phase1 {
     }
 
     foreach my $volid (sort keys %$volhash) {
-       if ($volhash->{$volid} eq 'storage') {
+       my $ref = $volhash->{$volid}->{ref};
+       if ($ref eq 'storage') {
            $self->log('info', "found local volume '$volid' (via storage)\n");
-       } elsif ($volhash->{$volid} eq 'config') {
+       } elsif ($ref eq 'config') {
            $self->log('info', "found local volume '$volid' (in current VM config)\n");
-       } elsif ($volhash->{$volid} eq 'snapshot') {
+       } elsif ($ref eq 'snapshot') {
            $self->log('info', "found local volume '$volid' (referenced by snapshot(s))\n");
        } else {
            $self->log('info', "found local volume '$volid'\n");
@@ -285,7 +282,8 @@ sub phase1 {
        next if $rep_volumes->{$volid};
        my ($sid, $volname) = PVE::Storage::parse_volume_id($volid);
        push @{$self->{volumes}}, $volid;
-       PVE::Storage::storage_migrate($self->{storecfg}, $volid, $self->{ssh_info}, $sid, undef, undef, undef, undef, $insecure);
+       my $with_snapshots = $volhash->{$volid}->{snapshots};
+       PVE::Storage::storage_migrate($self->{storecfg}, $volid, $self->{ssh_info}, $sid, undef, undef, undef, undef, $insecure, $with_snapshots);
     }
 
     my $conffile = PVE::LXC::Config->config_file($vmid);