Browse Source

iotests: Accommodate async QMP Exception classes

(But continue to support the old ones for now, too.)

There are very few cases of any user of QEMUMachine or a subclass
thereof relying on a QMP Exception type. If you'd like to check for
yourself, you want to grep for all of the derivatives of QMPError,
excluding 'AQMPError' and its derivatives. That'd be these:

- QMPError
- QMPConnectError
- QMPCapabilitiesError
- QMPTimeoutError
- QMPProtocolError
- QMPResponseError
- QMPBadPortError

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20211026175612.4127598-5-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
John Snow 3 years ago
parent
commit
3bd559467d

+ 2 - 1
scripts/simplebench/bench_block_job.py

@@ -28,6 +28,7 @@
 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
 from qemu.machine import QEMUMachine
 from qemu.machine import QEMUMachine
 from qemu.qmp import QMPConnectError
 from qemu.qmp import QMPConnectError
+from qemu.aqmp import ConnectError
 
 
 
 
 def bench_block_job(cmd, cmd_args, qemu_args):
 def bench_block_job(cmd, cmd_args, qemu_args):
@@ -49,7 +50,7 @@ def bench_block_job(cmd, cmd_args, qemu_args):
         vm.launch()
         vm.launch()
     except OSError as e:
     except OSError as e:
         return {'error': 'popen failed: ' + str(e)}
         return {'error': 'popen failed: ' + str(e)}
-    except (QMPConnectError, socket.timeout):
+    except (QMPConnectError, ConnectError, socket.timeout):
         return {'error': 'qemu failed: ' + str(vm.get_log())}
         return {'error': 'qemu failed: ' + str(vm.get_log())}
 
 
     try:
     try:

+ 3 - 2
tests/qemu-iotests/tests/mirror-top-perms

@@ -21,8 +21,9 @@
 
 
 import os
 import os
 
 
-from qemu import qmp
+from qemu.aqmp import ConnectError
 from qemu.machine import machine
 from qemu.machine import machine
+from qemu.qmp import QMPConnectError
 
 
 import iotests
 import iotests
 from iotests import qemu_img
 from iotests import qemu_img
@@ -102,7 +103,7 @@ class TestMirrorTopPerms(iotests.QMPTestCase):
             self.vm_b.launch()
             self.vm_b.launch()
             print('ERROR: VM B launched successfully, this should not have '
             print('ERROR: VM B launched successfully, this should not have '
                   'happened')
                   'happened')
-        except qmp.QMPConnectError:
+        except (QMPConnectError, ConnectError):
             assert 'Is another process using the image' in self.vm_b.get_log()
             assert 'Is another process using the image' in self.vm_b.get_log()
 
 
         result = self.vm.qmp('block-job-cancel',
         result = self.vm.qmp('block-job-cancel',