python: Treat None-return of greeting cmd
PATCH 1/1 python: Treat None-return of greeting cmd
In case qemu process dies the "monitor.cmd" returns None which gets passed to the "__negotiate_capabilities" and leads to unhandled exception. Let's only check the resp in case it has a value.
--- python/qemu/qmp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
python/qemu/qmp.py +1 -1
@@ -73,7 +73,7 @@ class QEMUMonitorProtocol(object): raise QMPConnectError # Greeting seems ok, negotiate capabilities resp = self.cmd('qmp_capabilities') - if "return" in resp: + if resp and "return" in resp: return greeting raise QMPCapabilitiesError
Signature · 1 line
2.21.0
Quoted 15 lines · Lukáš Doktor
In case qemu process dies the "monitor.cmd" returns None which gets passed to the "
__negotiate_capabilities" and leads to unhandled exception. Let's only check the resp in case it has a value.Signed-off-by Lukáš Doktor <[email protected]>--- python/qemu/qmp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)python/qemu/qmp.py +0
-0
python/qemu/qmp.py class QEMUMonitorProtocol(object): · line 79
Quoted 8 lines
python/qemu/qmp.py +1
-1@@ -73,7 +73,7 @@ class QEMUMonitorProtocol(object): raise QMPConnectError # Greeting seems ok, negotiate capabilities resp = self.cmd('qmp_capabilities') - if "return" in resp: + if resp and "return" in resp: return greeting raise QMPCapabilitiesError
Quoted 8 lines · Lukáš Doktor
In case qemu process dies the "monitor.cmd" returns None which gets passed to the "
__negotiate_capabilities" and leads to unhandled exception. Let's only check the resp in case it has a value.Signed-off-by Lukáš Doktor <[email protected]>--- python/qemu/qmp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines
python/qemu/qmp.py +1
-1@@ -73,7 +73,7 @@ class QEMUMonitorProtocol(object): raise QMPConnectError # Greeting seems ok, negotiate capabilities resp = self.cmd('qmp_capabilities') - if "return" in resp: + if resp and "return" in resp: return greeting raise QMPCapabilitiesError
Philippe Mathieu-Daudé
AppliedQuoted 15 lines · Lukáš Doktor
In case qemu process dies the "monitor.cmd" returns None which gets passed to the "
__negotiate_capabilities" and leads to unhandled exception. Let's only check the resp in case it has a value.Signed-off-by Lukáš Doktor <[email protected]>--- python/qemu/qmp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)python/qemu/qmp.py +0
-0
python/qemu/qmp.py class QEMUMonitorProtocol(object): · line 79
Quoted 8 lines
python/qemu/qmp.py +1
-1@@ -73,7 +73,7 @@ class QEMUMonitorProtocol(object): raise QMPConnectError # Greeting seems ok, negotiate capabilities resp = self.cmd('qmp_capabilities') - if "return" in resp: + if resp and "return" in resp: return greeting raise QMPCapabilitiesError
Thanks, applied to my python-next tree:
https://gitlab.com/philmd/qemu/commits/python-next