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:
parent
79c9e07933
commit
bcb51ae8f9
@ -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;
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user