mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-30 16:46:51 +00:00
fix bug #381: use PVE::Tools::next_migrate_port()
This commit is contained in:
parent
046e410418
commit
f9a971e0ee
@ -6,6 +6,7 @@ use PVE::AbstractMigrate;
|
|||||||
use IO::File;
|
use IO::File;
|
||||||
use IPC::Open2;
|
use IPC::Open2;
|
||||||
use PVE::INotify;
|
use PVE::INotify;
|
||||||
|
use PVE::Tools;
|
||||||
use PVE::Cluster;
|
use PVE::Cluster;
|
||||||
use PVE::Storage;
|
use PVE::Storage;
|
||||||
use PVE::QemuServer;
|
use PVE::QemuServer;
|
||||||
@ -328,7 +329,7 @@ sub phase2 {
|
|||||||
$self->log('info', "starting migration tunnel");
|
$self->log('info', "starting migration tunnel");
|
||||||
|
|
||||||
## create tunnel to remote port
|
## 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->{tunnel} = $self->fork_tunnel($self->{nodeip}, $lport, $rport);
|
||||||
|
|
||||||
$self->log('info', "starting online/live migration on port $lport");
|
$self->log('info', "starting online/live migration on port $lport");
|
||||||
|
@ -2540,25 +2540,6 @@ sub pidfile_name {
|
|||||||
return "${var_run_tmpdir}/$vmid.pid";
|
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 {
|
sub vm_devices_list {
|
||||||
my ($vmid) = @_;
|
my ($vmid) = @_;
|
||||||
|
|
||||||
@ -3002,7 +2983,7 @@ sub vm_start {
|
|||||||
|
|
||||||
if ($statefile) {
|
if ($statefile) {
|
||||||
if ($statefile eq 'tcp') {
|
if ($statefile eq 'tcp') {
|
||||||
$migrate_port = next_migrate_port();
|
$migrate_port = PVE::Tools::next_migrate_port();
|
||||||
my $migrate_uri = "tcp:localhost:${migrate_port}";
|
my $migrate_uri = "tcp:localhost:${migrate_port}";
|
||||||
push @$cmd, '-incoming', $migrate_uri;
|
push @$cmd, '-incoming', $migrate_uri;
|
||||||
push @$cmd, '-S';
|
push @$cmd, '-S';
|
||||||
|
Loading…
Reference in New Issue
Block a user