5
0
mirror of git://git.proxmox.com/git/qemu-server.git synced 2025-01-06 13:17:56 +03:00

mtunnel: add and handle OK/ERR replies

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>
This commit is contained in:
Fabian Grünbichler 2017-08-04 14:54:03 +02:00 committed by Wolfgang Bumiller
parent 79c9e07933
commit bcb51ae8f9
2 changed files with 15 additions and 1 deletions

View File

@ -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;

View 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 {