[pve-devel] [PATCH qemu-server 1/7] api2 : migrate_vm : add migration_type "external"

Alexandre Derumier aderumier at odiso.com
Mon Oct 29 16:38:46 CET 2018


qm migrate <vmid> <targetremotenode> --migration_type external [--targetstorage monpoolceph_vm] --online

Allow to migrate to an external cluster node.
--targetstorage is optionnal, if not defined it's used same storagename than source
---
 PVE/API2/Qemu.pm | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 52f4a5f..64eaa0e 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -3046,7 +3046,7 @@ __PACKAGE__->register_method({
 	    },
 	    migration_type => {
 		type => 'string',
-		enum => ['secure', 'insecure'],
+		enum => ['secure', 'insecure', 'external'],
 		description => "Migration traffic is encrypted using an SSH tunnel by default. On secure, completely private networks this can be disabled to increase performance.",
 		optional => 1,
 	    },
@@ -3085,7 +3085,7 @@ __PACKAGE__->register_method({
 
 	PVE::Cluster::check_cfs_quorum();
 
-	PVE::Cluster::check_node_exists($target);
+	PVE::Cluster::check_node_exists($target) if $param->{migration_type} ne 'external';
 
 	my $targetip = PVE::Cluster::remote_node_ip($target);
 
@@ -3094,6 +3094,13 @@ __PACKAGE__->register_method({
 	raise_param_exc({ targetstorage => "Live storage migration can only be done online." })
 	    if !$param->{online} && $param->{targetstorage};
 
+	raise_param_exc({ migration_type => "external migration can only be done online." })
+	    if !$param->{online} && $param->{migration_type} eq 'external';
+
+	raise_param_exc({ migration_type => "HA must be disable for external migration." })
+	    if PVE::HA::Config::vm_is_ha_managed($vmid) && $param->{migration_type} eq 'external';
+
+
 	raise_param_exc({ force => "Only root may use this option." })
 	    if $param->{force} && $authuser ne 'root at pam';
 
@@ -3114,17 +3121,22 @@ __PACKAGE__->register_method({
 	if (PVE::QemuServer::check_running($vmid)) {
 	    die "cant migrate running VM without --online\n"
 		if !$param->{online};
+	} else {
+	    die "vm need to be online for external migration" if $param->{migration_type} eq 'external';
 	}
 
 	my $storecfg = PVE::Storage::config();
 
-	if( $param->{targetstorage}) {
-	    PVE::Storage::storage_check_node($storecfg, $param->{targetstorage}, $target);
-        } else {
-	    PVE::QemuServer::check_storage_availability($storecfg, $conf, $target);
+	if ($param->{migration_type} ne 'external') {
+
+	    if( $param->{targetstorage} ) {
+		PVE::Storage::storage_check_node($storecfg, $param->{targetstorage}, $target);
+	    } else {
+		PVE::QemuServer::check_storage_availability($storecfg, $conf, $target);
+	    }
 	}
 
-	if (PVE::HA::Config::vm_is_ha_managed($vmid) && $rpcenv->{type} ne 'ha') {
+	if (PVE::HA::Config::vm_is_ha_managed($vmid) && $rpcenv->{type} ne 'ha' && $param->{migration_type} ne 'external') {
 
 	    my $hacmd = sub {
 		my $upid = shift;
-- 
2.11.0




More information about the pve-devel mailing list