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. Signed-off-by: Oksana Vohchana <ovoshcha@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-Id: <20200316103203.10046-1-ovoshcha@redhat.com> Signed-off-by: Cleber Rosa <crosa@redhat.com>
This commit is contained in:
parent
d649689a8e
commit
566054a0bc
@ -270,7 +270,8 @@ class QEMUMachine(object):
|
|||||||
self._vm_monitor = os.path.join(self._sock_dir,
|
self._vm_monitor = os.path.join(self._sock_dir,
|
||||||
self._name + "-monitor.sock")
|
self._name + "-monitor.sock")
|
||||||
self._remove_files.append(self._vm_monitor)
|
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):
|
def _post_launch(self):
|
||||||
if self._qmp:
|
if self._qmp:
|
||||||
|
@ -46,7 +46,7 @@ class QEMUMonitorProtocol:
|
|||||||
#: Logger object for debugging messages
|
#: Logger object for debugging messages
|
||||||
logger = logging.getLogger('QMP')
|
logger = logging.getLogger('QMP')
|
||||||
|
|
||||||
def __init__(self, address, server=False):
|
def __init__(self, address, server=False, nickname=None):
|
||||||
"""
|
"""
|
||||||
Create a QEMUMonitorProtocol class.
|
Create a QEMUMonitorProtocol class.
|
||||||
|
|
||||||
@ -62,6 +62,9 @@ class QEMUMonitorProtocol:
|
|||||||
self.__address = address
|
self.__address = address
|
||||||
self.__sock = self.__get_sock()
|
self.__sock = self.__get_sock()
|
||||||
self.__sockfile = None
|
self.__sockfile = None
|
||||||
|
self._nickname = nickname
|
||||||
|
if self._nickname:
|
||||||
|
self.logger = logging.getLogger('QMP').getChild(self._nickname)
|
||||||
if server:
|
if server:
|
||||||
self.__sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
self.__sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
self.__sock.bind(self.__address)
|
self.__sock.bind(self.__address)
|
||||||
|
Loading…
Reference in New Issue
Block a user