forked from autotest/tp-libvirt
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request autotest#5270 from Yingshun/vdpa_m_ifs
virtual_network: Add a case about mem_lock limit for vm with multiple…
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
.../tests/cfg/virtual_network/locked_memory_vdpa/mem_lock_limit_multiple_vdpa_interfaces.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
- virtual_network.locked_memory.vdpa_interfaceiface.multiple_interfaces: | ||
type = mem_lock_limit_multiple_vdpa_interfaces | ||
start_vm = no | ||
only x86_64 | ||
|
||
func_supported_since_libvirt_ver = (8, 7, 0) | ||
vm_attrs = {'max_mem_rt': 6291456, 'max_mem_rt_slots': 32, 'max_mem_rt_unit': 'K', 'current_mem':3, 'current_mem_unit': 'GiB','vcpu': 8, 'cpu': {'numa_cell': [{'id': '0', 'cpus': '0-3', 'memory': '1', 'unit': 'GiB'}, {'id': '1', 'cpus': '4-7', 'memory': '1', 'unit': 'GiB'}]}} | ||
iface_dict1 = {"source": {'dev':'/dev/vhost-vdpa-0'}} | ||
iface_dict2 = {"source": {'dev':'/dev/vhost-vdpa-1'}} | ||
iface_dict3 = {"source": {'dev':'/dev/vhost-vdpa-2'}} |
69 changes: 69 additions & 0 deletions
69
...t/tests/src/virtual_network/locked_memory_vdpa/mem_lock_limit_multiple_vdpa_interfaces.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from avocado.utils import process | ||
|
||
from virttest import libvirt_version | ||
from virttest import utils_vdpa | ||
|
||
from virttest.libvirt_xml import vm_xml | ||
from virttest.utils_libvirt import libvirt_memory | ||
from virttest.utils_libvirt import libvirt_vmxml | ||
from virttest.utils_test import libvirt | ||
|
||
from provider.interface import interface_base | ||
|
||
|
||
def run(test, params, env): | ||
""" | ||
Check mem_lock limit for vm with multiple vDPA interfaces. | ||
""" | ||
libvirt_version.is_libvirt_feature_supported(params) | ||
# Variable assignment | ||
dev_type = params.get('dev_type', 'vdpa') | ||
iface_num = 3 | ||
vm_name = params.get('main_vm') | ||
vm = env.get_vm(vm_name) | ||
|
||
vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name) | ||
backup_vmxml = vmxml.copy() | ||
|
||
try: | ||
pf_pci = utils_vdpa.get_vdpa_pci() | ||
test_env_obj = utils_vdpa.VDPAOvsTest(pf_pci) | ||
test_env_obj.setup() | ||
qemu_log = "/var/log/libvirt/qemu/%s.log" % vm.name | ||
process.run("echo > {}".format(qemu_log), shell=True) | ||
|
||
libvirt_vmxml.remove_vm_devices_by_type(vm, 'interface') | ||
|
||
vm_attrs = eval(params.get('vm_attrs', '{}')) | ||
vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name) | ||
vmxml.setup_attrs(**vm_attrs) | ||
vmxml.sync() | ||
test.log.debug("Updated VM xml: %s.", | ||
vm_xml.VMXML.new_from_dumpxml(vm_name)) | ||
for idx in range(iface_num): | ||
default_iface = {'source': {'dev': '/dev/vhost-vdpa-%s' % str(idx)}} | ||
iface_dict = eval(params.get( | ||
'iface_dict%s' % str(idx+1), str(default_iface))) | ||
if iface_dict: | ||
iface_dev = interface_base.create_iface(dev_type, iface_dict) | ||
libvirt.add_vm_device(vm_xml.VMXML.new_from_dumpxml(vm_name), | ||
iface_dev) | ||
test.log.debug("VM xml after updating ifaces: %s.", | ||
vm_xml.VMXML.new_from_dumpxml(vm_name)) | ||
|
||
test.log.info("TEST_STEP: Start the vm with 3 vDPA interfaces.") | ||
vm.start() | ||
vm.wait_for_serial_login(timeout=240).close() | ||
|
||
new_vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name) | ||
expr_memlock = libvirt_memory.normalize_mem_size( | ||
new_vmxml.get_current_mem(), | ||
new_vmxml.get_current_mem_unit()) * 3 + 1073741824 | ||
if not libvirt_memory.comp_memlock(expr_memlock): | ||
test.fail("Unable to get correct MEMLOCK after VM startup!") | ||
|
||
test.log.info("TEST_STEP: Check qemu log.") | ||
libvirt.check_logfile("fail|error", qemu_log, str_in_log=False) | ||
finally: | ||
backup_vmxml.sync() | ||
test_env_obj.cleanup() |