qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] python/qemu/qmp.py: QMP debug with VM label


From: Oksana Vohchana
Subject: [PATCH] python/qemu/qmp.py: QMP debug with VM label
Date: Wed, 4 Mar 2020 12:05:34 +0200

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 <address@hidden>
---
 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 via email to

[Prev in Thread] Current Thread [Next in Thread]