-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SP-T101: Verify PCI device passthrough
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
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
Robot-Framework/resources/virtualization_keywords.resource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters