Skip to content

Commit

Permalink
memory_nvdimm: Fix cpu mode to enable test for aarch64
Browse files Browse the repository at this point in the history
The cpu mode is host-passthrough for arm.

Internal snapshots of a VM with pflash based firmware are not supported on arm,
so skip this check on arm.

Signed-off-by: Hu Shuai <[email protected]>
  • Loading branch information
hs0210 committed Jan 12, 2024
1 parent b7d9676 commit c5f1efe
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
9 changes: 6 additions & 3 deletions libvirt/tests/cfg/memory/nvdimm.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
type = nvdimm
start_vm = no
nvdimm_file_size = '512M'
cpuxml_mode = host-model
aarch64:
cpuxml_mode = host-passthrough
variants:
- back_file:
nvdimm_file = /tmp/nvdimm
cpuxml_mode = host-model
cpuxml_check = partial
cpuxml_fallback = allow
nvdimmxml_mem_model = nvdimm
Expand Down Expand Up @@ -37,6 +39,8 @@
- default:
- check_life_cycle:
check_life_cycle = "yes"
error_msg_1 = "unsupported configuration: revert to external snapshot not supported yet"
error_msg_2 = "internal error: Invalid target domain state 'disk-snapshot'. Refusing snapshot reversion"
- discard:
check = discard
nvdimmxml_discard = yes
Expand All @@ -46,7 +50,7 @@
check = pmem_alignsize
nvdimm_file_path = '/tmp/nvdimm'
alignsize = 2048
vm_attrs = {'max_mem_rt': 8192, 'max_mem_rt_slots': 8, 'max_mem_rt_unit': 'M', 'vcpu': 4, 'cpu': {'mode': 'host-model', 'numa_cell': [{'id': '0', 'cpus': '0-1', 'memory': '2097152', 'unit': 'K'}, {'id': '1', 'cpus': '2-3', 'memory': '2097152', 'unit': 'K'}]}}
vm_attrs = {'max_mem_rt': 8192, 'max_mem_rt_slots': 8, 'max_mem_rt_unit': 'M', 'vcpu': 4, 'cpu': {'mode': '${cpuxml_mode}', 'numa_cell': [{'id': '0', 'cpus': '0-1', 'memory': '2097152', 'unit': 'K'}, {'id': '1', 'cpus': '2-3', 'memory': '2097152', 'unit': 'K'}]}}
mem_device_attrs = {'mem_model': 'nvdimm', 'source': {'path': '${nvdimm_file_path}', 'alignsize': ${alignsize}, 'alignsize_unit': 'K', 'pmem': True}, 'target': {'size': 512, 'size_unit': 'M', 'node': 1, 'readonly': True, 'label': {'size': 128, 'size_unit': 'KiB'}}}
qemu_checks = "align.*pmem"
error_msg = "['pwrite.* failed: Operation not permitted', 'wrong fs type, bad option, bad superblock on /dev/pmem0']"
Expand Down Expand Up @@ -113,7 +117,6 @@
nvdimmxml2_label_size = 128
nvdimmxml2_label_size_unit = KiB
nvdimmxml2_address_slot = 1
cpuxml_mode = host-model
cpuxml_check = partial
cpuxml_fallback = allow
cpuxml_topology = {'sockets': '2', 'cores': '2', 'threads': '1'}
Expand Down
28 changes: 25 additions & 3 deletions libvirt/tests/src/memory/nvdimm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from avocado.utils import process

from virttest import libvirt_version
from virttest import xml_utils
from virttest import virsh
from virttest import utils_hotplug
from virttest import utils_package
Expand Down Expand Up @@ -339,9 +340,30 @@ def test_with_label(vm, params, test):
vm_session = vm.wait_for_login()
check_nvdimm_file(test_str, test_file, vm_session, test)
vm_session.close()
virsh.snapshot_create_as(vm_name, vm_s1, ignore_status=False, debug=True)
virsh.snapshot_revert(vm_name, vm_s1, ignore_status=False, debug=True)
virsh.snapshot_delete(vm_name, vm_s1, ignore_status=False, debug=True)
if platform.machine() == 'aarch64':
virsh.snapshot_create_as(vm_name, "%s --disk-only" % vm_s1,
ignore_status=False, debug=True)
revert_result = virsh.snapshot_revert(vm_name, vm_s1, debug=True)
if revert_result.exit_status:
error_msg_1 = params.get('error_msg_1')
error_msg_2 = params.get('error_msg_2')
if not re.search(error_msg_1, revert_result.stderr) \
and not re.search(error_msg_2, revert_result.stderr):
test.fail("The error '{}' or '{}' should be in the output \n'{}'" %
format(error_msg_1, error_msg_2, revert_result.stderr))
if libvirt_version.version_compare(9, 10, 0):
virsh.snapshot_delete(vm_name, vm_s1, ignore_status=False, debug=True)
else:
virsh.snapshot_delete(vm_name, "%s --metadata" % vm_s1, ignore_status=False, debug=True)
domxml = virsh.dumpxml(vm_name).stdout.strip()
xtf_dom = xml_utils.XMLTreeFile(domxml)
snap_file_path = xtf_dom.find("devices/disk/source").get("file")
if os.path.exists(snap_file_path):
os.remove(snap_file_path)
else:
virsh.snapshot_create_as(vm_name, vm_s1, ignore_status=False, debug=True)
virsh.snapshot_revert(vm_name, vm_s1, ignore_status=False, debug=True)
virsh.snapshot_delete(vm_name, vm_s1, ignore_status=False, debug=True)


def test_hotplug(vm, params, test):
Expand Down

0 comments on commit c5f1efe

Please sign in to comment.