[pve-devel] [PATCH] pass port family to next_*_port() calls

Wolfgang Bumiller w.bumiller at proxmox.com
Tue May 12 12:14:03 CEST 2015


---
 PVE/API2/Qemu.pm   | 10 ++++++----
 PVE/QemuMigrate.pm |  3 ++-
 PVE/QemuServer.pm  |  9 ++++++---
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index c0a6bc3..fae2872 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1299,17 +1299,19 @@ __PACKAGE__->register_method({
 	$sslcert = PVE::Tools::file_get_contents("/etc/pve/pve-root-ca.pem", 8192)
 	    if !$sslcert;
 
-	my $port = PVE::Tools::next_vnc_port();
-
-	my $remip;
+	my ($remip, $family);
 	my $remcmd = [];
 
 	if ($node ne 'localhost' && $node ne PVE::INotify::nodename()) {
-	    $remip = PVE::Cluster::remote_node_ip($node);
+	    ($remip, $family) = PVE::Cluster::remote_node_ip($node);
 	    # NOTE: kvm VNC traffic is already TLS encrypted or is known unsecure
 	    $remcmd = ['/usr/bin/ssh', '-T', '-o', 'BatchMode=yes', $remip];
+	} else {
+	    $family = PVE::Tools::get_host_address_family($node);
 	}
 
+	my $port = PVE::Tools::next_vnc_port($family);
+
 	my $timeout = 10;
 
 	my $realcmd = sub {
diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index f6eb3f5..5eb488f 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -354,7 +354,8 @@ sub phase2 {
 
     ## create tunnel to remote port
     $self->log('info', "starting ssh migration tunnel");
-    my $lport = ($raddr eq "localhost") ? PVE::Tools::next_migrate_port() : undef;
+    my $pfamily = PVE::Tools::get_host_address_family($nodename);
+    my $lport = ($raddr eq "localhost") ? PVE::Tools::next_migrate_port($pfamily) : undef;
     $self->{tunnel} = $self->fork_tunnel($self->{nodeip}, $lport, $rport);
 
     my $start = time();
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 708b208..5ae4789 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3018,7 +3018,9 @@ sub config_to_command {
 
 	my $pciaddr = print_pci_addr("spice", $bridges);
 
-	$spice_port = PVE::Tools::next_spice_port();
+	my $nodename = PVE::INotify::nodename();
+	my $pfamily = PVE::Tools::get_host_address_family($nodename);
+	$spice_port = PVE::Tools::next_spice_port($pfamily);
 
 	push @$devices, '-spice', "tls-port=${spice_port},addr=127.0.0.1,tls-ciphers=DES-CBC3-SHA,seamless-migration=on";
 
@@ -4193,11 +4195,12 @@ sub vm_start {
 	    if ($statefile eq 'tcp') {
 		my $localip = "localhost";
 		my $datacenterconf = PVE::Cluster::cfs_read_file('datacenter.cfg');
+		my $nodename = PVE::INotify::nodename();
 		if ($datacenterconf->{migration_unsecure}) {
-			my $nodename = PVE::INotify::nodename();
 			$localip = PVE::Cluster::remote_node_ip($nodename, 1);
 		}
-		$migrate_port = PVE::Tools::next_migrate_port();
+		my $pfamily = PVE::Tools::get_host_address_family($nodename);
+		$migrate_port = PVE::Tools::next_migrate_port($pfamily);
 		$migrate_uri = "tcp:${localip}:${migrate_port}";
 		push @$cmd, '-incoming', $migrate_uri;
 		push @$cmd, '-S';
-- 
2.1.4





More information about the pve-devel mailing list