From 19a1127d0305563dcdb4fa095cf6a765b8b6895f Mon Sep 17 00:00:00 2001 From: Yingshun Cui Date: Thu, 2 Nov 2023 20:17:26 +0800 Subject: [PATCH] virtual_network: Add a nodedev test for vdpa device 1. Add nodedev test for for vdpa devices to virtual_network 2. Remove redundant files in virtual_interface Signed-off-by: Yingshun Cui --- .../virtual_interface/iface_nodedev_info.cfg | 13 ------- .../nodedev/nodedev_vdpa_interface.cfg | 11 ++++++ .../nodedev/nodedev_vdpa_interface.py} | 34 ++++--------------- 3 files changed, 18 insertions(+), 40 deletions(-) delete mode 100644 libvirt/tests/cfg/virtual_interface/iface_nodedev_info.cfg create mode 100644 libvirt/tests/cfg/virtual_network/nodedev/nodedev_vdpa_interface.cfg rename libvirt/tests/src/{virtual_interface/iface_nodedev_info.py => virtual_network/nodedev/nodedev_vdpa_interface.py} (78%) diff --git a/libvirt/tests/cfg/virtual_interface/iface_nodedev_info.cfg b/libvirt/tests/cfg/virtual_interface/iface_nodedev_info.cfg deleted file mode 100644 index 35fc71fbd1..0000000000 --- a/libvirt/tests/cfg/virtual_interface/iface_nodedev_info.cfg +++ /dev/null @@ -1,13 +0,0 @@ -- iface.nodedev_info: - type = iface_nodedev_info - start_vm = no - - variants dev_type: - - vdpa: - only x86_64 - func_supported_since_libvirt_ver = (7, 3, 0) - func_supported_since_qemu_kvm_ver = (6, 0, 0) - dev_dict = {'path': 'vdpa0', 'name': 'vdpa_vdpa0', 'driver_name': 'vhost_vdpa', 'cap_type': 'vdpa'} - variants test_target: - - simulator: - - mellanox: diff --git a/libvirt/tests/cfg/virtual_network/nodedev/nodedev_vdpa_interface.cfg b/libvirt/tests/cfg/virtual_network/nodedev/nodedev_vdpa_interface.cfg new file mode 100644 index 0000000000..35f3f3babd --- /dev/null +++ b/libvirt/tests/cfg/virtual_network/nodedev/nodedev_vdpa_interface.cfg @@ -0,0 +1,11 @@ +- virtual_network.nodedev.vdpa_interface: + type = nodedev_vdpa_interface + start_vm = no + only x86_64 + + func_supported_since_libvirt_ver = (7, 3, 0) + func_supported_since_qemu_kvm_ver = (6, 0, 0) + dev_dict = {'path': 'vdpa0', 'name': 'vdpa_vdpa0', 'driver_name': 'vhost_vdpa', 'cap_type': 'vdpa'} + variants test_target: + - simulator: + - mellanox: diff --git a/libvirt/tests/src/virtual_interface/iface_nodedev_info.py b/libvirt/tests/src/virtual_network/nodedev/nodedev_vdpa_interface.py similarity index 78% rename from libvirt/tests/src/virtual_interface/iface_nodedev_info.py rename to libvirt/tests/src/virtual_network/nodedev/nodedev_vdpa_interface.py index 6d85597533..785df3117e 100644 --- a/libvirt/tests/src/virtual_interface/iface_nodedev_info.py +++ b/libvirt/tests/src/virtual_network/nodedev/nodedev_vdpa_interface.py @@ -23,28 +23,6 @@ def check_environment(params): libvirt_version.is_libvirt_feature_supported(params) utils_misc.is_qemu_function_supported(params) - def setup_test(dev_type): - """ - Setup test environment for a specific interface if needed - - :param dev_type: interface type - :return: An object of special test environment - """ - test_env_obj = None - if dev_type == 'vdpa': - test_env_obj = setup_vdpa() - - return test_env_obj - - def teardown_test(dev_type): - """ - Default cleanup - - :param dev_type: interface type - """ - if dev_type == 'vdpa': - teardown_vdpa() - def setup_vdpa(): """ Setup vDPA environment @@ -84,7 +62,8 @@ def check_nodedev_info(dev_dict): if dev_name not in result.stdout_text: test.fail("Failed to list %s device!" % dev_name) - test.log.info("TEST_STEP2: Check device info using virsh nodedev-dumpxml.") + test.log.info("TEST_STEP2: Check device info using virsh " + "nodedev-dumpxml.") dev_xml = nodedev_xml.NodedevXML.new_from_dumpxml(dev_name) test.log.debug("Nodedev xml: {}".format(dev_xml)) if not all([getattr(dev_xml, attr).endswith(value) for attr, value in @@ -96,16 +75,17 @@ def check_nodedev_info(dev_dict): test.fail("Failed to validate node device xml!") check_environment(params) + # Variable assignment - dev_type = params.get('dev_type', '') dev_dict = eval(params.get('dev_dict', '{}')) test_obj = None try: # Execute test - test.log.info("TEST_CASE: %s", check_nodedev_info.__doc__.split('\n')[0]) - test_obj = setup_test(dev_type) + test.log.info("TEST_CASE: %s", + check_nodedev_info.__doc__.split('\n')[0]) + test_obj = setup_vdpa() check_nodedev_info(dev_dict) finally: - teardown_test(dev_type) + teardown_vdpa()