python/qemu: rename command() to cmd()

Use a shorter name. We are going to move in iotests from qmp() to
command() where possible. But command() is longer than qmp() and don't
look better. Let's rename.

You can simply grep for '\.command(' and for 'def command(' to check
that everything is updated (command() in tests/docker/docker.py is
unrelated).

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Message-id: 20231006154125.1068348-6-vsementsov@yandex-team.ru
[vsementsov: also update three occurrences in
   tests/avocado/machine_aspeed.py and keep r-b]
Signed-off-by: John Snow <jsnow@redhat.com>
This commit is contained in:
Vladimir Sementsov-Ogievskiy 2023-10-06 18:41:15 +03:00 committed by John Snow
parent 37274707f6
commit 684750ab4f
29 changed files with 200 additions and 195 deletions

View file

@ -408,8 +408,8 @@ class LinuxSSHMixIn:
def ssh_connect(self, username, credential, credential_is_key=True):
self.ssh_logger = logging.getLogger('ssh')
res = self.vm.command('human-monitor-command',
command_line='info usernet')
res = self.vm.cmd('human-monitor-command',
command_line='info usernet')
port = get_info_usernet_hostfwd_port(res)
self.assertIsNotNone(port)
self.assertGreater(port, 0)

View file

@ -23,12 +23,13 @@ class QueryCPUModelExpansion(QemuSystemTest):
self.vm.add_args('-S')
self.vm.launch()
cpus = self.vm.command('query-cpu-definitions')
cpus = self.vm.cmd('query-cpu-definitions')
for c in cpus:
self.log.info("Checking CPU: %s", c)
self.assertNotIn('', c['unavailable-features'], c['name'])
for c in cpus:
model = {'name': c['name']}
e = self.vm.command('query-cpu-model-expansion', model=model, type='full')
e = self.vm.cmd('query-cpu-model-expansion', model=model,
type='full')
self.assertEquals(e['model']['name'], c['name'])

View file

@ -29,9 +29,9 @@ class HotPlugCPU(LinuxTest):
with self.assertRaises(AssertionError):
self.ssh_command('test -e /sys/devices/system/cpu/cpu1')
self.vm.command('device_add',
driver='Haswell-x86_64-cpu',
socket_id=0,
core_id=1,
thread_id=0)
self.vm.cmd('device_add',
driver='Haswell-x86_64-cpu',
socket_id=0,
core_id=1,
thread_id=0)
self.ssh_command('test -e /sys/devices/system/cpu/cpu1')

View file

@ -22,8 +22,8 @@ class InfoUsernet(QemuSystemTest):
self.require_netdev('user')
self.vm.add_args('-netdev', 'user,id=vnet,hostfwd=:127.0.0.1:0-:22')
self.vm.launch()
res = self.vm.command('human-monitor-command',
command_line='info usernet')
res = self.vm.cmd('human-monitor-command',
command_line='info usernet')
port = get_info_usernet_hostfwd_port(res)
self.assertIsNotNone(port,
('"info usernet" output content does not seem to '

View file

@ -81,9 +81,9 @@ class IntegratorMachine(QemuSystemTest):
self.boot_integratorcp()
framebuffer_ready = 'Console: switching to colour frame buffer device'
wait_for_console_pattern(self, framebuffer_ready)
self.vm.command('human-monitor-command', command_line='stop')
self.vm.command('human-monitor-command',
command_line='screendump %s' % screendump_path)
self.vm.cmd('human-monitor-command', command_line='stop')
self.vm.cmd('human-monitor-command',
command_line='screendump %s' % screendump_path)
logger = logging.getLogger('framebuffer')
cpu_count = 1

View file

@ -181,8 +181,8 @@ class AST2x00Machine(QemuSystemTest):
'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d');
exec_command_and_wait_for_pattern(self,
'cat /sys/class/hwmon/hwmon1/temp1_input', '0')
self.vm.command('qom-set', path='/machine/peripheral/tmp-test',
property='temperature', value=18000);
self.vm.cmd('qom-set', path='/machine/peripheral/tmp-test',
property='temperature', value=18000);
exec_command_and_wait_for_pattern(self,
'cat /sys/class/hwmon/hwmon1/temp1_input', '18000')
@ -213,8 +213,8 @@ class AST2x00Machine(QemuSystemTest):
'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d');
exec_command_and_wait_for_pattern(self,
'cat /sys/class/hwmon/hwmon0/temp1_input', '0')
self.vm.command('qom-set', path='/machine/peripheral/tmp-test',
property='temperature', value=18000);
self.vm.cmd('qom-set', path='/machine/peripheral/tmp-test',
property='temperature', value=18000);
exec_command_and_wait_for_pattern(self,
'cat /sys/class/hwmon/hwmon0/temp1_input', '18000')
@ -360,8 +360,8 @@ class AST2x00MachineSDK(QemuSystemTest, LinuxSSHMixIn):
'i2c i2c-5: new_device: Instantiated device lm75 at 0x4d');
self.ssh_command_output_contains(
'cat /sys/class/hwmon/hwmon19/temp1_input', '0')
self.vm.command('qom-set', path='/machine/peripheral/tmp-test',
property='temperature', value=18000);
self.vm.cmd('qom-set', path='/machine/peripheral/tmp-test',
property='temperature', value=18000);
self.ssh_command_output_contains(
'cat /sys/class/hwmon/hwmon19/temp1_input', '18000')

