initdata: add initdata annotation in hypervisor config

- Add Initdata annotation for hypervisor config, so that it can be passed when CreateVM

Signed-off-by: Qi Feng Huo <huoqif@cn.ibm.com>
This commit is contained in:
Qi Feng Huo 2024-07-10 09:12:02 +08:00
parent ff498c55d1
commit 4d66ee1935
4 changed files with 10 additions and 0 deletions

View File

@ -542,6 +542,9 @@ func addHypervisorConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig,
config.HypervisorConfig.SGXEPCSize = size
}
if initdata, ok := ocispec.Annotations[vcAnnotations.Initdata]; ok {
config.HypervisorConfig.Initdata = initdata
}
return nil
}

View File

@ -680,6 +680,9 @@ type HypervisorConfig struct {
// QgsPort defines Intel Quote Generation Service port exposed from the host
QgsPort uint32
// Initdata defines the initdata passed into guest when CreateVM
Initdata string
}
// vcpu mapping from vcpu number to thread number

View File

@ -243,6 +243,9 @@ const (
// EnableRootlessHypervisor is a sandbox annotation to enable rootless hypervisor (only supported in QEMU currently).
EnableRootlessHypervisor = kataAnnotHypervisorPrefix + "rootless"
// Initdata is the initdata passed in when CreateVM
Initdata = kataConfAnnotationsPrefix + "runtime.cc_init_data"
)
// Runtime related annotations

View File

@ -79,6 +79,7 @@ func (rh *remoteHypervisor) CreateVM(ctx context.Context, id string, network Net
annotations[hypannotations.MachineType] = hypervisorConfig.HypervisorMachineType
annotations[hypannotations.DefaultVCPUs] = strconv.FormatUint(uint64(hypervisorConfig.NumVCPUs()), 10)
annotations[hypannotations.DefaultMemory] = strconv.FormatUint(uint64(hypervisorConfig.MemorySize), 10)
annotations[hypannotations.Initdata] = hypervisorConfig.Initdata
req := &pb.CreateVMRequest{
Id: id,