5
0
mirror of git://git.proxmox.com/git/qemu-server.git synced 2025-01-10 01:18:01 +03:00

fix bug #381: use PVE::Tools::next_migrate_port()

This commit is contained in:
Dietmar Maurer 2013-05-13 07:30:50 +02:00
parent 046e410418
commit f9a971e0ee
2 changed files with 3 additions and 21 deletions

View File

@ -6,6 +6,7 @@ use PVE::AbstractMigrate;
use IO::File;
use IPC::Open2;
use PVE::INotify;
use PVE::Tools;
use PVE::Cluster;
use PVE::Storage;
use PVE::QemuServer;
@ -328,7 +329,7 @@ sub phase2 {
$self->log('info', "starting migration tunnel");
## create tunnel to remote port
my $lport = PVE::QemuServer::next_migrate_port();
my $lport = PVE::Tools::next_migrate_port();
$self->{tunnel} = $self->fork_tunnel($self->{nodeip}, $lport, $rport);
$self->log('info', "starting online/live migration on port $lport");

View File

@ -2540,25 +2540,6 @@ sub pidfile_name {
return "${var_run_tmpdir}/$vmid.pid";
}
sub next_migrate_port {
for (my $p = 60000; $p < 60010; $p++) {
my $sock = IO::Socket::INET->new(Listen => 5,
LocalAddr => 'localhost',
LocalPort => $p,
ReuseAddr => 1,
Proto => 0);
if ($sock) {
close($sock);
return $p;
}
}
die "unable to find free migration port";
}
sub vm_devices_list {
my ($vmid) = @_;
@ -3002,7 +2983,7 @@ sub vm_start {
if ($statefile) {
if ($statefile eq 'tcp') {
$migrate_port = next_migrate_port();
$migrate_port = PVE::Tools::next_migrate_port();
my $migrate_uri = "tcp:localhost:${migrate_port}";
push @$cmd, '-incoming', $migrate_uri;
push @$cmd, '-S';