Python queue 2019-12-17

-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEeruW64tGuU1eD+m7ZX6NM6XyCfMFAl34Y8sACgkQZX6NM6Xy
 CfOcRA/+PnbiBHQXJgbRlEUzcwUYkCrtnZYV8Lrvq8+2tiW5x1CR6f64jnap/w50
 gEUvbrkfLFG5U5OOgpPGDmcyFXM7380uj5nqQL2ZEC945YMimQaGJg/B9mV6gSkl
 Rz1y4/y58Lre5zrPAIjEkytMrMgtp0VgT6Lblp7FslxAIlpqwwDNSz2rY8VoAkob
 RnOihiuMGUrcF4WNSKPj94AS+EJZLfeJDrVpy/yadfdEs1NskeZNDkl+vGeV2M64
 qgxr/zQtKL1o58nnrj/Ro5fKYbgcoF43YhF7KbW7GfetbZmF7WagO3sp8HfDNNaH
 dzM1/9yQsOXVlRDhtu3G96N6gTVdQGYPqjlYQJpYuOizVMxzAG8OIQVn9PdYO48x
 CAXoO0FBBpI5krez6F4RaUXhHzEkhbkUZMwZyX482xNoeTnsnMvyB278/DKuYoXV
 A1CE+zLfABNn69oe1z10WpyetlJ4J4y+9MWJhqpKgY9tvFF6ZfMmlkxHPsblkOCL
 6MDZoThYYdeCot0DaX/rPT0rK+SJA6kg0sbfdGqvmBEL1LsqhWvqXuG/mxl0nHoU
 Mq+0tDdrs/6lGhShhgGo2+ceONtHiywI1oKBt/A6tVA2lmhJOipV+3d6ISnhR4kq
 pPJtbCziVv9kNvuYvmEnUGn5HzLOgYfzMoB7e9tCMS6+8lH2jd8=
 =4LJa
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/cleber/tags/python-next-pull-request' into staging

Python queue 2019-12-17

# gpg: Signature made Tue 17 Dec 2019 05:12:43 GMT
# gpg:                using RSA key 7ABB96EB8B46B94D5E0FE9BB657E8D33A5F209F3
# gpg: Good signature from "Cleber Rosa <crosa@redhat.com>" [marginal]
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 7ABB 96EB 8B46 B94D 5E0F  E9BB 657E 8D33 A5F2 09F3

* remotes/cleber/tags/python-next-pull-request:
  python/qemu: Remove unneeded imports in __init__
  python/qemu: accel: Add tcg_available() method
  python/qemu: accel: Strengthen kvm_available() checks
  python/qemu: accel: Add list_accel() method
  python/qemu: Move kvm_available() to its own module
  Acceptance tests: use relative location for tests
  Acceptance tests: use avocado tags for machine type
  Acceptance tests: introduce utility method for tags unique vals
  Acceptance test x86_cpu_model_versions: use default vm
  tests/acceptance: Makes linux_initrd and empty_cpu_model use QEMUMachine
  python/qemu: Add set_qmp_monitor() to QEMUMachine
  analyze-migration.py: replace numpy with python 3.2
  analyze-migration.py: fix find() type error
  Revert "Acceptance test: cancel test if m68k kernel packages goes missing"
  tests/boot_linux_console: Fetch assets from Debian snapshot archives

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2019-12-17 14:34:31 +00:00
commit f6e7a97acb
17 changed files with 284 additions and 197 deletions

View File

@ -746,6 +746,17 @@ name. If one is not given explicitly, it will either be set to
``None``, or, if the test is tagged with one (and only one) ``None``, or, if the test is tagged with one (and only one)
``:avocado: tags=arch:VALUE`` tag, it will be set to ``VALUE``. ``:avocado: tags=arch:VALUE`` tag, it will be set to ``VALUE``.
machine
~~~~~~~
The machine type that will be set to all QEMUMachine instances created
by the test.
The ``machine`` attribute will be set to the test parameter of the same
name. If one is not given explicitly, it will either be set to
``None``, or, if the test is tagged with one (and only one)
``:avocado: tags=machine:VALUE`` tag, it will be set to ``VALUE``.
qemu_bin qemu_bin
~~~~~~~~ ~~~~~~~~
@ -781,6 +792,13 @@ architecture of a kernel or disk image to boot a VM with.
This parameter has a direct relation with the ``arch`` attribute. If This parameter has a direct relation with the ``arch`` attribute. If
not given, it will default to None. not given, it will default to None.
machine
~~~~~~~
The machine type that will be set to all QEMUMachine instances created
by the test.
qemu_bin qemu_bin
~~~~~~~~ ~~~~~~~~

View File

@ -9,27 +9,3 @@
# This work is licensed under the terms of the GNU GPL, version 2. See # This work is licensed under the terms of the GNU GPL, version 2. See
# the COPYING file in the top-level directory. # the COPYING file in the top-level directory.
# #
# Based on qmp.py.
#
import logging
import os
from . import qmp
from . import machine
LOG = logging.getLogger(__name__)
# Mapping host architecture to any additional architectures it can
# support which often includes its 32 bit cousin.
ADDITIONAL_ARCHES = {
"x86_64" : "i386",
"aarch64" : "armhf"
}
def kvm_available(target_arch=None):
host_arch = os.uname()[4]
if target_arch and target_arch != host_arch:
if target_arch != ADDITIONAL_ARCHES.get(host_arch):
return False
return os.access("/dev/kvm", os.R_OK | os.W_OK)

77
python/qemu/accel.py Normal file
View File

