]> git.proxmox.com Git - qemu-server.git/commitdiff
mtunnel: add and handle OK/ERR replies
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Fri, 4 Aug 2017 12:54:03 +0000 (14:54 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 7 Aug 2017 07:23:56 +0000 (09:23 +0200)
because we want commands to return meaningful errors, and
print them on the client/source side.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
PVE/CLI/qm.pm
PVE/QemuMigrate.pm

index 7b161e36242daa2a2a378dabc91def0edcc98da2..b70bb200c9461961201fc257d4fb31ee483affff 100755 (executable)
@@ -277,7 +277,10 @@ __PACKAGE__->register_method ({
 
        while (my $line = <>) {
            chomp $line;
-           last if $line =~ m/^quit$/;
+           if ($line =~ /^quit$/) {
+               $tunnel_write->("OK");
+               last;
+           }
        }
 
        return undef;
index a03805093b44e4e6f35d33d727dc6dd0f02ce03a..43a3911984d7a303ad5e98ddebc4735a16869e4a 100644 (file)
@@ -123,6 +123,17 @@ sub write_tunnel {
        });
     };
     die "writing to tunnel failed: $@\n" if $@;
+
+    if ($tunnel->{version} && $tunnel->{version} >= 1) {
+       my $res = eval { $self->read_tunnel($tunnel, 10); };
+       die "no reply to command '$command': $@\n" if $@;
+
+       if ($res eq 'OK') {
+           return;
+       } else {
+           die "tunnel replied '$res' to command '$command'\n";
+       }
+    }
 }
 
 sub fork_tunnel {