Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
virsh_migrate_options = '--live --p2p --verbose'
- non_p2p:
virsh_migrate_options = '--live --verbose'
- p2p_tunneled:
virsh_migrate_options = '--live --p2p --tunnelled --verbose'
- postcopy:
virsh_migrate_options = '--live --postcopy --verbose'
- postcopy_p2p:
virsh_migrate_options = '--live --postcopy --p2p --verbose'
- auto_converge:
virsh_migrate_options = '--live --auto-converge --verbose'
- auto_converge_p2p:
virsh_migrate_options = '--live --auto-converge --p2p --verbose'
variants migration_option:
- with_xml:
- without_xml:
Expand All @@ -38,5 +48,5 @@
numa_cell = "'numa_cell': [{'cpus': '0-1', 'memory': '2097152', 'unit': 'KiB'}]"
vm_attrs = {'cpu': {'mode': 'host-model', 'check': 'partial', ${numa_cell}}}
- custom:
no aarch64
no aarch64,ppc64le,ppc64
cpu_mode = "custom"
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import platform

from virttest import data_dir
from virttest import virsh
Expand All @@ -15,6 +16,21 @@ def run(test, params, env):
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
def get_host_cpu_model():
"""Get host CPU model in lowercase"""
try:
# virsh.capabilities() returns XML string directly
caps_xml = virsh.capabilities()
import re
match = re.search(r'<model>(\w+)</model>', caps_xml)
if match:
model = match.group(1).lower()
test.log.info(f"Detected CPU model: {model}")
return model
except Exception as e:
test.log.warning(f"Failed to detect CPU model: {e}")
return None

def setup_test():
"""
Setup steps
Expand All @@ -28,6 +44,13 @@ def setup_test():
vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name)
if cpu_mode == "host_model":
vm_attrs = eval(params.get('vm_attrs', '{}'))
arch = platform.machine()
if arch in ['ppc64', 'ppc64le'] and 'cpu' in vm_attrs:
host_model = get_host_cpu_model()
if host_model:
vm_attrs['cpu']['model'] = host_model
vm_attrs['cpu']['fallback'] = params.get('model_fallback', 'forbid')
test.log.info(f"Power arch - added CPU model: {host_model}")
vmxml.setup_attrs(**vm_attrs)
vmxml.sync()
else:
Expand Down
Loading