Skip to content

Commit

Permalink
SP-T101: Verify PCI device passthrough
Browse files Browse the repository at this point in the history
Verify passed through PCI devices are visible inside VM. From microvm's
configuration, read the PCI device paths that are supposed to be passed
through, resolve their VENDOR_ID and DEVICE_ID, and then check does
lspci show respective VENDOR_ID:DEVICE_ID combinations inside the VM.

Signed-off-by: Mika Tammi <[email protected]>
  • Loading branch information
Mika Tammi authored and Mika Tammi committed Nov 2, 2023
1 parent 0276fc7 commit 2949961
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
54 changes: 54 additions & 0 deletions Robot-Framework/resources/virtualization_keywords.resource
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# SPDX-FileCopyrightText: 2023 Technology Innovation Institute (TII)
# SPDX-License-Identifier: Apache-2.0

*** Settings ***
Library SSHLibrary
Resource ../config/variables.robot
Library BuiltIn
Library String


*** Keywords ***

Verify microvm PCI device passthrough
[Documentation] Verify that proper PCI devices have been passed through to the VM
[Arguments] ${host_connection} ${vm_connection} ${vmname}
Switch Connection ${vm_connection}
@{pciids}= Get list of PCI IDs
Switch Connection ${host_connection}
@{pcipassthrus}= Get microvm PCI passthrough list vmname=${vmname}
FOR ${pcipass} IN @{pcipassthrus}
${pciidpass}= Get PCI ID from PCI Address address=${pcipass}
Log Checking if PCI ID has been passed through to VM
Should Contain ${pciids} ${pciidpass}
END

Get list of PCI IDs
[Documentation] Runs lspci and returns VENDORID:DEVICEID pairs
... Pre-condition: requires active ssh connection to either
... host or one of the VMs, and ability run
... lspci in the target.
${cmd}= Set Variable lspci -n | cut -d ' ' -f 3
${stdout} ${stderr} ${rc}= Execute Command ${cmd} return_stdout=True return_stderr=True return_rc=True
Should Be Equal As Integers ${rc} 0
@{lines}= Split To Lines ${stdout}
[return] @{lines}

Get microvm PCI passthrough list
[Documentation] Returns PCI Addresses, like 0001:01:00.0
... Pre-condition: requires active ssh connection to ghaf host
[Arguments] ${vmname}
${cmd}= Format String cat /var/lib/microvms/{vmname}/booted/share/microvm/pci-devices vmname=${vmname}
${stdout} ${stderr} ${rc}= Execute Command ${cmd} return_stdout=True return_stderr=True return_rc=True
Should Be Equal As Integers ${rc} 0
@{lines}= Split To Lines ${stdout}
[return] @{lines}

Get PCI ID from PCI Address
[Documentation] Gets VENDORID:DEVICEID pair from sysfs
[Arguments] ${address}
${cmd}= Set Variable VENDOR=$(cut -c 3-7 /sys/bus/pci/devices/${address}/vendor) && DEVICE=$(cut -c 3-7 /sys/bus/pci/devices/${address}/device) && echo "$VENDOR:$DEVICE"
${stdout} ${stderr} ${rc}= Execute Command ${cmd} return_stdout=True return_stderr=True return_rc=True
Should Be Equal As Integers ${rc} 0
${stripped}= Strip String ${stdout}
[return] ${stripped}
9 changes: 9 additions & 0 deletions Robot-Framework/test-suites/bat-tests/netvm.robot
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Documentation Testing Network VM
Force Tags netvm
Resource ../../resources/ssh_keywords.resource
Resource ../../resources/virtualization_keywords.resource
Resource ../../config/variables.robot
Suite Teardown Close All Connections

Expand Down Expand Up @@ -78,6 +79,14 @@ Verify wpa_supplicant.service is running
Verify service status service=wpa_supplicant.service
[Teardown] Run Keywords Close All Connections

Verify NetVM PCI device passthrough
[Documentation] Verify that proper PCI devices have been passed through to the NetVM
[Tags] bat SP-T101 nuc orin-agx orin-nx
[Setup] Run Keywords
... Connect to ghaf host AND Connect to netvm via tunnel
Verify microvm PCI device passthrough host_connection=${ghaf_host} vm_connection=${netvm} vmname=${NETVM_NAME}
[Teardown] Run Keywords Close All Connections


*** Keywords ***

Expand Down

0 comments on commit 2949961

Please sign in to comment.