Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit 4111ef8

Browse files
authored
Merge pull request #3055 from amshinde/stable-1.11-backports
Stable 1.11 backports
2 parents f779d5c + eca202e commit 4111ef8

14 files changed

Lines changed: 260 additions & 107 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/cli/config/configuration-qemu-virtiofs.toml
1212
/cli/config/configuration-clh.toml
1313
/cli/config-generated.go
14+
/cli/containerd-shim-kata-v2/config-generated.go
1415
/cli/coverage.html
1516
/containerd-shim-kata-v2
1617
/data/kata-collect-data.sh

cli/delete.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"context"
1111
"fmt"
1212
"os"
13+
"syscall"
1314

1415
"github.com/kata-containers/runtime/pkg/katautils"
1516
vc "github.com/kata-containers/runtime/virtcontainers"
@@ -75,6 +76,11 @@ func delete(ctx context.Context, containerID string, force bool) error {
7576
kataLog.Warnf("Failed to get container, force will not fail: %s", err)
7677
return nil
7778
}
79+
if err.Error() == syscall.ENOENT.Error() {
80+
kataLog.WithField("container", containerID).Info("skipping delete as container does not exist")
81+
katautils.DelContainerIDMapping(ctx, containerID)
82+
return nil
83+
}
7884
return err
7985
}
8086

