python: use vm.cmd() instead of vm.qmp() where appropriate

In many cases we just want an effect of qmp command and want to raise
on failure.  Use vm.cmd() method which does exactly this.

The commit is generated by command

  git grep -l '\.qmp(' | xargs ./scripts/python_qmp_updater.py

And then, fix self.assertRaises to expect ExecuteError exception in
tests/qemu-iotests/124

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 20231006154125.1068348-16-vsementsov@yandex-team.ru
Signed-off-by: John Snow <jsnow@redhat.com>
This commit is contained in:
Vladimir Sementsov-Ogievskiy 2023-10-06 18:41:25 +03:00 committed by John Snow
parent 25ad2cf650
commit b6aed193e5
44 changed files with 974 additions and 1448 deletions

View file

@ -61,10 +61,8 @@ class EncryptionSetupTestCase(iotests.QMPTestCase):
# create the secrets and load 'em into the VMs
self.secrets = [ Secret(i) for i in range(0, 4) ]
for secret in self.secrets:
result = self.vm1.qmp("object-add", secret.to_qmp_object())
self.assert_qmp(result, 'return', {})
result = self.vm2.qmp("object-add", secret.to_qmp_object())
self.assert_qmp(result, 'return', {})
self.vm1.cmd("object-add", secret.to_qmp_object())
self.vm2.cmd("object-add", secret.to_qmp_object())
# test case shutdown
def tearDown(self):
@ -132,11 +130,9 @@ class EncryptionSetupTestCase(iotests.QMPTestCase):
}
if reOpen:
result = vm.qmp(command, options=[opts])
self.assert_qmp(result, 'return', {})
vm.cmd(command, options=[opts])
else:
result = vm.qmp(command, opts)
self.assert_qmp(result, 'return', {})
vm.cmd(command, opts)
###########################################################################
@ -154,8 +150,7 @@ class EncryptionSetupTestCase(iotests.QMPTestCase):
# close the encrypted block device
def closeImageQmp(self, vm, id):
result = vm.qmp('blockdev-del', {'node-name': id})
self.assert_qmp(result, 'return', {})
vm.cmd('blockdev-del', {'node-name': id})
###########################################################################