python/qemu/qmp.py: QMP debug with VM label
PATCH v4 1/1 python/qemu/qmp.py: QMP debug with VM label
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.
---
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(-)
python/qemu/machine.py +2 -1
@@ -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:
python/qemu/qmp.py +4 -1
@@ -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)
Signature · 1 line
2.21.1
Quoted 48 lines · Oksana Vohchana
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 <[email protected]>---
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(-)python/qemu/machine.py +2
-1@@ -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:python/qemu/qmp.py +1
-1@@ -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.
python/qemu/qmp.py class QEMUMonitorProtocol: · line 70
Quoted 9 lines
python/qemu/qmp.py +3
-0@@ -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.
Quoted 3 lines · Oksana Vohchana
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:
Thanks!
Quoted 53 lines
This patch adds a label to the logger in the debug mode.
Signed-off-by Oksana Vohchana <[email protected]>---
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(-)python/qemu/machine.py +2
-1@@ -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:python/qemu/qmp.py +4
-1@@ -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)
Quoted 6 lines · Oksana Vohchana
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 <[email protected]>
Queueing it on my python-next branch.
Thanks!