cli/kill.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,11 @@ func kill(ctx context.Context, containerID, signal string, all bool) error {
108108

109109
// Checks the MUST and MUST NOT from OCI runtime specification
110110
status, sandboxID, err := getExistingContainerInfo(ctx, containerID)
111-
112111
if err != nil {
112+
if err.Error() == syscall.ENOENT.Error() {
113+
kataLog.WithField("container", containerID).Info("skipping kill as container does not exist")
114+
return nil
115+
}
113116
return err
114117
}
115118

virtcontainers/hypervisor.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -578,11 +578,6 @@ func (conf *HypervisorConfig) HypervisorCtlAssetPath() (string, error) {
578578
return conf.assetPath(types.HypervisorCtlAsset)
579579
}
580580

581-
// JailerAssetPath returns the VM Jailer path
582-
func (conf *HypervisorConfig) JailerAssetPath() (string, error) {
583-
return conf.assetPath(types.JailerAsset)
584-
}
585-
586581
// CustomHypervisorAsset returns true if the hypervisor asset is a custom one, false otherwise.
587582
func (conf *HypervisorConfig) CustomHypervisorAsset() bool {
588583
return conf.isCustomAsset(types.HypervisorAsset)
@@ -593,11 +588,6 @@ func (conf *HypervisorConfig) FirmwareAssetPath() (string, error) {
593588
return conf.assetPath(types.FirmwareAsset)
594589
}
595590

596-
// CustomFirmwareAsset returns true if the firmware asset is a custom one, false otherwise.
597-
func (conf *HypervisorConfig) CustomFirmwareAsset() bool {
598-
return conf.isCustomAsset(types.FirmwareAsset)
599-
}
600-
601591
func appendParam(params []Param, parameter string, value string) []Param {
602592
return append(params, Param{parameter, value})
603593
}

virtcontainers/hypervisor_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,3 +456,41 @@ func TestGenerateVMSocket(t *testing.T) {
456456
assert.NotZero(vsock.ContextID)
457457
assert.NotZero(vsock.Port)
458458
}
459+
460+
func TestAssetPath(t *testing.T) {
461+
assert := assert.New(t)
462+
463+
// Minimal config containing values for all asset annotation options.
464+
// The values are "paths" (start with a slash), but end with the
465+
// annotation name.
466+
cfg := HypervisorConfig{
467+
HypervisorPath: "/" + "io.katacontainers.config.hypervisor.path",
468+
HypervisorCtlPath: "/" + "io.katacontainers.config.hypervisor.ctlpath",
469+
470+
KernelPath: "/" + "io.katacontainers.config.hypervisor.kernel",
471+
472+
ImagePath: "/" + "io.katacontainers.config.hypervisor.image",
473+
InitrdPath: "/" + "io.katacontainers.config.hypervisor.initrd",
474+
475+
FirmwarePath: "/" + "io.katacontainers.config.hypervisor.firmware",
476+
JailerPath: "/" + "io.katacontainers.config.hypervisor.jailer_path",
477+
}
478+
479+
for _, asset := range types.AssetTypes() {
480+
msg := fmt.Sprintf("asset: %v", asset)
481+
482+
annoPath, annoHash, err := asset.Annotations()
483+
assert.NoError(err, msg)
484+
485+
msg += fmt.Sprintf(", annotation path: %v, annotation hash: %v", annoPath, annoHash)
486+
487+
p, err := cfg.assetPath(asset)
488+
assert.NoError(err, msg)
489+
490+
assert.NotEqual(p, annoPath, msg)
491+
assert.NotEqual(p, annoHash, msg)
492+
493+
expected := fmt.Sprintf("/%s", annoPath)
494+
assert.Equal(expected, p, msg)
495+
}
496+
}

virtcontainers/pkg/annotations/annotations.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ const (
4141
// HypervisorPath is a sandbox annotation for passing a per container path pointing at the hypervisor that will run the container VM.
4242
HypervisorPath = kataAnnotHypervisorPrefix + "path"
4343

44+
// HypervisorCtlPath is a sandbox annotation for passing a per container path pointing at the hypervisor control binary that will run the container VM.
45+
HypervisorCtlPath = kataAnnotHypervisorPrefix + "ctlpath"
46+
4447
// JailerPath is a sandbox annotation for passing a per container path pointing at the jailer that will constrain the container VM.
4548
JailerPath = kataAnnotHypervisorPrefix + "jailer_path"
4649

@@ -59,6 +62,9 @@ const (
5962
// HypervisorHash is an sandbox annotation for passing a container hypervisor binary SHA-512 hash value.
6063
HypervisorHash = kataAnnotHypervisorPrefix + "hypervisor_hash"
6164

65+
// HypervisorCtlHash is a sandbox annotation for passing a container hypervisor control binary SHA-512 hash value.
66+
HypervisorCtlHash = kataAnnotHypervisorPrefix + "hypervisorctl_hash"
67+
6268
// JailerHash is an sandbox annotation for passing a jailer binary SHA-512 hash value.
6369
JailerHash = kataAnnotHypervisorPrefix + "jailer_hash"
6470

virtcontainers/pkg/oci/utils.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,11 @@ func SandboxID(spec specs.Spec) (string, error) {
335335
}
336336

337337
func addAnnotations(ocispec specs.Spec, config *vc.SandboxConfig) error {
338-
addAssetAnnotations(ocispec, config)
338+
err := addAssetAnnotations(ocispec, config)
339+
if err != nil {
340+
return err
341+
}
342+
339343
if err := addHypervisorConfigOverrides(ocispec, config); err != nil {
340344
return err
341345
}
@@ -350,17 +354,10 @@ func addAnnotations(ocispec specs.Spec, config *vc.SandboxConfig) error {
350354
return nil
351355
}
352356

353-
func addAssetAnnotations(ocispec specs.Spec, config *vc.SandboxConfig) {
354-
assetAnnotations := []string{
355-
vcAnnotations.KernelPath,
356-
vcAnnotations.ImagePath,
357-
vcAnnotations.InitrdPath,
358-
vcAnnotations.FirmwarePath,
359-
vcAnnotations.KernelHash,
360-
vcAnnotations.ImageHash,
361-
vcAnnotations.InitrdHash,
362-
vcAnnotations.FirmwareHash,
363-
vcAnnotations.AssetHashType,
357+
func addAssetAnnotations(ocispec specs.Spec, config *vc.SandboxConfig) error {
358+
assetAnnotations, err := types.AssetAnnotations()
359+
if err != nil {
360+
return err
364361
}
365362

366363
for _, a := range assetAnnotations {
@@ -371,6 +368,8 @@ func addAssetAnnotations(ocispec specs.Spec, config *vc.SandboxConfig) {
371368

372369
config.Annotations[a] = value
373370
}
371+
372+
return nil
374373
}
375374

376375
func addHypervisorConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig) error {

virtcontainers/pkg/oci/utils_test.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -665,12 +665,26 @@ func TestAddAssetAnnotations(t *testing.T) {
665665
assert := assert.New(t)
666666

667667
expectedAnnotations := map[string]string{
668-
vcAnnotations.KernelPath: "/abc/rgb/kernel",
669-
vcAnnotations.ImagePath: "/abc/rgb/image",
670-
vcAnnotations.InitrdPath: "/abc/rgb/initrd",
671-
vcAnnotations.KernelHash: "3l2353we871g",
672-
vcAnnotations.ImageHash: "52ss2550983",
673-
vcAnnotations.AssetHashType: "sha",
668+
vcAnnotations.FirmwarePath: "/some/where",
669+
vcAnnotations.FirmwareHash: "ffff",
670+
671+
vcAnnotations.HypervisorPath: "/some/where",
672+
vcAnnotations.HypervisorHash: "bbbbb",
673+
674+
vcAnnotations.HypervisorCtlPath: "/some/where/else",
675+
vcAnnotations.HypervisorCtlHash: "cc",
676+
677+
vcAnnotations.ImagePath: "/abc/rgb/image",
678+
vcAnnotations.ImageHash: "52ss2550983",
679+
680+
vcAnnotations.InitrdPath: "/abc/rgb/initrd",
681+
vcAnnotations.InitrdHash: "aaaa",
682+
683+
vcAnnotations.JailerPath: "/foo/bar",
684+
vcAnnotations.JailerHash: "dddd",
685+
686+
vcAnnotations.KernelPath: "/abc/rgb/kernel",
687+
vcAnnotations.KernelHash: "3l2353we871g",
674688
}
675689

676690
config := vc.SandboxConfig{

virtcontainers/qemu.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1965,7 +1965,7 @@ func genericBridges(number uint32, machineType string) []types.Bridge {
19651965
case QemuPC:
19661966
bt = types.PCI
19671967
case QemuVirt:
1968-
bt = types.PCIE
1968+
bt = types.PCI
19691969
case QemuPseries:
19701970
bt = types.PCI
19711971
case QemuCCWVirtio:

virtcontainers/qemu_arm64_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func TestQemuArm64AppendBridges(t *testing.T) {
119119

120120
expectedOut := []govmmQemu.Device{
121121
govmmQemu.BridgeDevice{
122-
Type: govmmQemu.PCIEBridge,
122+
Type: govmmQemu.PCIBridge,
123123
Bus: defaultBridgeBus,
124124
ID: bridges[0].ID,
125125
Chassis: 1,

0 commit comments

Comments
 (0)