[pve-devel] [PATCH container 2/2] add restart migration to lxc api

Dominik Csapak d.csapak at proxmox.com
Thu Dec 1 17:19:30 CET 2016


this simply adds the restart flag and the optional timeout to the
lxc api required for the restart mode migration

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/PVE/API2/LXC.pm | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 38b1feb..3c02398 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -845,6 +845,17 @@ __PACKAGE__->register_method({
 		description => "Use online/live migration.",
 		optional => 1,
 	    },
+	    restart => {
+		type => 'boolean',
+		description => "Use restart migration",
+		optional => 1,
+	    },
+	    timeout => {
+		type => 'integer',
+		description => "Timeout in seconds for shutdown for restart migration",
+		optional => 1,
+		default => 60
+	    },
 	    force => {
 		type => 'boolean',
 		description => "Force migration despite local bind / device" .
@@ -880,10 +891,13 @@ __PACKAGE__->register_method({
 	# test if VM exists
 	PVE::LXC::Config->load_config($vmid);
 
+	my $isrunning = PVE::LXC::check_running($vmid);
 	# try to detect errors early
-	if (PVE::LXC::check_running($vmid)) {
-	    die "can't migrate running container without --online\n"
-		if !$param->{online};
+	if ($isrunning) {
+	    die "lxc live migration not implemented\n"
+		if $param->{online};
+	    die "running container needs restart mode for migration\n"
+		if !$param->{restart};
 	}
 
 	if (PVE::HA::Config::vm_is_ha_managed($vmid) && $rpcenv->{type} ne 'ha') {
-- 
2.1.4





More information about the pve-devel mailing list