python/qemu: qmp: Make QEMUMonitorProtocol a context manager
commit07608e807d4e7bd2daa7fe154bd9dc2235c1a323
authorWainer dos Santos Moschetta <wainersm@redhat.com>
Tue, 4 Feb 2020 14:11:10 +0000 (4 11:11 -0300)
committerPhilippe Mathieu-Daudé <philmd@redhat.com>
Fri, 7 Feb 2020 14:12:48 +0000 (7 15:12 +0100)
tree38a24e66e3b91d3e5985ff50d03659d7a37d6bd5
parent54aafc2fc65231871e744308705c4aa6d283a22d
python/qemu: qmp: Make QEMUMonitorProtocol a context manager

This implement the __enter__ and __exit__ functions on
QEMUMonitorProtocol class so that it can be used on 'with'
statement and the resources will be free up on block end:

with QEMUMonitorProtocol(socket_path) as qmp:
    qmp.connect()
    qmp.command('query-status')

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Message-Id: <20200204141111.3207-5-wainersm@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
python/qemu/qmp.py