Since the first patch of this patchset restores the logging of monitor commands, let's silence the monitor logging for 2 frequently executed operations:
* Screendump thread * is_responsive() monitor checks They are executed very frequently, and see the logged commands in this case is pointless. So for all other execution of monitor commands, we get the commands logged, which is very convenient for future systematic monitor testing. Signed-off-by: Lucas Meneghel Rodrigues <[email protected]> --- client/tests/kvm/kvm_monitor.py | 44 +++++++++++++++++++------------- client/tests/kvm/kvm_preprocessing.py | 4 ++- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/client/tests/kvm/kvm_monitor.py b/client/tests/kvm/kvm_monitor.py index f62c583..90fde1a 100644 --- a/client/tests/kvm/kvm_monitor.py +++ b/client/tests/kvm/kvm_monitor.py @@ -173,7 +173,7 @@ class HumanMonitor(Monitor): return False, "\n".join(o.splitlines()) - def _send_command(self, command): + def _send_command(self, command, verbose=True): """ Send a command without waiting for output. @@ -188,7 +188,8 @@ class HumanMonitor(Monitor): try: try: - logging.debug("[human] monitor cmd: %s", command) + if verbose: + logging.debug("[human] monitor cmd: %s", command) self._socket.sendall(command + "\n") except socket.error: raise MonitorSendError("Could not send monitor command '%s'" % @@ -198,7 +199,7 @@ class HumanMonitor(Monitor): self._lock.release() - def _get_command_output(self, command, timeout=20): + def _get_command_output(self, command, timeout=20, verbose=True): """ Send command to the monitor. @@ -218,7 +219,7 @@ class HumanMonitor(Monitor): # Read any data that might be available self._recvall() # Send command - self._send_command(command) + self._send_command(command, verbose=verbose) # Read output s, o = self._read_up_to_qemu_prompt(timeout) # Remove command echo from output @@ -244,7 +245,9 @@ class HumanMonitor(Monitor): @return: True if responsive, False otherwise """ try: - self._get_command_output("help") + # Here let's silence the command logging, since + # it happens frequently and it's not particularly interesting + self._get_command_output("help", verbose=False) return True except MonitorError: return False @@ -257,7 +260,7 @@ class HumanMonitor(Monitor): # - A command wrapper should use self._help_str if it requires information # about the monitor's capabilities. - def cmd(self, cmdline, timeout=20): + def cmd(self, cmdline, timeout=20, verbose=True): """ Send a simple command with/without parameters and return its output. Implemented under the same name for both the human and QMP monitors. @@ -276,7 +279,7 @@ class HumanMonitor(Monitor): re_str = "(?<=\=)\w*" command += " " + ' '.join(re.findall(re_str, cmdline)) - return self._get_command_output(command, timeout) + return self._get_command_output(command, timeout, verbose=verbose) def quit(self): @@ -300,14 +303,15 @@ class HumanMonitor(Monitor): return self.info(what) - def screendump(self, filename): + def screendump(self, filename, verbose=True): """ Request a screendump. @param filename: Location for the screendump @return: The command's output """ - return self._get_command_output("screendump %s" % filename) + return self._get_command_output("screendump %s" % filename, + verbose=verbose) def migrate(self, uri, full_copy=False, incremental_copy=False, wait=False): @@ -476,7 +480,7 @@ class QMPMonitor(Monitor): return objs - def _send_command(self, cmd, args=None, id=None): + def _send_command(self, cmd, args=None, id=None, verbose=True): """ Send command without waiting for response. @@ -492,7 +496,8 @@ class QMPMonitor(Monitor): try: cmdobj = self._build_cmd(cmd, args, id) try: - logging.debug("[qmp] monitor cmd: %s" % cmdobj) + if verbose: + logging.debug("[qmp] monitor cmd: %s" % cmdobj) self._socket.sendall(json.dumps(cmdobj) + "\n") except socket.error: raise MonitorSendError("Could not send QMP command '%s'" % cmd) @@ -501,7 +506,7 @@ class QMPMonitor(Monitor): self._lock.release() - def _get_command_output(self, cmd, args=None, timeout=20): + def _get_command_output(self, cmd, args=None, timeout=20, verbose=True): """ Send monitor command and wait for response. @@ -525,7 +530,7 @@ class QMPMonitor(Monitor): self._read_objects() # Send command id = kvm_utils.generate_random_string(8) - self._send_command(cmd, args, id) + self._send_command(cmd, args, id, verbose=verbose) # Read response end_time = time.time() + timeout while time.time() < end_time: @@ -555,7 +560,9 @@ class QMPMonitor(Monitor): @return: True if responsive, False otherwise """ try: - self._get_command_output("query-version") + # Also here, let's silence the command logging, since + # it happens frequently and it's not particularly interesting + self._get_command_output("query-version", verbose=False) return True except MonitorError: return False @@ -608,7 +615,7 @@ class QMPMonitor(Monitor): # Note: all of the following functions raise exceptions in a similar manner # to cmd() and _get_command_output(). - def cmd(self, cmdline, timeout=20): + def cmd(self, cmdline, timeout=20, verbose=True): """ Send a simple command with/without parameters and return its output. Implemented under the same name for both the human and QMP monitors. @@ -636,7 +643,8 @@ class QMPMonitor(Monitor): args[opt[0]] = value except: logging.debug("Fail to create args, please check command") - return self._get_command_output(command, args, timeout=timeout) + return self._get_command_output(command, args, timeout=timeout, + verbose=verbose) def quit(self): @@ -660,7 +668,7 @@ class QMPMonitor(Monitor): return self.info(what) - def screendump(self, filename): + def screendump(self, filename, verbose=True): """ Request a screendump. @@ -668,7 +676,7 @@ class QMPMonitor(Monitor): @return: The response to the command """ args = {"filename": filename} - return self._get_command_output("screendump", args) + return self._get_command_output("screendump", args, verbose=verbose) def migrate(self, uri, full_copy=False, incremental_copy=False, wait=False): diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py index e3de0b3..d9aa8a3 100644 --- a/client/tests/kvm/kvm_preprocessing.py +++ b/client/tests/kvm/kvm_preprocessing.py @@ -408,7 +408,9 @@ def _take_screendumps(test, params, env): if not vm.is_alive(): continue try: - vm.monitor.screendump(temp_filename) + # Here verbose is set to false because otherwise the screendump + # thread would generate a *lot* of not so interesting output + vm.monitor.screendump(temp_filename, verbose=False) except kvm_monitor.MonitorError, e: logging.warn(e) continue -- 1.7.2.2 _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
