my $storage_cfg = cfs_read_file("storage.cfg");
- PVE::LXC::update_lxc_config($vmid, $conf);
-
- local $ENV{PVE_SKIPLOCK}=1 if $skiplock;
-
- my $cmd = ['systemctl', 'start', "pve-container\@$vmid"];
-
- run_command($cmd);
+ PVE::LXC::vm_start($vmid, $conf, $skiplock);
return;
};
return [];
}
+sub vm_start {
+ my ($vmid, $conf, $skiplock) = @_;
+
+ update_lxc_config($vmid, $conf);
+
+ local $ENV{PVE_SKIPLOCK}=1 if $skiplock;
+
+ my $cmd = ['systemctl', 'start', "pve-container\@$vmid"];
+
+ PVE::Tools::run_command($cmd);
+
+ return;
+}
+
# Helper to stop a container completely and make sure it has stopped completely.
# This is necessary because we want the post-stop hook to have completed its
# unmount-all step, but post-stop happens after lxc puts the container into the
if (my $err = $@) {
$self->log('err', $err);
}
+ # in restart mode, we start the container on the source node
+ # on migration error
+ if ($self->{opts}->{restart} && $self->{was_running}) {
+ $self->log('info', "start container on source node");
+ my $skiplock = 1;
+ PVE::LXC::vm_start($vmid, $self->{vmconf}, $skiplock);
+ }
} else {
my $cmd = [ @{$self->{rem_ssh}}, 'pct', 'unlock', $vmid ];
$self->cmd_logerr($cmd, errmsg => "failed to clear migrate lock");