@ -0,0 +1,77 @@
"""
QEMU accel module:
This module provides utilities for discover and check the availability of
accelerators.
"""
# Copyright (C) 2015-2016 Red Hat Inc.
# Copyright (C) 2012 IBM Corp.
#
# Authors:
# Fam Zheng <famz@redhat.com>
#
# This work is licensed under the terms of the GNU GPL, version 2. See
# the COPYING file in the top-level directory.
#
import logging
import os
import subprocess
LOG = logging.getLogger(__name__)
# Mapping host architecture to any additional architectures it can
# support which often includes its 32 bit cousin.
ADDITIONAL_ARCHES = {
"x86_64" : "i386",
"aarch64" : "armhf"
}
def list_accel(qemu_bin):
"""
List accelerators enabled in the QEMU binary.
@param qemu_bin (str): path to the QEMU binary.
@raise Exception: if failed to run `qemu -accel help`
@return a list of accelerator names.
"""
if not qemu_bin:
return []
try:
out = subprocess.check_output([qemu_bin, '-accel', 'help'],
universal_newlines=True)
except:
LOG.debug("Failed to get the list of accelerators in %s", qemu_bin)
raise
# Skip the first line which is the header.
return [acc.strip() for acc in out.splitlines()[1:]]
def kvm_available(target_arch=None, qemu_bin=None):
"""
Check if KVM is available using the following heuristic:
- Kernel module is present in the host;
- Target and host arches don't mismatch;
- KVM is enabled in the QEMU binary.
@param target_arch (str): target architecture
@param qemu_bin (str): path to the QEMU binary
@return True if kvm is available, otherwise False.
"""
if not os.access("/dev/kvm", os.R_OK | os.W_OK):
return False
if target_arch:
host_arch = os.uname()[4]
if target_arch != host_arch:
if target_arch != ADDITIONAL_ARCHES.get(host_arch):
return False
if qemu_bin and "kvm" not in list_accel(qemu_bin):
return False
return True
def tcg_available(qemu_bin):
"""
Check if TCG is available.
@param qemu_bin (str): path to the QEMU binary
"""
return 'tcg' in list_accel(qemu_bin)

View File

@ -104,6 +104,7 @@ class QEMUMachine(object):
self._events = [] self._events = []
self._iolog = None self._iolog = None
self._socket_scm_helper = socket_scm_helper self._socket_scm_helper = socket_scm_helper
self._qmp_set = True # Enable QMP monitor by default.
self._qmp = None self._qmp = None
self._qemu_full_args = None self._qemu_full_args = None
self._test_dir = test_dir self._test_dir = test_dir
@ -228,15 +229,16 @@ class QEMUMachine(object):
self._iolog = iolog.read() self._iolog = iolog.read()
def _base_args(self): def _base_args(self):
if isinstance(self._monitor_address, tuple): args = ['-display', 'none', '-vga', 'none']
moncdev = "socket,id=mon,host=%s,port=%s" % ( if self._qmp_set:
self._monitor_address[0], if isinstance(self._monitor_address, tuple):
self._monitor_address[1]) moncdev = "socket,id=mon,host=%s,port=%s" % (
else: self._monitor_address[0],
moncdev = 'socket,id=mon,path=%s' % self._vm_monitor self._monitor_address[1])
args = ['-chardev', moncdev, else:
'-mon', 'chardev=mon,mode=control', moncdev = 'socket,id=mon,path=%s' % self._vm_monitor
'-display', 'none', '-vga', 'none'] args.extend(['-chardev', moncdev, '-mon',
'chardev=mon,mode=control'])
if self._machine is not None: if self._machine is not None:
args.extend(['-machine', self._machine]) args.extend(['-machine', self._machine])
if self._console_set: if self._console_set:
@ -255,20 +257,21 @@ class QEMUMachine(object):
def _pre_launch(self): def _pre_launch(self):
self._temp_dir = tempfile.mkdtemp(dir=self._test_dir) self._temp_dir = tempfile.mkdtemp(dir=self._test_dir)
if self._monitor_address is not None:
self._vm_monitor = self._monitor_address
else:
self._vm_monitor = os.path.join(self._sock_dir,
self._name + "-monitor.sock")
self._remove_files.append(self._vm_monitor)
self._qemu_log_path = os.path.join(self._temp_dir, self._name + ".log") self._qemu_log_path = os.path.join(self._temp_dir, self._name + ".log")
self._qemu_log_file = open(self._qemu_log_path, 'wb') self._qemu_log_file = open(self._qemu_log_path, 'wb')
self._qmp = qmp.QEMUMonitorProtocol(self._vm_monitor, if self._qmp_set:
server=True) if self._monitor_address is not None:
self._vm_monitor = self._monitor_address
else:
self._vm_monitor = os.path.join(self._sock_dir,
self._name + "-monitor.sock")
self._remove_files.append(self._vm_monitor)
self._qmp = qmp.QEMUMonitorProtocol(self._vm_monitor, server=True)
def _post_launch(self): def _post_launch(self):
self._qmp.accept() if self._qmp:
self._qmp.accept()
def _post_shutdown(self): def _post_shutdown(self):
if self._qemu_log_file is not None: if self._qemu_log_file is not None:
@ -330,7 +333,8 @@ class QEMUMachine(object):
Wait for the VM to power off Wait for the VM to power off
""" """
self._popen.wait() self._popen.wait()
self._qmp.close() if self._qmp:
self._qmp.close()
self._load_io_log() self._load_io_log()
self._post_shutdown() self._post_shutdown()
@ -346,12 +350,13 @@ class QEMUMachine(object):
self._console_socket = None self._console_socket = None
if self.is_running(): if self.is_running():
try: if self._qmp:
if not has_quit: try:
self._qmp.cmd('quit') if not has_quit:
self._qmp.close() self._qmp.cmd('quit')
except: self._qmp.close()
self._popen.kill() except:
self._popen.kill()
self._popen.wait() self._popen.wait()
self._load_io_log() self._load_io_log()
@ -368,6 +373,21 @@ class QEMUMachine(object):
self._launched = False self._launched = False
def set_qmp_monitor(self, enabled=True):
"""
Set the QMP monitor.
@param enabled: if False, qmp monitor options will be removed from
the base arguments of the resulting QEMU command
line. Default is True.
@note: call this function before launch().
"""
if enabled:
self._qmp_set = True
else:
self._qmp_set = False
self._qmp = None
def qmp(self, cmd, conv_keys=True, **args): def qmp(self, cmd, conv_keys=True, **args):
""" """
Invoke a QMP command and return the response dict Invoke a QMP command and return the response dict

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# #
# Migration Stream Analyzer # Migration Stream Analyzer
# #
@ -17,12 +17,18 @@
# You should have received a copy of the GNU Lesser General Public # You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, see <http://www.gnu.org/licenses/>. # License along with this library; if not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import numpy as np
import json import json
import os import os
import argparse import argparse
import collections import collections
import struct
import sys
MIN_PYTHON = (3, 2)
if sys.version_info < MIN_PYTHON:
sys.exit("Python %s.%s or later is required.\n" % MIN_PYTHON)
def mkdir_p(path): def mkdir_p(path):
try: try:
@ -30,29 +36,26 @@ def mkdir_p(path):
except OSError: except OSError:
pass pass
class MigrationFile(object): class MigrationFile(object):
def __init__(self, filename): def __init__(self, filename):
self.filename = filename self.filename = filename
self.file = open(self.filename, "rb") self.file = open(self.filename, "rb")
def read64(self): def read64(self):
return np.asscalar(np.fromfile(self.file, count=1, dtype='>i8')[0]) return int.from_bytes(self.file.read(8), byteorder='big', signed=True)
def read32(self): def read32(self):
return np.asscalar(np.fromfile(self.file, count=1, dtype='>i4')[0]) return int.from_bytes(self.file.read(4), byteorder='big', signed=True)
def read16(self): def read16(self):
return np.asscalar(np.fromfile(self.file, count=1, dtype='>i2')[0]) return int.from_bytes(self.file.read(2), byteorder='big', signed=True)
def read8(self): def read8(self):
return np.asscalar(np.fromfile(self.file, count=1, dtype='>i1')[0]) return int.from_bytes(self.file.read(1), byteorder='big', signed=True)
def readstr(self, len = None): def readstr(self, len = None):
if len is None: return self.readvar(len).decode('utf-8')
len = self.read8()
if len == 0:
return ""
return np.fromfile(self.file, count=1, dtype=('S%d' % len))[0]
def readvar(self, size = None): def readvar(self, size = None):
if size is None: if size is None:
@ -86,8 +89,8 @@ class MigrationFile(object):
# Find the last NULL byte, then the first brace after that. This should # Find the last NULL byte, then the first brace after that. This should
# be the beginning of our JSON data. # be the beginning of our JSON data.
nulpos = data.rfind("\0") nulpos = data.rfind(b'\0')
jsonpos = data.find("{", nulpos) jsonpos = data.find(b'{', nulpos)
# Check backwards from there and see whether we guessed right # Check backwards from there and see whether we guessed right
self.file.seek(datapos + jsonpos - 5, 0) self.file.seek(datapos + jsonpos - 5, 0)
@ -275,7 +278,7 @@ class VMSDFieldGeneric(object):
return str(self.__str__()) return str(self.__str__())
def __str__(self): def __str__(self):
return " ".join("{0:02x}".format(ord(c)) for c in self.data) return " ".join("{0:02x}".format(c) for c in self.data)
def getDict(self): def getDict(self):
return self.__str__() return self.__str__()
@ -307,8 +310,8 @@ class VMSDFieldInt(VMSDFieldGeneric):
def read(self): def read(self):
super(VMSDFieldInt, self).read() super(VMSDFieldInt, self).read()
self.sdata = np.fromstring(self.data, count=1, dtype=(self.sdtype))[0] self.sdata = int.from_bytes(self.data, byteorder='big', signed=True)
self.udata = np.fromstring(self.data, count=1, dtype=(self.udtype))[0] self.udata = int.from_bytes(self.data, byteorder='big', signed=False)
self.data = self.sdata self.data = self.sdata
return self.data return self.data
@ -363,7 +366,7 @@ class VMSDFieldStruct(VMSDFieldGeneric):
array_len = field.pop('array_len') array_len = field.pop('array_len')
field['index'] = 0 field['index'] = 0
new_fields.append(field) new_fields.append(field)
for i in xrange(1, array_len): for i in range(1, array_len):
c = field.copy() c = field.copy()
c['index'] = i c['index'] = i
new_fields.append(c) new_fields.append(c)

