From 1c0743707ad92884212258c5e6a4fc8b0199bae9 Mon Sep 17 00:00:00 2001 From: Tasmiya Nalatwad Date: Tue, 17 Dec 2024 17:58:54 +0530 Subject: [PATCH] PCI PT Hotplug/Hotunplug fixes for arch ppc64 Added 2 new test cases, where hitplog unplug is performed for multiple times and a random reboot is done between hotplug and unplug and the device avialability is checked. Signed-off-by: Tasmiya Nalatwad --- .../pci/libvirt_pci_passthrough_hotplug.cfg | 6 ++ .../pci/libvirt_pci_passthrough_hotplug.py | 70 ++++++++++++++++--- 2 files changed, 67 insertions(+), 9 deletions(-) diff --git a/libvirt/tests/cfg/passthrough/pci/libvirt_pci_passthrough_hotplug.cfg b/libvirt/tests/cfg/passthrough/pci/libvirt_pci_passthrough_hotplug.cfg index dd5e9cba7b..4cf96502a9 100644 --- a/libvirt/tests/cfg/passthrough/pci/libvirt_pci_passthrough_hotplug.cfg +++ b/libvirt/tests/cfg/passthrough/pci/libvirt_pci_passthrough_hotplug.cfg @@ -45,3 +45,9 @@ - virsh_dump: # dump the guest with memory only option virsh_dump = "yes" + - multiple_hotplug_hotunplug: + multiple_hotplug_hotunplug = "yes" + no_of_hotplug_unplug = 25 + - multiple_hotplug_unplug_with_rand_reboot: + random_reboot = "yes" + no_of_hotplug_unplug = 20 diff --git a/libvirt/tests/src/passthrough/pci/libvirt_pci_passthrough_hotplug.py b/libvirt/tests/src/passthrough/pci/libvirt_pci_passthrough_hotplug.py index 90e94adffd..23c06209cd 100644 --- a/libvirt/tests/src/passthrough/pci/libvirt_pci_passthrough_hotplug.py +++ b/libvirt/tests/src/passthrough/pci/libvirt_pci_passthrough_hotplug.py @@ -17,6 +17,8 @@ import logging as log import aexpect import time +import platform +import random from avocado.utils import process @@ -75,20 +77,43 @@ def run(test, params, env): virsh_dumpxml = params.get("virsh_dumpxml", "no") virsh_dump = params.get("virsh_dump", "no") flood_ping = params.get("flood_ping", "no") + arch = platform.machine() + multiple_hotplug_hotunplug = params.get("multiple_hotplug_hotunplug", "no") + no_of_hotplug_unplug = params.get("no_of_hotplug_unplug", "no") + random_reboot = params.get("random_reboot", "no") # Check the parameters from configuration file. - for each_param in params.itervalues(): - if "ENTER_YOUR" in each_param: - test.cancel("Please enter the configuration details of %s." - % each_param) + if arch != "ppc64le": + for each_param in params.itervalues(): + if "ENTER_YOUR" in each_param: + test.cancel("Please enter the configuration details of %s." + % each_param) vmxml = VMXML.new_from_inactive_dumpxml(vm_name) backup_xml = vmxml.copy() devices = vmxml.get_devices() pci_devs = [] dargs = {'debug': True, 'ignore_status': True} + + cntlr_index = params.get("index", "1") + cntlr_model = params.get("model", "pci-root") + cntlr_type = "pci" + + controllers = vmxml.get_controllers(cntlr_type, cntlr_model) + index_list = [] + for controller in controllers: + index_value = controller.get("index") + if index_value is not None: + index_list.append(int(index_value)) + + if index_list: + next_index = max(index_list) + 1 + else: + next_index = int(cntlr_index) + controller = Controller("controller") - controller.type = "pci" - controller.index = params.get("index", "1") - controller.model = params.get("model", "pci-root") + controller.type = cntlr_type + controller.index = str(next_index) + controller.model = cntlr_model + devices.append(controller) vmxml.set_devices(devices) vmxml.sync() @@ -160,8 +185,12 @@ def check_attach_pci(): return nic_list_after != nic_list_before def device_hotplug(): - if not libvirt_version.version_compare(3, 10, 0): - detach_device(pci_devs, pci_ids) + if arch == "ppc64le": + if libvirt_version.version_compare(3, 10, 0): + detach_device(pci_devs, pci_ids) + else: + if not libvirt_version.version_compare(3, 10, 0): + detach_device(pci_devs, pci_ids) # attach the device in hotplug mode result = virsh.attach_device(vm_name, dev.xml, flagstr="--live", debug=True) @@ -263,6 +292,14 @@ def test_dump(): if cmd_result.exit_status: test.fail("Failed to virsh dump of domain %s" % vm_name) + def rand_reboot(iteration): + logging.info("Perform arandom reboot between hotplug and hotunplug of pci device") + rand_value = random.randint(15, 25) + if iteration == rand_value: + logging.debug("reboots at %s", rand_value) + test_reboot() + logging.debug("Random reboot completed, and adapter found in the VM after reboot") + try: for stress_value in range(0, int(stress_val)): device_hotplug() @@ -279,6 +316,21 @@ def test_dump(): test_dump() device_hotunplug() + if multiple_hotplug_hotunplug == "yes": + for iteration in range(int(no_of_hotplug_unplug)): + logging.info("Performing Hotplug/Hotunplug of pci device for %s time", iteration) + device_hotplug() + test_ping() + device_hotunplug() + + if random_reboot == "yes": + for iteration in range(int(no_of_hotplug_unplug)): + logging.info("Performing Hotplug/Hotunplug of pci device for %s time", iteration) + device_hotplug() + test_ping() + rand_reboot(iteration) + device_hotunplug() + finally: # clean up data_dir.clean_tmp_files()