pass port family to next_*_port() calls

This commit is contained in:
Wolfgang Bumiller 2015-05-12 12:14:03 +02:00 committed by Dietmar Maurer
parent 14aa29d169
commit af0eba7e35
3 changed files with 14 additions and 8 deletions

View File

@ -1299,17 +1299,19 @@ __PACKAGE__->register_method({
$sslcert = PVE::Tools::file_get_contents("/etc/pve/pve-root-ca.pem", 8192) $sslcert = PVE::Tools::file_get_contents("/etc/pve/pve-root-ca.pem", 8192)
if !$sslcert; if !$sslcert;
my $port = PVE::Tools::next_vnc_port(); my ($remip, $family);
my $remip;
my $remcmd = []; my $remcmd = [];
if ($node ne 'localhost' && $node ne PVE::INotify::nodename()) { 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 # NOTE: kvm VNC traffic is already TLS encrypted or is known unsecure
$remcmd = ['/usr/bin/ssh', '-T', '-o', 'BatchMode=yes', $remip]; $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 $timeout = 10;
my $realcmd = sub { my $realcmd = sub {

View File

@ -354,7 +354,8 @@ sub phase2 {
## create tunnel to remote port ## create tunnel to remote port
$self->log('info', "starting ssh migration tunnel"); $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); $self->{tunnel} = $self->fork_tunnel($self->{nodeip}, $lport, $rport);
my $start = time(); my $start = time();

View File

@ -3020,7 +3020,9 @@ sub config_to_command {
my $pciaddr = print_pci_addr("spice", $bridges); 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"; push @$devices, '-spice', "tls-port=${spice_port},addr=127.0.0.1,tls-ciphers=DES-CBC3-SHA,seamless-migration=on";
@ -4194,11 +4196,12 @@ sub vm_start {
if ($statefile eq 'tcp') { if ($statefile eq 'tcp') {
my $localip = "localhost"; my $localip = "localhost";
my $datacenterconf = PVE::Cluster::cfs_read_file('datacenter.cfg'); my $datacenterconf = PVE::Cluster::cfs_read_file('datacenter.cfg');
my $nodename = PVE::INotify::nodename();
if ($datacenterconf->{migration_unsecure}) { if ($datacenterconf->{migration_unsecure}) {
my $nodename = PVE::INotify::nodename();
$localip = PVE::Cluster::remote_node_ip($nodename, 1); $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}"; $migrate_uri = "tcp:${localip}:${migrate_port}";
push @$cmd, '-incoming', $migrate_uri; push @$cmd, '-incoming', $migrate_uri;
push @$cmd, '-S'; push @$cmd, '-S';