From 90b1fc64ec00b974010a2218a6b80554648dc75c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 22 Jun 2018 11:59:39 +0200 Subject: Make communication with QEMU monitor more robust --- bbot/agent/machine.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bbot/agent/machine.cxx b/bbot/agent/machine.cxx index 0431a2f..a8933bb 100644 --- a/bbot/agent/machine.cxx +++ b/bbot/agent/machine.cxx @@ -4,7 +4,7 @@ #include -#include // sleep() +#include // sleep(), usleep() #include // sockaddr_un #include @@ -425,6 +425,8 @@ namespace bbot void kvm_machine:: monitor_command (const string& c) { + tracer trace ("kvm_machine::monitor_command", monitor.string ().c_str ()); + sockaddr_un addr; addr.sun_family = AF_LOCAL; strcpy (addr.sun_path, monitor.string ().c_str ()); // Size check in ctor @@ -441,7 +443,7 @@ namespace bbot // Read until we get something. // - auto readsome = [&sock] () + auto readsome = [&trace, &sock] () { ifdstream ifs (move (sock), fdstream_mode::non_blocking, @@ -456,9 +458,11 @@ namespace bbot { n += m; - //buf[m] = '\0'; - //text << buf; + buf[m] = '\0'; + l5 ([&]{trace << buf;}); } + + usleep (100000); // 0.1s } sock = ifs.release (); -- cgit v1.1