From 5038d94b97d4a89fe8ecd335fc4b5cc56f5b441a Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Tue, 10 Sep 2024 10:02:25 +0200 Subject: [PATCH] Use PCI of a PGPU for PCI passthrough tests Instead a picking a random PCI that could break the host when passthroughed: use the PCI of a PGPU that will also be used in PGPU passthrough tests anyway. Signed-off-by: Benjamin Reis --- jobs.py | 2 +- tests/pci_passthrough/conftest.py | 27 +++++---------------------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/jobs.py b/jobs.py index 31ba22b32..c4bd391e2 100755 --- a/jobs.py +++ b/jobs.py @@ -401,7 +401,7 @@ "pci-passthrough": { "description": "Testing PCI passthrough functionalities", "requirements": [ - "A XCP-ng host >= 8.3 with a PGPU and a PCI to passthrough.", + "A XCP-ng host >= 8.3 with a PGPU to passthrough.", "The host will be rebooted by the tests." ], "nb_pools": 1, diff --git a/tests/pci_passthrough/conftest.py b/tests/pci_passthrough/conftest.py index 03809e239..390d82ded 100644 --- a/tests/pci_passthrough/conftest.py +++ b/tests/pci_passthrough/conftest.py @@ -3,28 +3,6 @@ from lib.common import safe_split -@pytest.fixture(scope="session") -def enabled_pci_uuid(host): - pci_uuids = safe_split(host.xe("pci-list", {"host-uuid": host.uuid, "dependencies": ""}, minimal=True), ',') - - pci_uuid = None - for uuid in pci_uuids: - dom0_access = host.xe("pci-get-dom0-access-status", {"uuid": uuid}) - if dom0_access == "enabled": - pci_uuid = uuid - break - - if pci_uuid is None: - pytest.skip("This test requires a PCI to hide from dom0") - - yield pci_uuid - - # Put PCI back in initial state - if host.xe("pci-get-dom0-access-status", {"uuid": pci_uuid}) != "enabled": - host.xe("pci-enable-dom0-access", {"uuid": pci_uuid}) - if host.xe("pci-get-dom0-access-status", {"uuid": pci_uuid}) != "enabled": - host.reboot(verify=True) - @pytest.fixture(scope="session") def enabled_pgpu_uuid(host): pgpu_uuids = safe_split(host.xe("pgpu-list", {"host-uuid": host.uuid}, minimal=True), ',') @@ -48,3 +26,8 @@ def enabled_pgpu_uuid(host): host.xe("pci-enable-dom0-access", {"uuid": pci_uuid}) if host.xe("pci-get-dom0-access-status", {"uuid": pci_uuid}) != "enabled": host.reboot(verify=True) + +@pytest.fixture(scope="session") +def enabled_pci_uuid(host, enabled_pgpu_uuid): + pci_uuid = host.xe("pgpu-param-get", {"uuid": enabled_pgpu_uuid, "param-name": "pci-uuid"}) + return pci_uuid