View file

@ -43,8 +43,8 @@ class NextCubeMachine(QemuSystemTest):
# 'displaysurface_create 1120x832' trace-event.
time.sleep(2)
self.vm.command('human-monitor-command',
command_line='screendump %s' % screenshot_path)
self.vm.cmd('human-monitor-command',
command_line='screendump %s' % screenshot_path)
@skipUnless(PIL_AVAILABLE, 'Python PIL not installed')
def test_bootrom_framebuffer_size(self):

View file

@ -71,9 +71,9 @@ class MaltaMachineFramebuffer(QemuSystemTest):
framebuffer_ready = 'Console: switching to colour frame buffer device'
wait_for_console_pattern(self, framebuffer_ready,
failure_message='Kernel panic - not syncing')
self.vm.command('human-monitor-command', command_line='stop')
self.vm.command('human-monitor-command',
command_line='screendump %s' % screendump_path)
self.vm.cmd('human-monitor-command', command_line='stop')
self.vm.cmd('human-monitor-command',
command_line='screendump %s' % screendump_path)
logger = logging.getLogger('framebuffer')
match_threshold = 0.95

View file

@ -107,10 +107,10 @@ class S390CCWVirtioMachine(QemuSystemTest):
'dd if=/dev/hwrng of=/dev/null bs=1k count=10',
'10+0 records out')
self.clear_guest_dmesg()
self.vm.command('device_del', id='rn1')
self.vm.cmd('device_del', id='rn1')
self.wait_for_crw_reports()
self.clear_guest_dmesg()
self.vm.command('device_del', id='rn2')
self.vm.cmd('device_del', id='rn2')
self.wait_for_crw_reports()
exec_command_and_wait_for_pattern(self,
'dd if=/dev/hwrng of=/dev/null bs=1k count=10',
@ -132,8 +132,8 @@ class S390CCWVirtioMachine(QemuSystemTest):
'0x0000000c')
# add another device
self.clear_guest_dmesg()
self.vm.command('device_add', driver='virtio-net-ccw',
devno='fe.0.4711', id='net_4711')
self.vm.cmd('device_add', driver='virtio-net-ccw',
devno='fe.0.4711', id='net_4711')
self.wait_for_crw_reports()
exec_command_and_wait_for_pattern(self, 'for i in 1 2 3 4 5 6 7 ; do '
'if [ -e /sys/bus/ccw/devices/*4711 ]; then break; fi ;'
@ -141,7 +141,7 @@ class S390CCWVirtioMachine(QemuSystemTest):
'0.0.4711')
# and detach it again
self.clear_guest_dmesg()
self.vm.command('device_del', id='net_4711')
self.vm.cmd('device_del', id='net_4711')
self.vm.event_wait(name='DEVICE_DELETED',
match={'data': {'device': 'net_4711'}})
self.wait_for_crw_reports()
@ -151,10 +151,10 @@ class S390CCWVirtioMachine(QemuSystemTest):
# test the virtio-balloon device
exec_command_and_wait_for_pattern(self, 'head -n 1 /proc/meminfo',
'MemTotal: 115640 kB')
self.vm.command('human-monitor-command', command_line='balloon 96')
self.vm.cmd('human-monitor-command', command_line='balloon 96')
exec_command_and_wait_for_pattern(self, 'head -n 1 /proc/meminfo',
'MemTotal: 82872 kB')
self.vm.command('human-monitor-command', command_line='balloon 128')
self.vm.cmd('human-monitor-command', command_line='balloon 128')
exec_command_and_wait_for_pattern(self, 'head -n 1 /proc/meminfo',
'MemTotal: 115640 kB')
@ -245,7 +245,7 @@ class S390CCWVirtioMachine(QemuSystemTest):
'12+0 records out')
with tempfile.NamedTemporaryFile(suffix='.ppm',
prefix='qemu-scrdump-') as ppmfile:
self.vm.command('screendump', filename=ppmfile.name)
self.vm.cmd('screendump', filename=ppmfile.name)
ppmfile.seek(0)
line = ppmfile.readline()
self.assertEqual(line, b"P6\n")
@ -261,16 +261,16 @@ class S390CCWVirtioMachine(QemuSystemTest):
# Hot-plug a virtio-crypto device and see whether it gets accepted
self.log.info("Test hot-plug virtio-crypto device")
self.clear_guest_dmesg()
self.vm.command('object-add', qom_type='cryptodev-backend-builtin',
id='cbe0')
self.vm.command('device_add', driver='virtio-crypto-ccw', id='crypdev0',
cryptodev='cbe0', devno='fe.0.2342')
self.vm.cmd('object-add', qom_type='cryptodev-backend-builtin',
id='cbe0')
self.vm.cmd('device_add', driver='virtio-crypto-ccw', id='crypdev0',
cryptodev='cbe0', devno='fe.0.2342')
exec_command_and_wait_for_pattern(self,
'while ! (dmesg -c | grep Accelerator.device) ; do'
' sleep 1 ; done', 'Accelerator device is ready')
exec_command_and_wait_for_pattern(self, 'lscss', '0.0.2342')
self.vm.command('device_del', id='crypdev0')
self.vm.command('object-del', id='cbe0')
self.vm.cmd('device_del', id='crypdev0')
self.vm.cmd('object-del', id='cbe0')
exec_command_and_wait_for_pattern(self,
'while ! (dmesg -c | grep Start.virtcrypto_remove) ; do'
' sleep 1 ; done', 'Start virtcrypto_remove.')

