qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Oksana Vohchana <ovoshcha@redhat.com>
To: qemu-devel@nongnu.org
Cc: ovoshcha@redhat.com, ehabkost@redhat.com, wainersm@redhat.com,
	crosa@redhat.com
Subject: [PATCH] python/qemu/qmp.py: QMP debug with VM label
Date: Wed,  4 Mar 2020 12:05:34 +0200	[thread overview]
Message-ID: <20200304100534.13155-1-ovoshcha@redhat.com> (raw)

QEMUMachine writes some messages to the default logger.
But it sometimes to hard the read the output if we have requested to
more than one VM.
This patch adds name in QMP command if it needs and labels with it in
debug mode.

Signed-off-by: Oksana Vohchana <ovoshcha@redhat.com>
---
 python/qemu/machine.py | 8 ++++----
 python/qemu/qmp.py     | 9 ++++++---
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/python/qemu/machine.py b/python/qemu/machine.py
index 183d8f3d38..060e68f06b 100644
--- a/python/qemu/machine.py
+++ b/python/qemu/machine.py
@@ -391,7 +391,7 @@ class QEMUMachine(object):
             self._qmp_set = False
             self._qmp = None
 
-    def qmp(self, cmd, conv_keys=True, **args):
+    def qmp(self, cmd, conv_keys=True, vm_name=None, **args):
         """
         Invoke a QMP command and return the response dict
         """
@@ -402,15 +402,15 @@ class QEMUMachine(object):
             else:
                 qmp_args[key] = value
 
-        return self._qmp.cmd(cmd, args=qmp_args)
+        return self._qmp.cmd(cmd, args=qmp_args, vm_name=vm_name)
 
-    def command(self, cmd, conv_keys=True, **args):
+    def command(self, cmd, conv_keys=True, vm_name=None, **args):
         """
         Invoke a QMP command.
         On success return the response dict.
         On failure raise an exception.
         """
-        reply = self.qmp(cmd, conv_keys, **args)
+        reply = self.qmp(cmd, conv_keys, vm_name, **args)
         if reply is None:
             raise qmp.QMPError("Monitor is closed")
         if "error" in reply:
diff --git a/python/qemu/qmp.py b/python/qemu/qmp.py
index f40586eedd..96b455b53f 100644
--- a/python/qemu/qmp.py
+++ b/python/qemu/qmp.py
@@ -180,11 +180,12 @@ class QEMUMonitorProtocol:
         self.__sockfile = self.__sock.makefile()
         return self.__negotiate_capabilities()
 
-    def cmd_obj(self, qmp_cmd):
+    def cmd_obj(self, qmp_cmd, vm_name=None):
         """
         Send a QMP command to the QMP Monitor.
 
         @param qmp_cmd: QMP command to be sent as a Python dict
+        @param vm_name: name for the virtual machine (string)
         @return QMP response as a Python dict or None if the connection has
                 been closed
         """
@@ -196,10 +197,12 @@ class QEMUMonitorProtocol:
                 return None
             raise err
         resp = self.__json_read()
+        if vm_name:
+            self.logger.debug("<<< {'vm_name' : %s }",  vm_name)
         self.logger.debug("<<< %s", resp)
         return resp
 
-    def cmd(self, name, args=None, cmd_id=None):
+    def cmd(self, name, args=None, cmd_id=None, vm_name=None):
         """
         Build a QMP command and send it to the QMP Monitor.
 
@@ -212,7 +215,7 @@ class QEMUMonitorProtocol:
             qmp_cmd['arguments'] = args
         if cmd_id:
             qmp_cmd['id'] = cmd_id
-        return self.cmd_obj(qmp_cmd)
+        return self.cmd_obj(qmp_cmd, vm_name)
 
     def command(self, cmd, **kwds):
         """
-- 
2.21.1



             reply	other threads:[~2020-03-04 10:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-04 10:05 Oksana Vohchana [this message]
2020-03-10  1:46 ` [PATCH] python/qemu/qmp.py: QMP debug with VM label John Snow
2020-03-12 14:02   ` Oksana Voshchana

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200304100534.13155-1-ovoshcha@redhat.com \
    --to=ovoshcha@redhat.com \
    --cc=crosa@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wainersm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).