View File

@ -1185,7 +1185,7 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR)
--show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \ --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \
--filter-by-tags-include-empty --filter-by-tags-include-empty-key \ --filter-by-tags-include-empty --filter-by-tags-include-empty-key \
$(AVOCADO_TAGS) \ $(AVOCADO_TAGS) \
--failfast=on $(SRC_PATH)/tests/acceptance, \ --failfast=on tests/acceptance, \
"AVOCADO", "tests/acceptance") "AVOCADO", "tests/acceptance")
# Consolidated targets # Consolidated targets

View File

@ -100,14 +100,24 @@ def exec_command_and_wait_for_pattern(test, command,
class Test(avocado.Test): class Test(avocado.Test):
def _get_unique_tag_val(self, tag_name):
"""
Gets a tag value, if unique for a key
"""
vals = self.tags.get(tag_name, [])
if len(vals) == 1:
return vals.pop()
return None
def setUp(self): def setUp(self):
self._vms = {} self._vms = {}
arches = self.tags.get('arch', [])
if len(arches) == 1: self.arch = self.params.get('arch',
arch = arches.pop() default=self._get_unique_tag_val('arch'))
else:
arch = None self.machine = self.params.get('machine',
self.arch = self.params.get('arch', default=arch) default=self._get_unique_tag_val('machine'))
default_qemu_bin = pick_default_qemu_bin(arch=self.arch) default_qemu_bin = pick_default_qemu_bin(arch=self.arch)
self.qemu_bin = self.params.get('qemu_bin', self.qemu_bin = self.params.get('qemu_bin',
default=default_qemu_bin) default=default_qemu_bin)
@ -129,6 +139,8 @@ class Test(avocado.Test):
name = str(uuid.uuid4()) name = str(uuid.uuid4())
if self._vms.get(name) is None: if self._vms.get(name) is None:
self._vms[name] = self._new_vm(*args) self._vms[name] = self._new_vm(*args)
if self.machine is not None:
self._vms[name].set_machine(self.machine)
return self._vms[name] return self._vms[name]
def tearDown(self): def tearDown(self):

View File

@ -62,7 +62,6 @@ class BootLinuxConsole(Test):
kernel_hash = '23bebd2680757891cf7adedb033532163a792495' kernel_hash = '23bebd2680757891cf7adedb033532163a792495'
kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
self.vm.set_machine('pc')
self.vm.set_console() self.vm.set_console()
kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
self.vm.add_args('-kernel', kernel_path, self.vm.add_args('-kernel', kernel_path,
@ -85,7 +84,6 @@ class BootLinuxConsole(Test):
kernel_path = self.extract_from_deb(deb_path, kernel_path = self.extract_from_deb(deb_path,
'/boot/vmlinux-2.6.32-5-4kc-malta') '/boot/vmlinux-2.6.32-5-4kc-malta')
self.vm.set_machine('malta')
self.vm.set_console() self.vm.set_console()
kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
self.vm.add_args('-kernel', kernel_path, self.vm.add_args('-kernel', kernel_path,
@ -118,7 +116,6 @@ class BootLinuxConsole(Test):
kernel_path = self.extract_from_deb(deb_path, kernel_path = self.extract_from_deb(deb_path,
'/boot/vmlinux-2.6.32-5-5kc-malta') '/boot/vmlinux-2.6.32-5-5kc-malta')
self.vm.set_machine('malta')
self.vm.set_console() self.vm.set_console()
kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
self.vm.add_args('-kernel', kernel_path, self.vm.add_args('-kernel', kernel_path,
@ -148,7 +145,6 @@ class BootLinuxConsole(Test):
initrd_path = self.workdir + "rootfs.cpio" initrd_path = self.workdir + "rootfs.cpio"
archive.gzip_uncompress(initrd_path_gz, initrd_path) archive.gzip_uncompress(initrd_path_gz, initrd_path)
self.vm.set_machine('malta')
self.vm.set_console() self.vm.set_console()
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
+ 'console=ttyS0 console=tty ' + 'console=ttyS0 console=tty '
@ -188,7 +184,6 @@ class BootLinuxConsole(Test):
initrd_path = self.workdir + "rootfs.cpio" initrd_path = self.workdir + "rootfs.cpio"
archive.gzip_uncompress(initrd_path_gz, initrd_path) archive.gzip_uncompress(initrd_path_gz, initrd_path)
self.vm.set_machine('malta')
self.vm.set_console() self.vm.set_console()
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
+ 'console=ttyS0 console=tty ' + 'console=ttyS0 console=tty '
@ -215,7 +210,6 @@ class BootLinuxConsole(Test):
with open(kernel_path, 'wb') as f_out: with open(kernel_path, 'wb') as f_out:
shutil.copyfileobj(f_in, f_out) shutil.copyfileobj(f_in, f_out)
self.vm.set_machine('malta')
self.vm.set_console() self.vm.set_console()
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
+ 'mem=256m@@0x0 ' + 'mem=256m@@0x0 '
@ -275,7 +269,6 @@ class BootLinuxConsole(Test):
kernel_hash = '8c73e469fc6ea06a58dc83a628fc695b693b8493' kernel_hash = '8c73e469fc6ea06a58dc83a628fc695b693b8493'
kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
self.vm.set_machine('virt')
self.vm.set_console() self.vm.set_console()
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
'console=ttyAMA0') 'console=ttyAMA0')
@ -297,7 +290,6 @@ class BootLinuxConsole(Test):
kernel_hash = 'e9826d741b4fb04cadba8d4824d1ed3b7fb8b4d4' kernel_hash = 'e9826d741b4fb04cadba8d4824d1ed3b7fb8b4d4'
kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
self.vm.set_machine('virt')
self.vm.set_console() self.vm.set_console()
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
'console=ttyAMA0') 'console=ttyAMA0')
@ -310,7 +302,7 @@ class BootLinuxConsole(Test):
def test_arm_emcraft_sf2(self): def test_arm_emcraft_sf2(self):
""" """
:avocado: tags=arch:arm :avocado: tags=arch:arm
:avocado: tags=machine:emcraft_sf2 :avocado: tags=machine:emcraft-sf2
:avocado: tags=endian:little :avocado: tags=endian:little
""" """
uboot_url = ('https://raw.githubusercontent.com/' uboot_url = ('https://raw.githubusercontent.com/'
@ -324,7 +316,6 @@ class BootLinuxConsole(Test):
spi_hash = '85f698329d38de63aea6e884a86fbde70890a78a' spi_hash = '85f698329d38de63aea6e884a86fbde70890a78a'
spi_path = self.fetch_asset(spi_url, asset_hash=spi_hash) spi_path = self.fetch_asset(spi_url, asset_hash=spi_hash)
self.vm.set_machine('emcraft-sf2')
self.vm.set_console() self.vm.set_console()
kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE
self.vm.add_args('-kernel', uboot_path, self.vm.add_args('-kernel', uboot_path,
@ -351,7 +342,6 @@ class BootLinuxConsole(Test):
kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img') kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img')
dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb') dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb')
self.vm.set_machine('raspi2')
self.vm.set_console() self.vm.set_console()
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
serial_kernel_cmdline[uart_id]) serial_kernel_cmdline[uart_id])
@ -393,7 +383,6 @@ class BootLinuxConsole(Test):
initrd_path = os.path.join(self.workdir, 'rootfs.cpio') initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
archive.gzip_uncompress(initrd_path_gz, initrd_path) archive.gzip_uncompress(initrd_path_gz, initrd_path)
self.vm.set_machine('smdkc210')
self.vm.set_console() self.vm.set_console()
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
'earlycon=exynos4210,0x13800000 earlyprintk ' + 'earlycon=exynos4210,0x13800000 earlyprintk ' +
@ -414,7 +403,7 @@ class BootLinuxConsole(Test):
def test_s390x_s390_ccw_virtio(self): def test_s390x_s390_ccw_virtio(self):
""" """
:avocado: tags=arch:s390x :avocado: tags=arch:s390x
:avocado: tags=machine:s390_ccw_virtio :avocado: tags=machine:s390-ccw-virtio
""" """
kernel_url = ('https://archives.fedoraproject.org/pub/archive' kernel_url = ('https://archives.fedoraproject.org/pub/archive'
'/fedora-secondary/releases/29/Everything/s390x/os/images' '/fedora-secondary/releases/29/Everything/s390x/os/images'
@ -422,7 +411,6 @@ class BootLinuxConsole(Test):
kernel_hash = 'e8e8439103ef8053418ef062644ffd46a7919313' kernel_hash = 'e8e8439103ef8053418ef062644ffd46a7919313'
kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
self.vm.set_machine('s390-ccw-virtio')
self.vm.set_console() self.vm.set_console()
kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=sclp0' kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=sclp0'
self.vm.add_args('-nodefaults', self.vm.add_args('-nodefaults',
@ -444,7 +432,6 @@ class BootLinuxConsole(Test):
uncompressed_kernel = archive.uncompress(kernel_path, self.workdir) uncompressed_kernel = archive.uncompress(kernel_path, self.workdir)
self.vm.set_machine('clipper')
self.vm.set_console() self.vm.set_console()
kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
self.vm.add_args('-vga', 'std', self.vm.add_args('-vga', 'std',
@ -465,7 +452,6 @@ class BootLinuxConsole(Test):
kernel_hash = '3fe04abfc852b66653b8c3c897a59a689270bc77' kernel_hash = '3fe04abfc852b66653b8c3c897a59a689270bc77'
kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
self.vm.set_machine('pseries')
self.vm.set_console() self.vm.set_console()
kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=hvc0' kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=hvc0'
self.vm.add_args('-kernel', kernel_path, self.vm.add_args('-kernel', kernel_path,
@ -479,17 +465,14 @@ class BootLinuxConsole(Test):
:avocado: tags=arch:m68k :avocado: tags=arch:m68k
:avocado: tags=machine:q800 :avocado: tags=machine:q800
""" """
deb_url = ('http://ftp.ports.debian.org/debian-ports/pool-m68k/main' deb_url = ('https://snapshot.debian.org/archive/debian-ports'
'/20191021T083923Z/pool-m68k/main'
'/l/linux/kernel-image-5.3.0-1-m68k-di_5.3.7-1_m68k.udeb') '/l/linux/kernel-image-5.3.0-1-m68k-di_5.3.7-1_m68k.udeb')
deb_hash = '044954bb9be4160a3ce81f8bc1b5e856b75cccd1' deb_hash = '044954bb9be4160a3ce81f8bc1b5e856b75cccd1'
try: deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
except OSError as exp:
self.cancel(exp)
kernel_path = self.extract_from_deb(deb_path, kernel_path = self.extract_from_deb(deb_path,
'/boot/vmlinux-5.3.0-1-m68k') '/boot/vmlinux-5.3.0-1-m68k')
self.vm.set_machine('q800')
self.vm.set_console() self.vm.set_console()
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
'console=ttyS0 vga=off') 'console=ttyS0 vga=off')

View File

@ -20,8 +20,8 @@ class QueryCPUModelExpansion(Test):
def test(self): def test(self):
""" """
:avocado: tags=arch:x86_64 :avocado: tags=arch:x86_64
:avocado: tags=machine:none
""" """
self.vm.set_machine('none')
self.vm.add_args('-S') self.vm.add_args('-S')
self.vm.launch() self.vm.launch()

View File

@ -7,13 +7,13 @@
# #
# This work is licensed under the terms of the GNU GPL, version 2 or # This work is licensed under the terms of the GNU GPL, version 2 or
# later. See the COPYING file in the top-level directory. # later. See the COPYING file in the top-level directory.
import subprocess
from avocado_qemu import Test from avocado_qemu import Test
class EmptyCPUModel(Test): class EmptyCPUModel(Test):
def test(self): def test(self):
cmd = [self.qemu_bin, '-S', '-display', 'none', '-machine', 'none', '-cpu', ''] self.vm.add_args('-S', '-display', 'none', '-machine', 'none', '-cpu', '')
r = subprocess.run(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE) self.vm.set_qmp_monitor(enabled=False)
self.assertEquals(r.returncode, 1, "QEMU exit code should be 1") self.vm.launch()
self.assertEquals(r.stdout, b'', "QEMU stdout should be empty") self.vm.wait()
self.assertNotEquals(r.stderr, b'', "QEMU stderr shouldn't be empty") self.assertEquals(self.vm.exitcode(), 1, "QEMU exit code should be 1")
self.assertRegex(self.vm.get_log(), r'-cpu option cannot be empty')

View File

@ -10,7 +10,6 @@
import logging import logging
import tempfile import tempfile
from avocado.utils.process import run
from avocado_qemu import Test from avocado_qemu import Test
@ -20,6 +19,7 @@ class LinuxInitrd(Test):
Checks QEMU evaluates correctly the initrd file passed as -initrd option. Checks QEMU evaluates correctly the initrd file passed as -initrd option.
:avocado: tags=arch:x86_64 :avocado: tags=arch:x86_64
:avocado: tags=machine:pc
""" """
timeout = 300 timeout = 300
@ -41,13 +41,15 @@ class LinuxInitrd(Test):
initrd.seek(max_size) initrd.seek(max_size)
initrd.write(b'\0') initrd.write(b'\0')
initrd.flush() initrd.flush()
cmd = "%s -kernel %s -initrd %s -m 4096" % ( self.vm.add_args('-kernel', kernel_path, '-initrd', initrd.name,
self.qemu_bin, kernel_path, initrd.name) '-m', '4096')
res = run(cmd, ignore_status=True) self.vm.set_qmp_monitor(enabled=False)
self.assertEqual(res.exit_status, 1) self.vm.launch()
self.vm.wait()
self.assertEqual(self.vm.exitcode(), 1)
expected_msg = r'.*initrd is too large.*max: \d+, need %s.*' % ( expected_msg = r'.*initrd is too large.*max: \d+, need %s.*' % (
max_size + 1) max_size + 1)
self.assertRegex(res.stderr_text, expected_msg) self.assertRegex(self.vm.get_log(), expected_msg)
def test_with_2gib_file_should_work_with_linux_v4_16(self): def test_with_2gib_file_should_work_with_linux_v4_16(self):
""" """
@ -66,7 +68,6 @@ class LinuxInitrd(Test):
initrd.write(b'\0') initrd.write(b'\0')
initrd.flush() initrd.flush()
self.vm.set_machine('pc')
self.vm.set_console() self.vm.set_console()
kernel_command_line = 'console=ttyS0' kernel_command_line = 'console=ttyS0'
self.vm.add_args('-kernel', kernel_path, self.vm.add_args('-kernel', kernel_path,

View File

@ -113,7 +113,6 @@ class LinuxSSH(Test):
image_url, image_hash = self.get_image_info(endianess) image_url, image_hash = self.get_image_info(endianess)
image_path = self.fetch_asset(image_url, asset_hash=image_hash) image_path = self.fetch_asset(image_url, asset_hash=image_hash)
self.vm.set_machine('malta')
self.vm.set_console() self.vm.set_console()
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
+ 'console=ttyS0 root=/dev/sda1') + 'console=ttyS0 root=/dev/sda1')
@ -217,7 +216,6 @@ class LinuxSSH(Test):
def test_mips_malta32eb_kernel3_2_0(self): def test_mips_malta32eb_kernel3_2_0(self):
""" """
:avocado: tags=arch:mips :avocado: tags=arch:mips
:avocado: tags=machine:malta
:avocado: tags=endian:big :avocado: tags=endian:big
:avocado: tags=device:pcnet32 :avocado: tags=device:pcnet32
""" """
@ -226,7 +224,6 @@ class LinuxSSH(Test):
def test_mips_malta32el_kernel3_2_0(self): def test_mips_malta32el_kernel3_2_0(self):
""" """
:avocado: tags=arch:mipsel :avocado: tags=arch:mipsel
:avocado: tags=machine:malta
:avocado: tags=endian:little :avocado: tags=endian:little
:avocado: tags=device:pcnet32 :avocado: tags=device:pcnet32
""" """
@ -235,7 +232,6 @@ class LinuxSSH(Test):
def test_mips_malta64eb_kernel3_2_0(self): def test_mips_malta64eb_kernel3_2_0(self):
""" """
:avocado: tags=arch:mips64 :avocado: tags=arch:mips64
:avocado: tags=machine:malta
:avocado: tags=endian:big :avocado: tags=endian:big
:avocado: tags=device:pcnet32 :avocado: tags=device:pcnet32
""" """
@ -244,7 +240,6 @@ class LinuxSSH(Test):
def test_mips_malta64el_kernel3_2_0(self): def test_mips_malta64el_kernel3_2_0(self):
""" """
:avocado: tags=arch:mips64el :avocado: tags=arch:mips64el
:avocado: tags=machine:malta
:avocado: tags=endian:little :avocado: tags=endian:little
:avocado: tags=device:pcnet32 :avocado: tags=device:pcnet32
""" """

View File

@ -43,6 +43,11 @@ def tesseract_available(expected_version):
class NextCubeMachine(Test): class NextCubeMachine(Test):
"""
:avocado: tags=arch:m68k
:avocado: tags=machine:next-cube
:avocado: tags=device:framebuffer
"""
timeout = 15 timeout = 15
@ -52,7 +57,6 @@ class NextCubeMachine(Test):
rom_hash = 'b3534796abae238a0111299fc406a9349f7fee24' rom_hash = 'b3534796abae238a0111299fc406a9349f7fee24'
rom_path = self.fetch_asset(rom_url, asset_hash=rom_hash) rom_path = self.fetch_asset(rom_url, asset_hash=rom_hash)
self.vm.set_machine('next-cube')
self.vm.add_args('-bios', rom_path) self.vm.add_args('-bios', rom_path)
self.vm.launch() self.vm.launch()
@ -66,11 +70,6 @@ class NextCubeMachine(Test):
@skipUnless(PIL_AVAILABLE, 'Python PIL not installed') @skipUnless(PIL_AVAILABLE, 'Python PIL not installed')
def test_bootrom_framebuffer_size(self): def test_bootrom_framebuffer_size(self):
"""
:avocado: tags=arch:m68k
:avocado: tags=machine:next_cube
:avocado: tags=device:framebuffer
"""
screenshot_path = os.path.join(self.workdir, "dump.png") screenshot_path = os.path.join(self.workdir, "dump.png")
self.check_bootrom_framebuffer(screenshot_path) self.check_bootrom_framebuffer(screenshot_path)
@ -80,11 +79,6 @@ class NextCubeMachine(Test):
@skipUnless(tesseract_available(3), 'tesseract v3 OCR tool not available') @skipUnless(tesseract_available(3), 'tesseract v3 OCR tool not available')
def test_bootrom_framebuffer_ocr_with_tesseract_v3(self): def test_bootrom_framebuffer_ocr_with_tesseract_v3(self):
"""
:avocado: tags=arch:m68k
:avocado: tags=machine:next_cube
:avocado: tags=device:framebuffer
"""
screenshot_path = os.path.join(self.workdir, "dump.png") screenshot_path = os.path.join(self.workdir, "dump.png")
self.check_bootrom_framebuffer(screenshot_path) self.check_bootrom_framebuffer(screenshot_path)
@ -101,11 +95,6 @@ class NextCubeMachine(Test):
# that it is still alpha-level software. # that it is still alpha-level software.
@skipUnless(tesseract_available(4), 'tesseract v4 OCR tool not available') @skipUnless(tesseract_available(4), 'tesseract v4 OCR tool not available')
def test_bootrom_framebuffer_ocr_with_tesseract_v4(self): def test_bootrom_framebuffer_ocr_with_tesseract_v4(self):
"""
:avocado: tags=arch:m68k
:avocado: tags=machine:next_cube
:avocado: tags=device:framebuffer
"""
screenshot_path = os.path.join(self.workdir, "dump.png") screenshot_path = os.path.join(self.workdir, "dump.png")
self.check_bootrom_framebuffer(screenshot_path) self.check_bootrom_framebuffer(screenshot_path)

View File

@ -16,7 +16,7 @@ class Leon3Machine(Test):
def test_leon3_helenos_uimage(self): def test_leon3_helenos_uimage(self):
""" """
:avocado: tags=arch:sparc :avocado: tags=arch:sparc
:avocado: tags=machine:leon3 :avocado: tags=machine:leon3_generic
:avocado: tags=binfmt:uimage :avocado: tags=binfmt:uimage
""" """
kernel_url = ('http://www.helenos.org/releases/' kernel_url = ('http://www.helenos.org/releases/'
@ -24,7 +24,6 @@ class Leon3Machine(Test):
kernel_hash = 'a88c9cfdb8430c66650e5290a08765f9bf049a30' kernel_hash = 'a88c9cfdb8430c66650e5290a08765f9bf049a30'
kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
self.vm.set_machine('leon3_generic')
self.vm.set_console() self.vm.set_console()
self.vm.add_args('-kernel', kernel_path) self.vm.add_args('-kernel', kernel_path)

View File

@ -39,7 +39,6 @@ class IbmPrep40pMachine(Test):
drive_hash = 'dbcfc09912e71bd5f0d82c7c1ee43082fb596ceb' drive_hash = 'dbcfc09912e71bd5f0d82c7c1ee43082fb596ceb'
drive_path = self.fetch_asset(drive_url, asset_hash=drive_hash) drive_path = self.fetch_asset(drive_url, asset_hash=drive_hash)
self.vm.set_machine('40p')
self.vm.set_console() self.vm.set_console()
self.vm.add_args('-bios', bios_path, self.vm.add_args('-bios', bios_path,
'-fda', drive_path) '-fda', drive_path)
@ -53,7 +52,6 @@ class IbmPrep40pMachine(Test):
:avocado: tags=arch:ppc :avocado: tags=arch:ppc
:avocado: tags=machine:40p :avocado: tags=machine:40p
""" """
self.vm.set_machine('40p')
self.vm.set_console() self.vm.set_console()
self.vm.add_args('-m', '192') # test fw_cfg self.vm.add_args('-m', '192') # test fw_cfg
@ -73,7 +71,6 @@ class IbmPrep40pMachine(Test):
drive_hash = 'ac6fa2707d888b36d6fa64de6e7fe48e' drive_hash = 'ac6fa2707d888b36d6fa64de6e7fe48e'
drive_path = self.fetch_asset(drive_url, asset_hash=drive_hash, drive_path = self.fetch_asset(drive_url, asset_hash=drive_hash,
algorithm='md5') algorithm='md5')
self.vm.set_machine('40p')
self.vm.set_console() self.vm.set_console()
self.vm.add_args('-cdrom', drive_path, self.vm.add_args('-cdrom', drive_path,
'-boot', 'd') '-boot', 'd')

View File

@ -25,10 +25,6 @@
import avocado_qemu import avocado_qemu
import re import re
def get_cpu_prop(vm, prop):
cpu_path = vm.command('query-cpus')[0].get('qom_path')
return vm.command('qom-get', path=cpu_path, property=prop)
class X86CPUModelAliases(avocado_qemu.Test): class X86CPUModelAliases(avocado_qemu.Test):
""" """
Validation of PC CPU model versions and CPU model aliases Validation of PC CPU model versions and CPU model aliases
@ -79,12 +75,15 @@ class X86CPUModelAliases(avocado_qemu.Test):
"EPYC-IBPB shouldn't be versioned") "EPYC-IBPB shouldn't be versioned")
def test_4_0_alias_compatibility(self): def test_4_0_alias_compatibility(self):
"""Check if pc-*-4.0 unversioned CPU model won't be reported as aliases""" """
Check if pc-*-4.0 unversioned CPU model won't be reported as aliases
:avocado: tags=machine:pc-i440fx-4.0
"""
# pc-*-4.0 won't expose non-versioned CPU models as aliases # pc-*-4.0 won't expose non-versioned CPU models as aliases
# We do this to help management software to keep compatibility # We do this to help management software to keep compatibility
# with older QEMU versions that didn't have the versioned CPU model # with older QEMU versions that didn't have the versioned CPU model
self.vm.add_args('-S') self.vm.add_args('-S')
self.vm.set_machine('pc-i440fx-4.0')
self.vm.launch() 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.command('query-cpu-definitions'))
@ -109,9 +108,12 @@ class X86CPUModelAliases(avocado_qemu.Test):
self.assertNotIn('alias-of', c, "%s shouldn't be an alias" % (name)) self.assertNotIn('alias-of', c, "%s shouldn't be an alias" % (name))
def test_4_1_alias(self): def test_4_1_alias(self):
"""Check if unversioned CPU model is an alias pointing to right version""" """
Check if unversioned CPU model is an alias pointing to right version
:avocado: tags=machine:pc-i440fx-4.1
"""
self.vm.add_args('-S') self.vm.add_args('-S')
self.vm.set_machine('pc-i440fx-4.1')
self.vm.launch() 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.command('query-cpu-definitions'))
@ -211,9 +213,12 @@ class X86CPUModelAliases(avocado_qemu.Test):
self.validate_aliases(cpus) self.validate_aliases(cpus)
def test_none_alias(self): def test_none_alias(self):
"""Check if unversioned CPU model is an alias pointing to some version""" """
Check if unversioned CPU model is an alias pointing to some version
:avocado: tags=machine:none
"""
self.vm.add_args('-S') self.vm.add_args('-S')
self.vm.set_machine('none')
self.vm.launch() 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.command('query-cpu-definitions'))
@ -241,78 +246,90 @@ class CascadelakeArchCapabilities(avocado_qemu.Test):
:avocado: tags=arch:x86_64 :avocado: tags=arch:x86_64
""" """
def get_cpu_prop(self, prop):
cpu_path = self.vm.command('query-cpus')[0].get('qom_path')
return self.vm.command('qom-get', path=cpu_path, property=prop)
def test_4_1(self): def test_4_1(self):
"""
:avocado: tags=machine:pc-i440fx-4.1
"""
# machine-type only: # machine-type only:
vm = self.get_vm() self.vm.add_args('-S')
vm.add_args('-S') self.vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=on,check=off,enforce=off')
vm.set_machine('pc-i440fx-4.1') self.vm.launch()
vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=on,check=off,enforce=off') self.assertFalse(self.get_cpu_prop('arch-capabilities'),
vm.launch()
self.assertFalse(get_cpu_prop(vm, 'arch-capabilities'),
'pc-i440fx-4.1 + Cascadelake-Server should not have arch-capabilities') 'pc-i440fx-4.1 + Cascadelake-Server should not have arch-capabilities')
def test_4_0(self): def test_4_0(self):
vm = self.get_vm() """
vm.add_args('-S') :avocado: tags=machine:pc-i440fx-4.0
vm.set_machine('pc-i440fx-4.0') """
vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=on,check=off,enforce=off') self.vm.add_args('-S')
vm.launch() self.vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=on,check=off,enforce=off')
self.assertFalse(get_cpu_prop(vm, 'arch-capabilities'), self.vm.launch()
self.assertFalse(self.get_cpu_prop('arch-capabilities'),
'pc-i440fx-4.0 + Cascadelake-Server should not have arch-capabilities') 'pc-i440fx-4.0 + Cascadelake-Server should not have arch-capabilities')
def test_set_4_0(self): def test_set_4_0(self):
"""
:avocado: tags=machine:pc-i440fx-4.0
"""
# command line must override machine-type if CPU model is not versioned: # command line must override machine-type if CPU model is not versioned:
vm = self.get_vm() self.vm.add_args('-S')
vm.add_args('-S') self.vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=on,check=off,enforce=off,+arch-capabilities')
vm.set_machine('pc-i440fx-4.0') self.vm.launch()
vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=on,check=off,enforce=off,+arch-capabilities') self.assertTrue(self.get_cpu_prop('arch-capabilities'),
vm.launch()
self.assertTrue(get_cpu_prop(vm, 'arch-capabilities'),
'pc-i440fx-4.0 + Cascadelake-Server,+arch-capabilities should have arch-capabilities') 'pc-i440fx-4.0 + Cascadelake-Server,+arch-capabilities should have arch-capabilities')
def test_unset_4_1(self): def test_unset_4_1(self):
vm = self.get_vm() """
vm.add_args('-S') :avocado: tags=machine:pc-i440fx-4.1
vm.set_machine('pc-i440fx-4.1') """
vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=on,check=off,enforce=off,-arch-capabilities') self.vm.add_args('-S')
vm.launch() self.vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=on,check=off,enforce=off,-arch-capabilities')
self.assertFalse(get_cpu_prop(vm, 'arch-capabilities'), self.vm.launch()
self.assertFalse(self.get_cpu_prop('arch-capabilities'),
'pc-i440fx-4.1 + Cascadelake-Server,-arch-capabilities should not have arch-capabilities') 'pc-i440fx-4.1 + Cascadelake-Server,-arch-capabilities should not have arch-capabilities')
def test_v1_4_0(self): def test_v1_4_0(self):
"""
:avocado: tags=machine:pc-i440fx-4.0
"""
# versioned CPU model overrides machine-type: # versioned CPU model overrides machine-type:
vm = self.get_vm() self.vm.add_args('-S')
vm.add_args('-S') self.vm.add_args('-cpu', 'Cascadelake-Server-v1,x-force-features=on,check=off,enforce=off')
vm.set_machine('pc-i440fx-4.0') self.vm.launch()
vm.add_args('-cpu', 'Cascadelake-Server-v1,x-force-features=on,check=off,enforce=off') self.assertFalse(self.get_cpu_prop('arch-capabilities'),
vm.launch()
self.assertFalse(get_cpu_prop(vm, 'arch-capabilities'),
'pc-i440fx-4.0 + Cascadelake-Server-v1 should not have arch-capabilities') 'pc-i440fx-4.0 + Cascadelake-Server-v1 should not have arch-capabilities')
def test_v2_4_0(self): def test_v2_4_0(self):
vm = self.get_vm() """
vm.add_args('-S') :avocado: tags=machine:pc-i440fx-4.0
vm.set_machine('pc-i440fx-4.0') """
vm.add_args('-cpu', 'Cascadelake-Server-v2,x-force-features=on,check=off,enforce=off') self.vm.add_args('-S')
vm.launch() self.vm.add_args('-cpu', 'Cascadelake-Server-v2,x-force-features=on,check=off,enforce=off')
self.assertTrue(get_cpu_prop(vm, 'arch-capabilities'), self.vm.launch()
'pc-i440fx-4.0 + Cascadelake-Server-v2 should have arch-capabilities') self.assertTrue(self.get_cpu_prop('arch-capabilities'),
'pc-i440fx-4.0 + Cascadelake-Server-v2 should have arch-capabilities')
def test_v1_set_4_0(self): def test_v1_set_4_0(self):
"""
:avocado: tags=machine:pc-i440fx-4.0
"""
# command line must override machine-type and versioned CPU model: # command line must override machine-type and versioned CPU model:
vm = self.get_vm() self.vm.add_args('-S')
vm.add_args('-S') self.vm.add_args('-cpu', 'Cascadelake-Server-v1,x-force-features=on,check=off,enforce=off,+arch-capabilities')
vm.set_machine('pc-i440fx-4.0') self.vm.launch()
vm.add_args('-cpu', 'Cascadelake-Server-v1,x-force-features=on,check=off,enforce=off,+arch-capabilities') self.assertTrue(self.get_cpu_prop('arch-capabilities'),
vm.launch() 'pc-i440fx-4.0 + Cascadelake-Server-v1,+arch-capabilities should have arch-capabilities')
self.assertTrue(get_cpu_prop(vm, 'arch-capabilities'),
'pc-i440fx-4.0 + Cascadelake-Server-v1,+arch-capabilities should have arch-capabilities')
def test_v2_unset_4_1(self): def test_v2_unset_4_1(self):
vm = self.get_vm() """
vm.add_args('-S') :avocado: tags=machine:pc-i440fx-4.1
vm.set_machine('pc-i440fx-4.1') """
vm.add_args('-cpu', 'Cascadelake-Server-v2,x-force-features=on,check=off,enforce=off,-arch-capabilities') self.vm.add_args('-S')
vm.launch() self.vm.add_args('-cpu', 'Cascadelake-Server-v2,x-force-features=on,check=off,enforce=off,-arch-capabilities')
self.assertFalse(get_cpu_prop(vm, 'arch-capabilities'), self.vm.launch()
self.assertFalse(self.get_cpu_prop('arch-capabilities'),
'pc-i440fx-4.1 + Cascadelake-Server-v2,-arch-capabilities should not have arch-capabilities') 'pc-i440fx-4.1 + Cascadelake-Server-v2,-arch-capabilities should not have arch-capabilities')

View File

@ -21,7 +21,7 @@ import logging
import time import time
import datetime import datetime
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
from qemu import kvm_available from qemu.accel import kvm_available
from qemu.machine import QEMUMachine from qemu.machine import QEMUMachine
import subprocess import subprocess
import hashlib import hashlib