View file

@ -30,7 +30,7 @@ class MigrationTest(QemuSystemTest):
@staticmethod
def migration_finished(vm):
return vm.command('query-migrate')['status'] in ('completed', 'failed')
return vm.cmd('query-migrate')['status'] in ('completed', 'failed')
def assert_migration(self, src_vm, dst_vm):
wait.wait_for(self.migration_finished,
@ -41,10 +41,10 @@ class MigrationTest(QemuSystemTest):
timeout=self.timeout,
step=0.1,
args=(dst_vm,))
self.assertEqual(src_vm.command('query-migrate')['status'], 'completed')
self.assertEqual(dst_vm.command('query-migrate')['status'], 'completed')
self.assertEqual(dst_vm.command('query-status')['status'], 'running')
self.assertEqual(src_vm.command('query-status')['status'],'postmigrate')
self.assertEqual(src_vm.cmd('query-migrate')['status'], 'completed')
self.assertEqual(dst_vm.cmd('query-migrate')['status'], 'completed')
self.assertEqual(dst_vm.cmd('query-status')['status'], 'running')
self.assertEqual(src_vm.cmd('query-status')['status'],'postmigrate')
def do_migrate(self, dest_uri, src_uri=None):
dest_vm = self.get_vm('-incoming', dest_uri)

View file

@ -32,4 +32,4 @@ class OmittedCPUProps(QemuSystemTest):
self.vm.add_args('-smp', '1,sockets=2,cores=2,threads=2,maxcpus=8')
self.vm.add_args('-device', 'qemu64-x86_64-cpu,socket-id=1,core-id=0,thread-id=0')
self.vm.launch()
self.assertEquals(len(self.vm.command('query-cpus-fast')), 2)
self.assertEquals(len(self.vm.cmd('query-cpus-fast')), 2)

