[pve-devel] [PATCH v3 qemu-server 7/7] migrate: add sshkey in /etc/pve/priv/migrate_external/

Alexandre Derumier aderumier at odiso.com
Tue Nov 27 16:38:09 CET 2018


ssh key need to be in

/etc/pve/priv/migrate_external/id_rsa_mytargetnode
---
 PVE/API2/Qemu.pm   | 5 +++++
 PVE/QemuMigrate.pm | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index b85fd6d..d31fd96 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -3226,6 +3226,10 @@ __PACKAGE__->register_method({
 
         die "HA must be disable for external migration." if PVE::HA::Config::vm_is_ha_managed($vmid);
 
+	my $migration_external_sshkey = "/etc/pve/priv/migrate_external/id_rsa_$target";
+
+	die "ssh privatekey is missing for $target" if !-e $migration_external_sshkey;
+
 	my $targetip = PVE::Network::get_ip_from_hostname($target, 1);
 
 	# test if VM exists
@@ -3239,6 +3243,7 @@ __PACKAGE__->register_method({
 
 	$param->{online} = 1;
 	$param->{migration_external} = 1;
+	$param->{migration_external_sshkey} = $migration_external_sshkey;
 
 	my $realcmd = sub {
 	    PVE::QemuMigrate->migrate($target, $targetip, $vmid, $param);
diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index ed8df71..9942757 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -234,6 +234,8 @@ sub prepare {
 
     if($self->{opts}->{migration_external}) {
 
+	push @{$self->{rem_ssh}}, '-i', $self->{opts}->{migration_external_sshkey};
+
 	#get remote nextvmid
 	eval {
 	    my $cmd = [@{$self->{rem_ssh}}, 'pvesh', 'get', '/cluster/nextid'];
-- 
2.11.0




More information about the pve-devel mailing list