mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-19 09:51:29 +00:00
runtime: Enable ImageName annotation for remote hypervisor
Enables ImageName to support multiple VM images in remote hypervisor scenario Fixes https://github.com/kata-containers/kata-containers/issues/10240 Signed-off-by: Ajay Victor <ajvictor@in.ibm.com>
This commit is contained in:
parent
1597f8ba00
commit
a19f2eacec
@ -38,7 +38,7 @@ remote_hypervisor_timeout = 600
|
|||||||
# Each member of the list is a regular expression, which is the base name
|
# Each member of the list is a regular expression, which is the base name
|
||||||
# of the annotation, e.g. "path" for io.katacontainers.config.hypervisor.path"
|
# of the annotation, e.g. "path" for io.katacontainers.config.hypervisor.path"
|
||||||
# Note: Remote hypervisor is only handling the following annotations
|
# Note: Remote hypervisor is only handling the following annotations
|
||||||
enable_annotations = ["machine_type", "default_memory", "default_vcpus"]
|
enable_annotations = ["machine_type", "default_memory", "default_vcpus", "image"]
|
||||||
|
|
||||||
# Optional space-separated list of options to pass to the guest kernel.
|
# Optional space-separated list of options to pass to the guest kernel.
|
||||||
# For example, use `kernel_params = "vsyscall=emulate"` if you are having
|
# For example, use `kernel_params = "vsyscall=emulate"` if you are having
|
||||||
|
@ -77,6 +77,7 @@ func (rh *remoteHypervisor) CreateVM(ctx context.Context, id string, network Net
|
|||||||
annotations[cri.SandboxName] = hypervisorConfig.SandboxName
|
annotations[cri.SandboxName] = hypervisorConfig.SandboxName
|
||||||
annotations[cri.SandboxNamespace] = hypervisorConfig.SandboxNamespace
|
annotations[cri.SandboxNamespace] = hypervisorConfig.SandboxNamespace
|
||||||
annotations[hypannotations.MachineType] = hypervisorConfig.HypervisorMachineType
|
annotations[hypannotations.MachineType] = hypervisorConfig.HypervisorMachineType
|
||||||
|
annotations[hypannotations.ImagePath] = hypervisorConfig.ImagePath
|
||||||
annotations[hypannotations.DefaultVCPUs] = strconv.FormatUint(uint64(hypervisorConfig.NumVCPUs()), 10)
|
annotations[hypannotations.DefaultVCPUs] = strconv.FormatUint(uint64(hypervisorConfig.NumVCPUs()), 10)
|
||||||
annotations[hypannotations.DefaultMemory] = strconv.FormatUint(uint64(hypervisorConfig.MemorySize), 10)
|
annotations[hypannotations.DefaultMemory] = strconv.FormatUint(uint64(hypervisorConfig.MemorySize), 10)
|
||||||
annotations[hypannotations.Initdata] = hypervisorConfig.Initdata
|
annotations[hypannotations.Initdata] = hypervisorConfig.Initdata
|
||||||
|
@ -448,13 +448,25 @@ func createAssets(ctx context.Context, sandboxConfig *SandboxConfig) error {
|
|||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
for _, name := range types.AssetTypes() {
|
for _, name := range types.AssetTypes() {
|
||||||
a, err := types.NewAsset(sandboxConfig.Annotations, name)
|
annotation, _, err := name.Annotations()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// For remote hypervisor donot check for Absolute Path incase of ImagePath, as it denotes the name of the image.
|
||||||
|
if sandboxConfig.HypervisorType == RemoteHypervisor && annotation == annotations.ImagePath {
|
||||||
|
value := sandboxConfig.Annotations[annotation]
|
||||||
|
if value != "" {
|
||||||
|
sandboxConfig.HypervisorConfig.ImagePath = value
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
a, err := types.NewAsset(sandboxConfig.Annotations, name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if err := sandboxConfig.HypervisorConfig.AddCustomAsset(a); err != nil {
|
if err := sandboxConfig.HypervisorConfig.AddCustomAsset(a); err != nil {
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -771,6 +771,24 @@ func TestSandboxCreateAssets(t *testing.T) {
|
|||||||
err = createAssets(context.Background(), config)
|
err = createAssets(context.Background(), config)
|
||||||
assert.Error(err, msg)
|
assert.Error(err, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remote Hypervisor scenario for ImagePath
|
||||||
|
msg := "test[image]: imagePath"
|
||||||
|
imagePathData := &testData{
|
||||||
|
assetType: types.ImageAsset,
|
||||||
|
annotations: map[string]string{
|
||||||
|
annotations.ImagePath: "rhel9-os",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
config := &SandboxConfig{
|
||||||
|
Annotations: imagePathData.annotations,
|
||||||
|
HypervisorConfig: hc,
|
||||||
|
HypervisorType: RemoteHypervisor,
|
||||||
|
}
|
||||||
|
|
||||||
|
err = createAssets(context.Background(), config)
|
||||||
|
assert.NoError(err, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testFindContainerFailure(t *testing.T, sandbox *Sandbox, cid string) {
|
func testFindContainerFailure(t *testing.T, sandbox *Sandbox, cid string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user