* [PATCH v4] python/qemu/qmp.py: QMP debug with VM label
@ 2020-03-16 10:32 Oksana Vohchana
2020-03-16 17:11 ` John Snow
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Oksana Vohchana @ 2020-03-16 10:32 UTC (permalink / raw)
To: qemu-devel; +Cc: ovoshcha, ehabkost, wainersm, crosa
QEMUMachine writes some messages to the default logger.
But it sometimes hard to read the output if we have requests to
more than one VM.
This patch adds a label to the logger in the debug mode.
Signed-off-by: Oksana Vohchana <ovoshcha@redhat.com>
---
v2:
- Instead of shown the label in the message it provides the label
only in the debug logger information.
v3:
- Fixes coding style problems.
v4:
- Use a suffix method to get a children's logger process from the parent.
---
python/qemu/machine.py | 3 ++-
python/qemu/qmp.py | 5 ++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/python/qemu/machine.py b/python/qemu/machine.py
index 183d8f3d38..f53abfa492 100644
--- a/python/qemu/machine.py
+++ b/python/qemu/machine.py
@@ -270,7 +270,8 @@ class QEMUMachine(object):
self._vm_monitor = os.path.join(self._sock_dir,
self._name + "-monitor.sock")
self._remove_files.append(self._vm_monitor)
- self._qmp = qmp.QEMUMonitorProtocol(self._vm_monitor, server=True)
+ self._qmp = qmp.QEMUMonitorProtocol(self._vm_monitor, server=True,
+ nickname=self._name)
def _post_launch(self):
if self._qmp:
diff --git a/python/qemu/qmp.py b/python/qemu/qmp.py
index f40586eedd..d6c9b2f4b1 100644
--- a/python/qemu/qmp.py
+++ b/python/qemu/qmp.py
@@ -46,7 +46,7 @@ class QEMUMonitorProtocol:
#: Logger object for debugging messages
logger = logging.getLogger('QMP')
- def __init__(self, address, server=False):
+ def __init__(self, address, server=False, nickname=None):
"""
Create a QEMUMonitorProtocol class.
@@ -62,6 +62,9 @@ class QEMUMonitorProtocol:
self.__address = address
self.__sock = self.__get_sock()
self.__sockfile = None
+ self._nickname = nickname
+ if self._nickname:
+ self.logger = logging.getLogger('QMP').getChild(self._nickname)
if server:
self.__sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.__sock.bind(self.__address)
--
2.21.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v4] python/qemu/qmp.py: QMP debug with VM label
2020-03-16 10:32 [PATCH v4] python/qemu/qmp.py: QMP debug with VM label Oksana Vohchana
@ 2020-03-16 17:11 ` John Snow
2020-03-17 20:15 ` Wainer dos Santos Moschetta
2020-03-17 21:55 ` Cleber Rosa
2 siblings, 0 replies; 4+ messages in thread
From: John Snow @ 2020-03-16 17:11 UTC (permalink / raw)
To: Oksana Vohchana, qemu-devel; +Cc: ehabkost, wainersm, crosa
On 3/16/20 6:32 AM, Oksana Vohchana wrote:
> QEMUMachine writes some messages to the default logger.
> But it sometimes hard to read the output if we have requests to
> more than one VM.
> This patch adds a label to the logger in the debug mode.
>
> Signed-off-by: Oksana Vohchana <ovoshcha@redhat.com>
> ---
> v2:
> - Instead of shown the label in the message it provides the label
> only in the debug logger information.
> v3:
> - Fixes coding style problems.
> v4:
> - Use a suffix method to get a children's logger process from the parent.
> ---
> python/qemu/machine.py | 3 ++-
> python/qemu/qmp.py | 5 ++++-
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/python/qemu/machine.py b/python/qemu/machine.py
> index 183d8f3d38..f53abfa492 100644
> --- a/python/qemu/machine.py
> +++ b/python/qemu/machine.py
> @@ -270,7 +270,8 @@ class QEMUMachine(object):
> self._vm_monitor = os.path.join(self._sock_dir,
> self._name + "-monitor.sock")
> self._remove_files.append(self._vm_monitor)
> - self._qmp = qmp.QEMUMonitorProtocol(self._vm_monitor, server=True)
> + self._qmp = qmp.QEMUMonitorProtocol(self._vm_monitor, server=True,
> + nickname=self._name)
>
> def _post_launch(self):
> if self._qmp:
> diff --git a/python/qemu/qmp.py b/python/qemu/qmp.py
> index f40586eedd..d6c9b2f4b1 100644
> --- a/python/qemu/qmp.py
> +++ b/python/qemu/qmp.py
> @@ -46,7 +46,7 @@ class QEMUMonitorProtocol:
> #: Logger object for debugging messages
> logger = logging.getLogger('QMP')
>
> - def __init__(self, address, server=False):
> + def __init__(self, address, server=False, nickname=None):
> """
> Create a QEMUMonitorProtocol class.
>
> @@ -62,6 +62,9 @@ class QEMUMonitorProtocol:
> self.__address = address
> self.__sock = self.__get_sock()
> self.__sockfile = None
> + self._nickname = nickname
> + if self._nickname:
> + self.logger = logging.getLogger('QMP').getChild(self._nickname)
> if server:
> self.__sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
> self.__sock.bind(self.__address)
>
Looks right to me. Thank you for taking the time to get this cleaned up.
Reviewed-by: John Snow <jsnow@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] python/qemu/qmp.py: QMP debug with VM label
2020-03-16 10:32 [PATCH v4] python/qemu/qmp.py: QMP debug with VM label Oksana Vohchana
2020-03-16 17:11 ` John Snow
@ 2020-03-17 20:15 ` Wainer dos Santos Moschetta
2020-03-17 21:55 ` Cleber Rosa
2 siblings, 0 replies; 4+ messages in thread
From: Wainer dos Santos Moschetta @ 2020-03-17 20:15 UTC (permalink / raw)
To: Oksana Vohchana, qemu-devel; +Cc: ehabkost, crosa
On 3/16/20 7:32 AM, Oksana Vohchana wrote:
> QEMUMachine writes some messages to the default logger.
> But it sometimes hard to read the output if we have requests to
> more than one VM.
For example, tests/acceptance/migration.py uses two VMs and reading the
qmp outputs on avocado's log is very confusing. Certainly this change
will help to improve that situation, just need to adapt
tests/acceptance/avocado_qemu/__init__.py to create the QEMUMachine
object with a name.
Anyway, this patch looks good to me so:
Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Thanks!
> This patch adds a label to the logger in the debug mode.
>
> Signed-off-by: Oksana Vohchana <ovoshcha@redhat.com>
> ---
> v2:
> - Instead of shown the label in the message it provides the label
> only in the debug logger information.
> v3:
> - Fixes coding style problems.
> v4:
> - Use a suffix method to get a children's logger process from the parent.
> ---
> python/qemu/machine.py | 3 ++-
> python/qemu/qmp.py | 5 ++++-
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/python/qemu/machine.py b/python/qemu/machine.py
> index 183d8f3d38..f53abfa492 100644
> --- a/python/qemu/machine.py
> +++ b/python/qemu/machine.py
> @@ -270,7 +270,8 @@ class QEMUMachine(object):
> self._vm_monitor = os.path.join(self._sock_dir,
> self._name + "-monitor.sock")
> self._remove_files.append(self._vm_monitor)
> - self._qmp = qmp.QEMUMonitorProtocol(self._vm_monitor, server=True)
> + self._qmp = qmp.QEMUMonitorProtocol(self._vm_monitor, server=True,
> + nickname=self._name)
>
> def _post_launch(self):
> if self._qmp:
> diff --git a/python/qemu/qmp.py b/python/qemu/qmp.py
> index f40586eedd..d6c9b2f4b1 100644
> --- a/python/qemu/qmp.py
> +++ b/python/qemu/qmp.py
> @@ -46,7 +46,7 @@ class QEMUMonitorProtocol:
> #: Logger object for debugging messages
> logger = logging.getLogger('QMP')
>
> - def __init__(self, address, server=False):
> + def __init__(self, address, server=False, nickname=None):
> """
> Create a QEMUMonitorProtocol class.
>
> @@ -62,6 +62,9 @@ class QEMUMonitorProtocol:
> self.__address = address
> self.__sock = self.__get_sock()
> self.__sockfile = None
> + self._nickname = nickname
> + if self._nickname:
> + self.logger = logging.getLogger('QMP').getChild(self._nickname)
> if server:
> self.__sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
> self.__sock.bind(self.__address)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] python/qemu/qmp.py: QMP debug with VM label
2020-03-16 10:32 [PATCH v4] python/qemu/qmp.py: QMP debug with VM label Oksana Vohchana
2020-03-16 17:11 ` John Snow
2020-03-17 20:15 ` Wainer dos Santos Moschetta
@ 2020-03-17 21:55 ` Cleber Rosa
2 siblings, 0 replies; 4+ messages in thread
From: Cleber Rosa @ 2020-03-17 21:55 UTC (permalink / raw)
To: Oksana Vohchana; +Cc: qemu-devel, wainersm, ehabkost
[-- Attachment #1: Type: text/plain, Size: 432 bytes --]
On Mon, Mar 16, 2020 at 12:32:03PM +0200, Oksana Vohchana wrote:
> QEMUMachine writes some messages to the default logger.
> But it sometimes hard to read the output if we have requests to
> more than one VM.
> This patch adds a label to the logger in the debug mode.
>
> Signed-off-by: Oksana Vohchana <ovoshcha@redhat.com>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Queueing it on my python-next branch.
Thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-03-17 21:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-16 10:32 [PATCH v4] python/qemu/qmp.py: QMP debug with VM label Oksana Vohchana
2020-03-16 17:11 ` John Snow
2020-03-17 20:15 ` Wainer dos Santos Moschetta
2020-03-17 21:55 ` Cleber Rosa
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.