View file

@ -20,6 +20,6 @@ class Version(QemuSystemTest):
def test_qmp_human_info_version(self):
self.vm.add_args('-nodefaults')
self.vm.launch()
res = self.vm.command('human-monitor-command',
command_line='info version')
res = self.vm.cmd('human-monitor-command',
command_line='info version')
self.assertRegexpMatches(res, r'^(\d+\.\d+\.\d)')

View file

@ -51,8 +51,8 @@ class VirtioMaxSegSettingsCheck(QemuSystemTest):
error = None
props = None
output = vm.command('human-monitor-command',
command_line = 'info qtree')
output = vm.cmd('human-monitor-command',
command_line = 'info qtree')
props_list = DEV_TYPES[dev_type_name].values();
pattern = self.make_pattern(props_list)
res = re.findall(pattern, output)
@ -121,7 +121,7 @@ class VirtioMaxSegSettingsCheck(QemuSystemTest):
# collect all machine types except 'none', 'isapc', 'microvm'
with QEMUMachine(self.qemu_bin) as vm:
vm.launch()
machines = [m['name'] for m in vm.command('query-machines')]
machines = [m['name'] for m in vm.cmd('query-machines')]
vm.shutdown()
machines.remove('none')
machines.remove('isapc')

View file

@ -48,7 +48,8 @@ def pci_modern_device_id(virtio_devid):
return virtio_devid + 0x1040
def devtype_implements(vm, devtype, implements):
return devtype in [d['name'] for d in vm.command('qom-list-types', implements=implements)]
return devtype in [d['name'] for d in
vm.cmd('qom-list-types', implements=implements)]
def get_pci_interfaces(vm, devtype):
interfaces = ('pci-express-device', 'conventional-pci-device')
@ -78,7 +79,7 @@ class VirtioVersionCheck(QemuSystemTest):
vm.add_args('-S')
vm.launch()
pcibuses = vm.command('query-pci')
pcibuses = vm.cmd('query-pci')
alldevs = [dev for bus in pcibuses for dev in bus['devices']]
devfortest = [dev for dev in alldevs
if dev['qdev_id'] == 'devfortest']

View file

@ -84,7 +84,8 @@ class X86CPUModelAliases(avocado_qemu.QemuSystemTest):
# with older QEMU versions that didn't have the versioned CPU model
self.vm.add_args('-S')
self.vm.launch()
cpus = dict((m['name'], m) for m in self.vm.command('query-cpu-definitions'))
cpus = dict((m['name'], m) for m in
self.vm.cmd('query-cpu-definitions'))
self.assertFalse(cpus['Cascadelake-Server']['static'],
'unversioned Cascadelake-Server CPU model must not be static')
@ -115,7 +116,8 @@ class X86CPUModelAliases(avocado_qemu.QemuSystemTest):
self.vm.add_args('-S')
self.vm.launch()
cpus = dict((m['name'], m) for m in self.vm.command('query-cpu-definitions'))
cpus = dict((m['name'], m) for m in
self.vm.cmd('query-cpu-definitions'))
self.assertFalse(cpus['Cascadelake-Server']['static'],
'unversioned Cascadelake-Server CPU model must not be static')
@ -220,7 +222,8 @@ class X86CPUModelAliases(avocado_qemu.QemuSystemTest):
self.vm.add_args('-S')
self.vm.launch()
cpus = dict((m['name'], m) for m in self.vm.command('query-cpu-definitions'))
cpus = dict((m['name'], m) for m in
self.vm.cmd('query-cpu-definitions'))
self.assertFalse(cpus['Cascadelake-Server']['static'],
'unversioned Cascadelake-Server CPU model must not be static')
@ -246,8 +249,8 @@ class CascadelakeArchCapabilities(avocado_qemu.QemuSystemTest):
:avocado: tags=arch:x86_64
"""
def get_cpu_prop(self, prop):
cpu_path = self.vm.command('query-cpus-fast')[0].get('qom-path')
return self.vm.command('qom-get', path=cpu_path, property=prop)
cpu_path = self.vm.cmd('query-cpus-fast')[0].get('qom-path')
return self.vm.cmd('qom-get', path=cpu_path, property=prop)
def test_4_1(self):
"""