[pve-devel] [v2 qemu-server 06/10] mtunnel: add and handle OK/ERR replies
Fabian Grünbichler
f.gruenbichler at proxmox.com
Fri Aug 4 14:54:03 CEST 2017
because we want commands to return meaningful errors, and
print them on the client/source side.
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
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 7b161e3..b70bb20 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 a038050..43a3911 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 {
--
2.11.0
More information about the pve-devel
mailing list