since PVE::Cluster::get_local_migration_ip does not exist anymore. this
is basically an inlined version, since this is the only remaining caller
that we actually want to keep long-term.

Signed-off-by: Fabian Grünbichler <f.gruenbich...@proxmox.com>
---
 PVE/QemuServer.pm | 40 +++++++++++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index cd89475..71720fd 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -5346,6 +5346,35 @@ sub vm_start {
 
        my ($cmd, $vollist, $spice_port) = config_to_command($storecfg, $vmid, 
$conf, $defaults, $forcemachine);
 
+       my $migration_ip;
+       my $get_migration_ip = sub {
+           my ($cidr, $nodename) = @_;
+
+           return $migration_ip if defined($migration_ip);
+
+           if (!defined($cidr)) {
+               my $dc_conf = PVE::Cluster::cfs_read_file('datacenter.cfg');
+               $cidr = $dc_conf->{migration}->{network};
+           }
+
+           if (defined($cidr)) {
+               my $ips = PVE::Network::get_local_ip_from_cidr($cidr);
+
+               die "could not get IP: no address configured on local " .
+                   "node for network '$cidr'\n" if scalar(@$ips) == 0;
+
+               die "could not get IP: multiple addresses configured on local " 
.
+                   "node for network '$cidr'\n" if scalar(@$ips) > 1;
+
+               $migration_ip = @$ips[0];
+           }
+
+           $migration_ip = PVE::Cluster::remote_node_ip($nodename, 1)
+               if !defined($migration_ip);
+
+           return $migration_ip;
+       };
+
        my $migrate_uri;
        if ($statefile) {
            if ($statefile eq 'tcp') {
@@ -5362,13 +5391,7 @@ sub vm_start {
                }
 
                if ($migration_type eq 'insecure') {
-                   my $migrate_network_addr = 
PVE::Cluster::get_local_migration_ip($migration_network);
-                   if ($migrate_network_addr) {
-                       $localip = $migrate_network_addr;
-                   } else {
-                       $localip = PVE::Cluster::remote_node_ip($nodename, 1);
-                   }
-
+                   $localip = $get_migration_ip->($migration_network, 
$nodename);
                    $localip = "[$localip]" if Net::IP::ip_is_ipv6($localip);
                }
 
@@ -5498,8 +5521,7 @@ sub vm_start {
        #start nbd server for storage migration
        if ($targetstorage) {
            my $nodename = PVE::INotify::nodename();
-           my $migrate_network_addr = 
PVE::Cluster::get_local_migration_ip($migration_network);
-           my $localip = $migrate_network_addr ? $migrate_network_addr : 
PVE::Cluster::remote_node_ip($nodename, 1);
+           my $localip = $get_migration_ip->($migration_network, $nodename);
            my $pfamily = PVE::Tools::get_host_address_family($nodename);
            my $storage_migrate_port = PVE::Tools::next_migrate_port($pfamily);
 
-- 
2.20.1


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to