mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-20 15:28:22 +00:00
Ensure Qemu monitor commands are executed. Ref #1582.
This commit is contained in:
parent
c41c01b95f
commit
cf0cc8bb87
@ -1081,7 +1081,15 @@ class QemuVM(BaseNode):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
try:
|
try:
|
||||||
writer.write(command.encode('ascii') + b"\n")
|
cmd_byte = command.encode('ascii')
|
||||||
|
writer.write(cmd_byte + b"\n")
|
||||||
|
if not expected:
|
||||||
|
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:
|
except OSError as e:
|
||||||
log.warning("Could not write to QEMU monitor: {}".format(e))
|
log.warning("Could not write to QEMU monitor: {}".format(e))
|
||||||
writer.close()
|
writer.close()
|
||||||
@ -1089,13 +1097,15 @@ class QemuVM(BaseNode):
|
|||||||
if expected:
|
if expected:
|
||||||
try:
|
try:
|
||||||
while result is None:
|
while result is None:
|
||||||
line = await reader.readline()
|
line = await asyncio.wait_for(reader.readline(), timeout=3)
|
||||||
if not line:
|
if not line:
|
||||||
break
|
break
|
||||||
for expect in expected:
|
for expect in expected:
|
||||||
if expect in line:
|
if expect in line:
|
||||||
result = line.decode("utf-8").strip()
|
result = line.decode("utf-8").strip()
|
||||||
break
|
break
|
||||||
|
except asyncio.TimeoutError:
|
||||||
|
log.warning("Timeout while waiting for result of command '{}'".format(command))
|
||||||
except (ConnectionError, EOFError) as e:
|
except (ConnectionError, EOFError) as e:
|
||||||
log.warning("Could not read from QEMU monitor: {}".format(e))
|
log.warning("Could not read from QEMU monitor: {}".format(e))
|
||||||
writer.close()
|
writer.close()
|
||||||
@ -1118,6 +1128,9 @@ class QemuVM(BaseNode):
|
|||||||
log.info("Execute QEMU monitor command: {}".format(command))
|
log.info("Execute QEMU monitor command: {}".format(command))
|
||||||
try:
|
try:
|
||||||
writer.write(command.encode('ascii') + b"\n")
|
writer.write(command.encode('ascii') + b"\n")
|
||||||
|
await asyncio.wait_for(reader.readline(), timeout=3) # echo of the command
|
||||||
|
except asyncio.TimeoutError:
|
||||||
|
log.warning("Missing echo of command '{}'".format(command))
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
log.warning("Could not write to QEMU monitor: {}".format(e))
|
log.warning("Could not write to QEMU monitor: {}".format(e))
|
||||||
writer.close()
|
writer.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user