Skip to content

Commit e843780

Browse files
authored
Merge pull request #4288 from JinLiul/change_attestation_script
attestation: change to use host cpu model
2 parents 91a233b + d608b74 commit e843780

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

qemu/deps/sev-snp/regular_attestation_workflow.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
#!/bin/bash
22
set -e
33

4+
# Check for the required CPU model parameter
5+
if [[ -z "$1" ]]; then
6+
echo "Error: cpu_model parameter is required."
7+
echo "Usage: $0 <cpu_model>"
8+
exit 1
9+
fi
10+
11+
cpu_model="$1"
12+
413
fetch_retry() {
514
local command=$1
615
local max_retries=3
@@ -23,11 +32,6 @@ fetch_retry() {
2332
snpguest report attestation-report.bin request-data.txt --random
2433
snpguest display report attestation-report.bin
2534

26-
# Get cpu model
27-
cpu_familly_id=$(cat /proc/cpuinfo | grep 'cpu family' | head -1 | cut -d ":" -f 2 | tr -d " ")
28-
model_id=$(cat /proc/cpuinfo | grep 'model' | head -1 | cut -d ":" -f 2 | tr -d " ")
29-
dict_cpu=([251]="milan" [2517]="genoa" [2617]="turin")
30-
cpu_model=${dict_cpu[${cpu_familly_id}${model_id}]}
3135

3236
# Fetch cert
3337
set +e

qemu/tests/snp_basic_config.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22

3-
from avocado.utils import process
3+
from avocado.utils import cpu, process
44
from virttest import data_dir as virttest_data_dir
55
from virttest import error_context
66
from virttest.utils_misc import verify_dmesg
@@ -36,6 +36,12 @@ def run(test, params, env):
3636
if int(process.getoutput(socket_count_cmd, shell=True)) != 1:
3737
test.cancel("Host cpu has more than 1 socket, skip the case.")
3838

39+
family_id = cpu.get_family()
40+
model_id = cpu.get_model()
41+
dict_cpu = {"251": "milan", "2517": "genoa", "2617": "turin"}
42+
key = str(family_id) + str(model_id)
43+
host_cpu_model = dict_cpu.get(key, "unknown")
44+
3945
vm_name = params["main_vm"]
4046
vm = env.get_vm(vm_name)
4147
vm.create()
@@ -65,6 +71,7 @@ def run(test, params, env):
6571
session.cmd_output("chmod 755 %s" % guest_cmd)
6672
except Exception as e:
6773
test.fail("Guest test preperation fail: %s" % str(e))
74+
guest_cmd = guest_cmd + " " + host_cpu_model
6875
s = session.cmd_status(guest_cmd, timeout=360)
6976
if s:
7077
test.fail("Guest script error")

qemu/tests/snp_multi_vm.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22

3+
from avocado.utils import cpu
34
from virttest import data_dir as virttest_data_dir
45
from virttest import env_process, error_context
56
from virttest.utils_misc import get_mem_info, normalize_data_size, verify_dmesg
@@ -23,6 +24,12 @@ def run(test, params, env):
2324
error_context.context("Start sev-snp test", test.log.info)
2425
timeout = params.get_numeric("login_timeout", 240)
2526

27+
family_id = cpu.get_family()
28+
model_id = cpu.get_model()
29+
dict_cpu = {"251": "milan", "2517": "genoa", "2617": "turin"}
30+
key = str(family_id) + str(model_id)
31+
host_cpu_model = dict_cpu.get(key, "unknown")
32+
2633
snp_module_path = params["snp_module_path"]
2734
if os.path.exists(snp_module_path):
2835
with open(snp_module_path) as f:
@@ -66,6 +73,7 @@ def run(test, params, env):
6673
session.cmd_output("chmod 755 %s" % guest_cmd)
6774
except Exception as e:
6875
test.fail("Guest test preperation fail: %s" % str(e))
76+
guest_cmd = guest_cmd + " " + host_cpu_model
6977
s = session.cmd_status(guest_cmd, timeout=360)
7078
if s:
7179
test.fail("Guest script error")

0 commit comments

Comments
 (0)