Skip to content

Commit

Permalink
Merge pull request #5811 from xiaodwan/new_case_for_ras_support
Browse files Browse the repository at this point in the history
RAS: add new case for RAS feature support
  • Loading branch information
dzhengfy authored Oct 10, 2024
2 parents 7eb1188 + c9b6c58 commit 6fd65ed
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
14 changes: 14 additions & 0 deletions libvirt/tests/cfg/features/ras.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- features.ras:
type = ras
start_vm = no
only aarch64
func_supported_since_libvirt_ver = (10, 4, 0)
unsupported_err_msg = "Ras feature is not supported on current version."
variants:
- on:
ras_state = on
- off:
ras_state = off
variants:
- positive_test:
status_error = "no"
62 changes: 62 additions & 0 deletions libvirt/tests/src/features/ras.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import logging

from virttest import virsh
from virttest import libvirt_version
from virttest.libvirt_xml.vm_xml import VMXML
from virttest.utils_libvirt import libvirt_vmxml
from virttest.utils_test import libvirt

LOG = logging.getLogger('avocado.' + __name__)


def run(test, params, env):
"""
Test the ras feature
1. Enable 'ras=on/off' in a guest
2. check the xml and qemu cmd line
"""
# Ras feature supported since 10.4.0.
libvirt_version.is_libvirt_feature_supported(params)

ras_state = params.get("ras_state")

def check_dumpxml():
"""
Check whether the added devices are shown in the guest xml
"""
xpath = [{'element_attrs': [".//ras[@state='%s']" % ras_state]}]
# Check ras state
vm_xml = VMXML.new_from_dumpxml(vm_name)
libvirt_vmxml.check_guest_xml_by_xpaths(vm_xml, xpath)

def check_qemu_cmd_line():
"""
Check whether the ras feature is shown in the qemu cmd line
"""
pattern = r"-machine.*ras=%s" % ras_state
libvirt.check_qemu_cmd_line(pattern)

vm_name = params.get("main_vm", "avocado-vt-vm1")
vm = env.get_vm(vm_name)

vm_xml = VMXML.new_from_dumpxml(vm_name)
vm_xml_backup = vm_xml.copy()
LOG.debug("vm xml is %s", vm_xml_backup)

if vm.is_alive():
vm.destroy()

try:
features_xml = vm_xml.features
if features_xml.has_feature('ras'):
features_xml.remove_feature('ras')
features_xml.ras = ras_state
vm_xml.features = features_xml
vm_xml.sync()
virsh.start(vm_name, ignore_status=False)
check_dumpxml()
check_qemu_cmd_line()
finally:
if vm.is_alive():
virsh.destroy(vm_name)
vm_xml_backup.sync()
1 change: 1 addition & 0 deletions spell.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ qxl
QXL
qxldod
Radix
ras
rases
rawio
rbd
Expand Down

0 comments on commit 6fd65ed

Please sign in to comment.