mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-04-09 21:42:14 +00:00
tests: Support runtime-rs QEMU cmdline format in attestation test
The k8s-confidential-attestation test extracts the QEMU command line
from journal logs to compute the SNP launch measurement. It only
matched the Go runtime's log format ("launching <path> with: [<args>]"),
but runtime-rs logs differently ("qemu args: <args>").
Handle both formats so the test works with qemu-snp-runtime-rs.
Made-with: Cursor
Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
This commit is contained in:
@@ -146,15 +146,22 @@ setup() {
|
||||
kbs_set_cpu0_resource_policy
|
||||
|
||||
# get measured artifacts from qemu command line of previous test
|
||||
# Go runtime logs: "launching <path> with: [<args>]"
|
||||
# runtime-rs logs: "qemu args: <args>"
|
||||
log_line=$(sudo journalctl -r -x -t kata | grep -m 1 'launching.*qemu.*with:' || true)
|
||||
qemu_cmd=$(echo "$log_line" | sed 's/.*with: \[\(.*\)\]".*/\1/')
|
||||
if [[ -n "$log_line" ]]; then
|
||||
qemu_cmd=$(echo "$log_line" | sed 's/.*with: \[\(.*\)\]".*/\1/')
|
||||
else
|
||||
log_line=$(sudo journalctl -r -x -t kata | grep -m 1 'qemu args:' || true)
|
||||
qemu_cmd=$(echo "$log_line" | sed 's/.*qemu args: //')
|
||||
fi
|
||||
[[ -n "$qemu_cmd" ]] || { echo "Could not find QEMU command line"; return 1; }
|
||||
|
||||
kernel_path=$(echo "$qemu_cmd" | grep -oP -- '-kernel \K[^ ]+')
|
||||
initrd_path=$(echo "$qemu_cmd" | grep -oP -- '-initrd \K[^ ]+' || true)
|
||||
firmware_path=$(echo "$qemu_cmd" | grep -oP -- '-bios \K[^ ]+')
|
||||
vcpu_count=$(echo "$qemu_cmd" | grep -oP -- '-smp \K\d+')
|
||||
append=$(echo "$qemu_cmd" | sed -n 's/.*-append \(.*\) -bios.*/\1/p')
|
||||
append=$(echo "$qemu_cmd" | grep -oP -- '-append \K.*?(?= -(smp|bios) )')
|
||||
# Remove escape backslashes for quotes from output for dm-mod.create parameters
|
||||
append="${append//\\\"/\"}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user