diff --git a/src/runtime/pkg/oci/utils.go b/src/runtime/pkg/oci/utils.go index e3cfd1b6c7..ee70686d3c 100644 --- a/src/runtime/pkg/oci/utils.go +++ b/src/runtime/pkg/oci/utils.go @@ -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 } diff --git a/src/runtime/virtcontainers/hypervisor.go b/src/runtime/virtcontainers/hypervisor.go index aa30823247..4e4c992a1b 100644 --- a/src/runtime/virtcontainers/hypervisor.go +++ b/src/runtime/virtcontainers/hypervisor.go @@ -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 diff --git a/src/runtime/virtcontainers/pkg/annotations/annotations.go b/src/runtime/virtcontainers/pkg/annotations/annotations.go index 9414d05397..8b6adc56fa 100644 --- a/src/runtime/virtcontainers/pkg/annotations/annotations.go +++ b/src/runtime/virtcontainers/pkg/annotations/annotations.go @@ -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 diff --git a/src/runtime/virtcontainers/remote.go b/src/runtime/virtcontainers/remote.go index 0250566736..d0bb1674c3 100644 --- a/src/runtime/virtcontainers/remote.go +++ b/src/runtime/virtcontainers/remote.go @@ -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,