From df9b40c1dc67ed41d1ee5f895baa914960b08437 Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 15 Oct 2019 23:42:42 +0800 Subject: [PATCH] Fix QEMU link detection flaky on last port. Fixes #1666 --- gns3server/compute/qemu/qemu_vm.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 92d2adb8..e83ac244 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -1173,8 +1173,12 @@ class QemuVM(BaseNode): for command in commands: log.info("Execute QEMU monitor command: {}".format(command)) try: - writer.write(command.encode('ascii') + b"\n") - await asyncio.wait_for(reader.readline(), timeout=3) # echo of the command + cmd_byte = command.encode('ascii') + writer.write(cmd_byte + b"\n") + while True: + line = await asyncio.wait_for(reader.readline(), timeout=3) # echo of the command + if not line or cmd_byte in line: + break except asyncio.TimeoutError: log.warning("Missing echo of command '{}'".format(command)) except OSError as e: