runtime: fix initdata support for SNP

the qemu commandline of SNP should start with `sev-snp-guest`, and then
following other parameters separeted by ','. This patch fixes the
parameter order.

Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
This commit is contained in:
Xynnn007 2025-05-29 09:25:59 +08:00
parent 57f3cb8b3b
commit 39aa481da1

View File

@ -404,14 +404,6 @@ func (object Object) QemuParams(config *Config) []string {
driveParams = append(driveParams, "if=pflash,format=raw,readonly=on")
driveParams = append(driveParams, fmt.Sprintf("file=%s", object.File))
case SNPGuest:
if len(object.InitdataDigest) > 0 {
// due to https://github.com/confidential-containers/qemu/blob/amd-snp-202402240000/qapi/qom.json#L926-L929
// hostdata in SEV-SNP should be exactly 32 bytes
hostdataSlice := adjustProperLength(object.InitdataDigest, 32)
hostdata := base64.StdEncoding.EncodeToString(hostdataSlice)
objectParams = append(objectParams, fmt.Sprintf("host-data=%s", hostdata))
}
objectParams = append(objectParams, string(object.Type))
objectParams = append(objectParams, fmt.Sprintf("id=%s", object.ID))
objectParams = append(objectParams, fmt.Sprintf("cbitpos=%d", object.CBitPos))
@ -423,6 +415,13 @@ func (object Object) QemuParams(config *Config) []string {
if object.SnpIdAuth != "" {
objectParams = append(objectParams, fmt.Sprintf("id-auth=%s", object.SnpIdAuth))
}
if len(object.InitdataDigest) > 0 {
// due to https://github.com/confidential-containers/qemu/blob/amd-snp-202402240000/qapi/qom.json#L926-L929
// hostdata in SEV-SNP should be exactly 32 bytes
hostdataSlice := adjustProperLength(object.InitdataDigest, 32)
hostdata := base64.StdEncoding.EncodeToString(hostdataSlice)
objectParams = append(objectParams, fmt.Sprintf("host-data=%s", hostdata))
}
config.Bios = object.File
case SecExecGuest:
objectParams = append(objectParams, string(object.Type))