Qemu parses hostnames in brackets correctly but sets an ipv6
flag for them as if they were ipv6 addresses, only insert
brackets for ipv6 addresses.
---
 PVE/QemuMigrate.pm | 6 +++---
 PVE/QemuServer.pm  | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index a1ee10a..3506e10 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -334,7 +334,7 @@ sub phase2 {
     PVE::Tools::run_command($cmd, input => $spice_ticket, outfunc => sub {
        my $line = shift;
 
-       if ($line =~ m/^migration listens on 
tcp:\[([\d\.:a-fA-F]+|localhost)\]:(\d+)$/) {
+       if ($line =~ m/^migration listens on 
tcp:(localhost|[\d\.]+|\[[\d\.:a-fA-F]+\]):(\d+)$/) {
            $raddr = $1;
            $rport = int($2);
        }
@@ -418,10 +418,10 @@ sub phase2 {
     }
 
     eval {
-        PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate", uri => 
"tcp:[$raddr]:$rport");
+        PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate", uri => 
"tcp:$raddr:$rport");
     };
     my $merr = $@;
-    $self->log('info', "migrate uri => tcp:[$raddr]:$rport failed: $merr") if 
$merr;
+    $self->log('info', "migrate uri => tcp:$raddr:$rport failed: $merr") if 
$merr;
 
     my $lstat = 0;
     my $usleep = 2000000;
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 19c017c..af64ccd 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -4607,10 +4607,11 @@ sub vm_start {
                my $nodename = PVE::INotify::nodename();
                if ($datacenterconf->{migration_unsecure}) {
                        $localip = PVE::Cluster::remote_node_ip($nodename, 1);
+                       $localip = "[$localip]" if 
Net::IP::ip_is_ipv6($localip);
                }
                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, '-S';
            } else {
-- 
2.1.4


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

Reply via email to