mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-30 23:06:27 +00:00
Merge pull request #9988 from huoqifeng/annotation
initdata: add initdata annotation in hypervisor config
This commit is contained in:
commit
2a9ed19512
@ -556,6 +556,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
|
||||
}
|
||||
|
@ -773,6 +773,12 @@ func TestAddRemoteHypervisorAnnotations(t *testing.T) {
|
||||
ocispec.Annotations[vcAnnotations.DefaultMemory] = "1"
|
||||
err = addAnnotations(ocispec, &sbConfig, runtimeConfig)
|
||||
assert.NoError(err)
|
||||
|
||||
// When initdata specified, remote hypervisor annotations do have the annotation added.
|
||||
ocispec.Annotations[vcAnnotations.Initdata] = "initdata"
|
||||
err = addAnnotations(ocispec, &sbConfig, runtimeConfig)
|
||||
assert.NoError(err)
|
||||
assert.Equal(sbConfig.HypervisorConfig.Initdata, "initdata")
|
||||
}
|
||||
|
||||
func TestAddProtectedHypervisorAnnotations(t *testing.T) {
|
||||
@ -860,6 +866,7 @@ func TestAddRuntimeAnnotations(t *testing.T) {
|
||||
ocispec.Annotations[vcAnnotations.DisableNewNetNs] = "true"
|
||||
ocispec.Annotations[vcAnnotations.InterNetworkModel] = "macvtap"
|
||||
ocispec.Annotations[vcAnnotations.CreateContainerTimeout] = "100"
|
||||
ocispec.Annotations[vcAnnotations.Initdata] = "initdata"
|
||||
|
||||
addAnnotations(ocispec, &config, runtimeConfig)
|
||||
assert.Equal(config.DisableGuestSeccomp, true)
|
||||
@ -867,6 +874,7 @@ func TestAddRuntimeAnnotations(t *testing.T) {
|
||||
assert.Equal(config.NetworkConfig.DisableNewNetwork, true)
|
||||
assert.Equal(config.NetworkConfig.InterworkingModel, vc.NetXConnectMacVtapModel)
|
||||
assert.Equal(config.CreateContainerTimeout, uint64(100))
|
||||
assert.Equal(config.HypervisorConfig.Initdata, "initdata")
|
||||
}
|
||||
|
||||
func TestRegexpContains(t *testing.T) {
|
||||
|
@ -684,6 +684,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
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user