diff mbox series

[2/2] tests/functional/test_aarch64_hotplug_pci: Add test for ACPI PCI hotplug

Message ID 20250527150229.1617074-3-gustavo.romero@linaro.org
State Superseded
Headers show
Series Add functional test for ACPI PCI hotplug | expand

Commit Message

Gustavo Romero May 27, 2025, 3:02 p.m. UTC
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(-)

Comments

Gustavo Romero May 28, 2025, 2:13 a.m. UTC | #1
On 5/27/25 12:02, Gustavo Romero wrote:
> 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(-)
> 
> diff --git a/tests/functional/test_aarch64_hotplug_pci.py b/tests/functional/test_aarch64_hotplug_pci.py
> index bb2c121503..862bb6746b 100755
> --- a/tests/functional/test_aarch64_hotplug_pci.py
> +++ b/tests/functional/test_aarch64_hotplug_pci.py
> @@ -27,11 +27,26 @@ class HotplugPCI(LinuxKernelTest):
>            'current/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()

Re-posted here as a single patch:

https://lists.nongnu.org/archive/html/qemu-devel/2025-05/msg06332.html

I missed the Based-on: 20250527074224.1197793-1-eric.auger@redhat.com tag :-/


Cheers,
Gustavo
diff mbox series

Patch

diff --git a/tests/functional/test_aarch64_hotplug_pci.py b/tests/functional/test_aarch64_hotplug_pci.py
index bb2c121503..862bb6746b 100755
--- a/tests/functional/test_aarch64_hotplug_pci.py
+++ b/tests/functional/test_aarch64_hotplug_pci.py
@@ -27,11 +27,26 @@  class HotplugPCI(LinuxKernelTest):
          'current/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()