@@ -27,11 +27,26 @@ class HotplugPCI(LinuxKernelTest):
'20230607+deb12u11/images/netboot/debian-installer/arm64/initrd.gz'),
'9f817f76951f3237bca8216bee35267bfb826815687f4b2fcdd5e6c2a917790c')
- def test_hotplug_pci(self):
+ def run_vm_and_test_hotplug_pci(self, use_acpi_pci_hotplug=False):
+ """
+ Run an aarch64 VM and test the PCI hotplug mechanism by plugging and
+ unplugging a PCI network adapter to the VM. Proper plug and unplug of
+ the adapter is verified by checking if the network device is correctly
+ added and removed in Linux.
+
+ Parameters
+ ----------
+ use_acpi_pci_hotplug : bool
+ If true the ACPI PCI hotplug mechanim is used, otherwise the
+ Native PCIe Hotplug mechanism is used.
+ """
+
+ acpi_pci_hotplug = "on" if use_acpi_pci_hotplug else "off"
self.set_machine('virt')
self.vm.add_args('-m', '512M')
self.vm.add_args('-cpu', 'cortex-a57')
+ self.vm.add_args('-machine', f"acpi-pcihp={acpi_pci_hotplug}")
self.vm.add_args('-append',
'console=ttyAMA0,115200 init=/bin/sh')
self.vm.add_args('-device',
@@ -70,5 +85,12 @@ def test_hotplug_pci(self):
'ls -l /sys/class/net | wc -l',
'2')
+ def test_native_pci_hotplug(self):
+ self.run_vm_and_test_hotplug_pci(use_acpi_pci_hotplug=False)
+
+ def test_acpi_pci_hotplug(self):
+ self.run_vm_and_test_hotplug_pci(use_acpi_pci_hotplug=True)
+
+
if __name__ == '__main__':
LinuxKernelTest.main()
Currently, test_aarch64_hotplug_pci only tests PCI hotplug using the native PCI hotplug mechanism. Now that aarch64 supports PCI hotplug via the ACPI mechanism it's time to support it in the test as well. Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org> --- tests/functional/test_aarch64_hotplug_pci.py | 24 +++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)