From bcb51ae8f9e6c8f8f526f861b5b9a4ea3490b17a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Fri, 4 Aug 2017 14:54:03 +0200 Subject: [PATCH] mtunnel: add and handle OK/ERR replies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit because we want commands to return meaningful errors, and print them on the client/source side. Signed-off-by: Fabian Grünbichler --- PVE/CLI/qm.pm | 5 ++++- PVE/QemuMigrate.pm | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm index 7b161e36..b70bb200 100755 --- a/PVE/CLI/qm.pm +++ b/PVE/CLI/qm.pm @@ -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; diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm index a0380509..43a39119 100644 --- a/PVE/QemuMigrate.pm +++ b/PVE/QemuMigrate.pm @@ -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 {