Skip to content

Commit

Permalink
Verify passed PCI devices are visible inside VM
Browse files Browse the repository at this point in the history
Signed-off-by: Mika Tammi <[email protected]>
  • Loading branch information
Mika Tammi committed Nov 1, 2023
1 parent ccfd4cf commit 86917c6
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 @@ -75,6 +76,14 @@ Verify wpa_supplicant.service is running
Switch Connection ${netvm}
Verify service status service=wpa_supplicant.service

Verify NetVM PCI device passthrough
[Documentation] Verify that proper PCI devices have been passed through to the NetVM
[Tags] bat SP-T670 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 86917c6

Please sign in to comment.