Skip to content

Commit

Permalink
Merge pull request #255 from xcp-ng/fix-pci-selection
Browse files Browse the repository at this point in the history
Use PCI of a PGPU for PCI passthrough tests
  • Loading branch information
stormi authored Sep 10, 2024
2 parents 460aaf5 + 5038d94 commit 4d7106a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 23 deletions.
2 changes: 1 addition & 1 deletion jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
27 changes: 5 additions & 22 deletions tests/pci_passthrough/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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), ',')
Expand All @@ -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

0 comments on commit 4d7106a

Please sign in to comment.