]> git.proxmox.com Git - qemu-server.git/commitdiff
Fix #1664: nbd mirror : remove socat tunnel
authorAlexandre Derumier <aderumier@odiso.com>
Thu, 15 Feb 2018 12:43:10 +0000 (13:43 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 16 Feb 2018 12:58:56 +0000 (13:58 +0100)
socat tunnel for nbd mirror was introduce here
https://pve.proxmox.com/pipermail/pve-devel/2017-January/024777.html
to workaround when nbd client was hanging on non responding nbd server.

We have added a 30s timeout on socat tunnel, but when we migrate
multiple disks, it can break migration if for example first disk
is already finished and don't send any new datas in the tunnel.

The connect timeout bug has been fixed in qemu 2.9,
so we can remove the socat tunnel now.

PVE/QemuServer.pm

index ffbb436951b24dfc0a211c2438668361861094a4..fc3ff6d8d6337198b971fc91aaa7da2268b37d53 100644 (file)
@@ -6062,31 +6062,8 @@ sub qemu_drive_mirror {
     $jobs->{"drive-$drive"} = {};
 
     if ($dst_volid =~ /^nbd:(localhost|[\d\.]+|\[[\d\.:a-fA-F]+\]):(\d+):exportname=(\S+)/) {
-       my $server = $1;
-       my $port = $2;
-       my $exportname = $3;
-
+       $qemu_target = $dst_volid;
        $format = "nbd";
-       my $unixsocket = "/run/qemu-server/$vmid.mirror-drive-$drive";
-       $qemu_target = "nbd+unix:///$exportname?socket=$unixsocket";
-       my $cmd = ['socat', '-T30', "UNIX-LISTEN:$unixsocket,fork", "TCP:$server:$2,connect-timeout=5"];
-
-       my $pid = fork();
-       if (!defined($pid)) {
-           die "forking socat tunnel failed\n";
-       } elsif ($pid == 0) {
-           exec(@$cmd);
-           warn "exec failed: $!\n";
-           POSIX::_exit(-1);
-       }
-       $jobs->{"drive-$drive"}->{pid} = $pid;
-
-       my $timeout = 0;
-       while (!-S $unixsocket) {
-           die "nbd connection helper timed out\n"
-               if $timeout++ > 5;
-           sleep 1;
-       }
     } else {
        my $storecfg = PVE::Storage::config();
        my ($dst_storeid, $dst_volname) = PVE::Storage::parse_volume_id($dst_volid);
@@ -6198,7 +6175,6 @@ sub qemu_drive_mirror_monitor {
                        }else {
                            print "$job: Completed successfully.\n";
                            $jobs->{$job}->{complete} = 1;
-                           eval { qemu_blockjobs_finish_tunnel($vmid, $job, $jobs->{$job}->{pid}) } ;
                        }
                    }
                }
@@ -6236,7 +6212,6 @@ sub qemu_blockjobs_cancel {
 
            if (defined($jobs->{$job}->{cancel}) && !defined($running_jobs->{$job})) {
                print "$job: Done.\n";
-               eval { qemu_blockjobs_finish_tunnel($vmid, $job, $jobs->{$job}->{pid}) } ;
                delete $jobs->{$job};
            }
        }
@@ -6247,25 +6222,6 @@ sub qemu_blockjobs_cancel {
     }
 }
 
-sub qemu_blockjobs_finish_tunnel {
-   my ($vmid, $job, $cpid) = @_;
-
-   return if !$cpid;
-
-   for (my $i = 1; $i < 20; $i++) {
-       my $waitpid = waitpid($cpid, WNOHANG);
-       last if (defined($waitpid) && ($waitpid == $cpid));
-       if ($i == 10) {
-           kill(15, $cpid);
-       } elsif ($i >= 15) {
-           kill(9, $cpid);
-       }
-       sleep (1);
-    }
-    unlink "/run/qemu-server/$vmid.mirror-$job";
-}
-
 sub clone_disk {
     my ($storecfg, $vmid, $running, $drivename, $drive, $snapname,
        $newvmid, $storage, $format, $full, $newvollist, $jobs, $skipcomplete, $qga) = @_;