Compare commits

...

15 Commits
2.3.2 ... 2.3.3

Author SHA1 Message Date
Eric Ernst
97cd593953 Merge pull request #3798 from egernst/2.3.3-branch-bump
# Kata Containers 2.3.3
2022-03-01 10:18:27 -08:00
Eric Ernst
652cff16b4 release: Kata Containers 2.3.3
- back port:: runtime: make selinux configurable
- stable-2.3 | kata-deploy: Use (kata with) qemu as the default shim-v2 binary
- stable-2.3 | shim: log events for CRI-O
- stable-2.3 | agent: fix invalid hooks env issues
- stable-2.3 | packaging: Use `patch` for applying patches

0b6e9f83 runtime: make selinux configurable
408477a2 kata-deploy: Use (kata with) qemu as the default shim-v2 binary
9431498e shim: log events for CRI-O
406f00a3 packaging: Use `patch` for applying patches
7af719e4 agent: handle hook process result
9b34cf46 agent: valid envs for hooks
9c195364 agent: Fix execute_hook() args error
9bea3a42 agent: check environment variables if empty or invalid

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2022-03-01 08:38:59 -08:00
Fabiano Fidêncio
48732f5c4f Merge pull request #3794 from egernst/backport-selinux-build
back port:: runtime: make selinux configurable
2022-03-01 08:54:23 +01:00
Tanweer Noor
0b6e9f8365 runtime: make selinux configurable
removes --tags selinux handling in the makefile (part of it introduced here: d78ffd6)
and makes selinux configurable via configuration.toml

Fixes: #3631
Signed-off-by: Tanweer Noor <tnoor@apple.com>
2022-02-28 20:58:46 -08:00
snir911
d2d579f1aa Merge pull request #3745 from fidencio/stable-2.3-kata-deploy-use-kata-with-qemu-as-the-default-shim-v2-binary
stable-2.3 | kata-deploy: Use (kata with) qemu as the default shim-v2 binary
2022-02-22 14:29:39 +02:00
snir911
a373dc0270 Merge pull request #3744 from liubin/backport/3736
stable-2.3 | shim: log events for CRI-O
2022-02-22 12:30:16 +02:00
Fabiano Fidêncio
408477a263 kata-deploy: Use (kata with) qemu as the default shim-v2 binary
When using kata-deploy, no `containerd-shim-kata-v2` binary is deployed,
but we do deploy a `kata` runtime class, which seems very much
incosistent.

As the default configuration for kata-containers points to QEMU, let's
also use kata with QEMU as the default shim-v2 binary.

Fixes: #3228, #3734

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
(cherry picked from commit 11220f052f)
2022-02-22 09:57:04 +01:00
bin
9431498e14 shim: log events for CRI-O
CRI-O start shim process without setting TTRPC_ADDRESS,
that the forwarding events goroutine will get errors.

For CRI-O runtime, we can log the events to log file.

Fixes: #3733

Signed-off-by: bin <bin@hyper.sh>
2022-02-22 16:27:00 +08:00
Fabiano Fidêncio
41cc86751b Merge pull request #3716 from liubin/backport/3668
stable-2.3 | agent: fix invalid hooks env issues
2022-02-19 08:39:23 +01:00
Fabiano Fidêncio
bf9b364678 Merge pull request #3725 from Jakob-Naucke/backport-fix-apply-patches
stable-2.3 | packaging: Use `patch` for applying patches
2022-02-19 08:38:55 +01:00
Jakob Naucke
406f00a3a2 packaging: Use patch for applying patches
`tools/packaging/scripts/apply_patches.sh` uses `git apply $patch`, but
this will not apply to subdirectories. If one wanted to apply with
`git apply`, they'd have to run it with `--directory=...`
_relative to the Git tree's root_ (absolute will not work!). I suggest
we just use `patch`, which will do what we expected `git apply` would
do.

`patch` is also added to build containers that require it.

Fixes: #3690
Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2022-02-18 16:55:23 +01:00
bin
7af719e47c agent: handle hook process result
Current hook process is handled by just calling
unwrap() on it, sometime it will cause panic.

By handling all Result type and check the error can
avoid panic.

Fixes: #3649

Signed-off-by: bin <bin@hyper.sh>
2022-02-18 15:29:11 +08:00
bin
9b34cf46da agent: valid envs for hooks
Envs contain null-byte will cause running hooks to panic,
this commit will filter envs and only pass valid envs to hooks.

Fixes: #3667

Signed-off-by: bin <bin@hyper.sh>
2022-02-18 15:28:55 +08:00
Binbin Zhang
9c1953641b agent: Fix execute_hook() args error
1. The hook.args[0] is the hook binary name which shouldn't be included
in the Command.args.
2. Add new unit tests

Fixes: #2610

Signed-off-by: Binbin Zhang <binbin36520@gmail.com>
Signed-off-by: bin <bin@hyper.sh>
2022-02-18 15:28:50 +08:00
bin
9bea3a42a7 agent: check environment variables if empty or invalid
Invalid environment variable key/value will cause set_env panic.

Refer: https://doc.rust-lang.org/std/env/fn.set_var.html#panics

Fixes: #3006

Signed-off-by: bin <bin@hyper.sh>
2022-02-18 13:18:01 +08:00
22 changed files with 353 additions and 98 deletions

View File

@@ -1 +1 @@
2.3.2
2.3.3

View File

@@ -636,11 +636,10 @@ fn do_init_child(cwfd: RawFd) -> Result<()> {
// setup the envs
for e in env.iter() {
let v: Vec<&str> = e.splitn(2, '=').collect();
if v.len() != 2 {
continue;
match valid_env(e) {
Some((key, value)) => env::set_var(key, value),
None => log_child!(cfd_log, "invalid env key-value: {:?}", e),
}
env::set_var(v[0], v[1]);
}
// set the "HOME" env getting from "/etc/passwd", if
@@ -1479,15 +1478,15 @@ async fn execute_hook(logger: &Logger, h: &Hook, st: &OCIState) -> Result<()> {
return Err(anyhow!(nix::Error::from_errno(Errno::EINVAL)));
}
let args = h.args.clone();
let env: HashMap<String, String> = h
.env
.iter()
.map(|e| {
let v: Vec<&str> = e.split('=').collect();
(v[0].to_string(), v[1].to_string())
})
.collect();
let mut args = h.args.clone();
// the hook.args[0] is the hook binary name which shouldn't be included
// in the Command.args
if args.len() > 1 {
args.remove(0);
}
// all invalid envs will be omitted, only valid envs will be passed to hook.
let env: HashMap<&str, &str> = h.env.iter().filter_map(|e| valid_env(e)).collect();
// Avoid the exit signal to be reaped by the global reaper.
let _wait_locker = WAIT_PID_LOCKER.lock().await;
@@ -1498,8 +1497,7 @@ async fn execute_hook(logger: &Logger, h: &Hook, st: &OCIState) -> Result<()> {
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
.unwrap();
.spawn()?;
// default timeout 10s
let mut timeout: u64 = 10;
@@ -1515,27 +1513,39 @@ async fn execute_hook(logger: &Logger, h: &Hook, st: &OCIState) -> Result<()> {
let path = h.path.clone();
let join_handle = tokio::spawn(async move {
child
.stdin
.as_mut()
.unwrap()
.write_all(state.as_bytes())
.await
.unwrap();
if let Some(mut stdin) = child.stdin.take() {
match stdin.write_all(state.as_bytes()).await {
Ok(_) => {}
Err(e) => {
info!(logger, "write to child stdin failed: {:?}", e);
}
}
}
// Close stdin so that hook program could receive EOF
child.stdin.take();
// read something from stdout and stderr for debug
if let Some(stdout) = child.stdout.as_mut() {
let mut out = String::new();
match stdout.read_to_string(&mut out).await {
Ok(_) => {
info!(logger, "child stdout: {}", out.as_str());
}
Err(e) => {
info!(logger, "read from child stdout failed: {:?}", e);
}
}
}
// read something from stdout for debug
let mut out = String::new();
child
.stdout
.as_mut()
.unwrap()
.read_to_string(&mut out)
.await
.unwrap();
info!(logger, "child stdout: {}", out.as_str());
let mut err = String::new();
if let Some(stderr) = child.stderr.as_mut() {
match stderr.read_to_string(&mut err).await {
Ok(_) => {
info!(logger, "child stderr: {}", err.as_str());
}
Err(e) => {
info!(logger, "read from child stderr failed: {:?}", e);
}
}
}
match child.wait().await {
Ok(exit) => {
@@ -1544,7 +1554,10 @@ async fn execute_hook(logger: &Logger, h: &Hook, st: &OCIState) -> Result<()> {
.ok_or_else(|| anyhow!("hook exit status has no status code"))?;
if code != 0 {
error!(logger, "hook {} exit status is {}", &path, code);
error!(
logger,
"hook {} exit status is {}, error message is {}", &path, code, err
);
return Err(anyhow!(nix::Error::from_errno(Errno::UnknownErrno)));
}
@@ -1565,6 +1578,30 @@ async fn execute_hook(logger: &Logger, h: &Hook, st: &OCIState) -> Result<()> {
}
}
// valid environment variables according to https://doc.rust-lang.org/std/env/fn.set_var.html#panics
fn valid_env(e: &str) -> Option<(&str, &str)> {
// wherther key or value will contain NULL char.
if e.as_bytes().contains(&b'\0') {
return None;
}
let v: Vec<&str> = e.splitn(2, '=').collect();
// key can't hold an `equal` sign, but value can
if v.len() != 2 {
return None;
}
let (key, value) = (v[0].trim(), v[1].trim());
// key can't be empty
if key.is_empty() {
return None;
}
Some((key, value))
}
#[cfg(test)]
mod tests {
use super::*;
@@ -1597,13 +1634,47 @@ mod tests {
#[tokio::test]
async fn test_execute_hook() {
let xargs = which("xargs").await;
let temp_file = "/tmp/test_execute_hook";
let touch = which("touch").await;
defer!(fs::remove_file(temp_file).unwrap(););
let invalid_str = vec![97, b'\0', 98];
let invalid_string = std::str::from_utf8(&invalid_str).unwrap();
let invalid_env = format!("{}=value", invalid_string);
execute_hook(
&slog_scope::logger(),
&Hook {
path: xargs,
args: vec![],
path: touch,
args: vec!["touch".to_string(), temp_file.to_string()],
env: vec![invalid_env],
timeout: Some(10),
},
&OCIState {
version: "1.2.3".to_string(),
id: "321".to_string(),
status: ContainerState::Running,
pid: 2,
bundle: "".to_string(),
annotations: Default::default(),
},
)
.await
.unwrap();
assert_eq!(Path::new(&temp_file).exists(), true);
}
#[tokio::test]
async fn test_execute_hook_with_error() {
let ls = which("ls").await;
let res = execute_hook(
&slog_scope::logger(),
&Hook {
path: ls,
args: vec!["ls".to_string(), "/tmp/not-exist".to_string()],
env: vec![],
timeout: None,
},
@@ -1616,8 +1687,13 @@ mod tests {
annotations: Default::default(),
},
)
.await
.unwrap()
.await;
let expected_err = nix::Error::from_errno(Errno::UnknownErrno);
assert_eq!(
res.unwrap_err().downcast::<nix::Error>().unwrap(),
expected_err
);
}
#[tokio::test]
@@ -1628,7 +1704,7 @@ mod tests {
&slog_scope::logger(),
&Hook {
path: sleep,
args: vec!["2".to_string()],
args: vec!["sleep".to_string(), "2".to_string()],
env: vec![],
timeout: Some(1),
},
@@ -1988,4 +2064,49 @@ mod tests {
let ret = do_init_child(std::io::stdin().as_raw_fd());
assert!(ret.is_err(), "Expecting Err, Got {:?}", ret);
}
#[test]
fn test_valid_env() {
let env = valid_env("a=b=c");
assert_eq!(Some(("a", "b=c")), env);
let env = valid_env("a=b");
assert_eq!(Some(("a", "b")), env);
let env = valid_env("a =b");
assert_eq!(Some(("a", "b")), env);
let env = valid_env(" a =b");
assert_eq!(Some(("a", "b")), env);
let env = valid_env("a= b");
assert_eq!(Some(("a", "b")), env);
let env = valid_env("a=b ");
assert_eq!(Some(("a", "b")), env);
let env = valid_env("a=b c ");
assert_eq!(Some(("a", "b c")), env);
let env = valid_env("=b");
assert_eq!(None, env);
let env = valid_env("a=");
assert_eq!(Some(("a", "")), env);
let env = valid_env("a==");
assert_eq!(Some(("a", "=")), env);
let env = valid_env("a");
assert_eq!(None, env);
let invalid_str = vec![97, b'\0', 98];
let invalid_string = std::str::from_utf8(&invalid_str).unwrap();
let invalid_env = format!("{}=value", invalid_string);
let env = valid_env(&invalid_env);
assert_eq!(None, env);
let invalid_env = format!("key={}", invalid_string);
let env = valid_env(&invalid_env);
assert_eq!(None, env);
}
}

View File

@@ -165,6 +165,8 @@ DEFDISABLEGUESTSECCOMP := true
#Default experimental features enabled
DEFAULTEXPFEATURES := []
DEFDISABLESELINUX := false
#Default entropy source
DEFENTROPYSOURCE := /dev/urandom
DEFVALIDENTROPYSOURCES := [\"/dev/urandom\",\"/dev/random\",\"\"]
@@ -197,9 +199,6 @@ DEFSANDBOXCGROUPONLY ?= false
DEFBINDMOUNTS := []
# Features
FEATURE_SELINUX ?= check
SED = sed
CLI_DIR = cmd
@@ -437,6 +436,7 @@ USER_VARS += DEFNETWORKMODEL_CLH
USER_VARS += DEFNETWORKMODEL_FC
USER_VARS += DEFNETWORKMODEL_QEMU
USER_VARS += DEFDISABLEGUESTSECCOMP
USER_VARS += DEFDISABLESELINUX
USER_VARS += DEFAULTEXPFEATURES
USER_VARS += DEFDISABLEBLOCK
USER_VARS += DEFBLOCKSTORAGEDRIVER_ACRN
@@ -461,7 +461,6 @@ USER_VARS += DEFVALIDENTROPYSOURCES
USER_VARS += DEFSANDBOXCGROUPONLY
USER_VARS += DEFBINDMOUNTS
USER_VARS += DEFVFIOMODE
USER_VARS += FEATURE_SELINUX
USER_VARS += BUILDFLAGS
@@ -476,21 +475,6 @@ QUIET_TEST = $(Q:@=@echo ' TEST '$@;)
BUILDTAGS :=
ifneq ($(FEATURE_SELINUX),no)
SELINUXTAG := $(shell ./hack/selinux_tag.sh)
ifneq ($(SELINUXTAG),)
override FEATURE_SELINUX = yes
BUILDTAGS += --tags "$(SELINUXTAG)"
else
ifeq ($(FEATURE_SELINUX),yes)
$(error "ERROR: SELinux support requested, but libselinux is not available")
endif
override FEATURE_SELINUX = no
endif
endif
# go build common flags
BUILDFLAGS := -buildmode=pie -mod=vendor ${BUILDTAGS}
@@ -762,9 +746,6 @@ endif
@printf "\tKnown: $(sort $(HYPERVISORS))\n"
@printf "\tAvailable for this architecture: $(sort $(KNOWN_HYPERVISORS))\n"
@printf "\n"
@printf "• Features:\n"
@printf "\tSELinux (FEATURE_SELINUX): $(FEATURE_SELINUX)\n"
@printf "\n"
@printf "• Summary:\n"
@printf "\n"
@printf "\tdestination install path (DESTDIR) : %s\n" $(abspath $(DESTDIR))

View File

@@ -200,6 +200,9 @@ internetworking_model="@DEFNETWORKMODEL_ACRN@"
# (default: true)
disable_guest_seccomp=@DEFDISABLEGUESTSECCOMP@
# disable applying SELinux on the VMM process (default false)
disable_selinux=@DEFDISABLESELINUX@
# If enabled, the runtime will create opentracing.io traces and spans.
# (See https://www.jaegertracing.io/docs/getting-started).
# (default: disabled)

View File

@@ -223,6 +223,9 @@ internetworking_model="@DEFNETWORKMODEL_CLH@"
# (default: true)
disable_guest_seccomp=@DEFDISABLEGUESTSECCOMP@
# disable applying SELinux on the VMM process (default false)
disable_selinux=@DEFDISABLESELINUX@
# If enabled, the runtime will create opentracing.io traces and spans.
# (See https://www.jaegertracing.io/docs/getting-started).
# (default: disabled)

View File

@@ -328,6 +328,9 @@ internetworking_model="@DEFNETWORKMODEL_FC@"
# (default: true)
disable_guest_seccomp=@DEFDISABLEGUESTSECCOMP@
# disable applying SELinux on the VMM process (default false)
disable_selinux=@DEFDISABLESELINUX@
# If enabled, the runtime will create opentracing.io traces and spans.
# (See https://www.jaegertracing.io/docs/getting-started).
# (default: disabled)

View File

@@ -504,6 +504,9 @@ internetworking_model="@DEFNETWORKMODEL_QEMU@"
# (default: true)
disable_guest_seccomp=@DEFDISABLEGUESTSECCOMP@
# disable applying SELinux on the VMM process (default false)
disable_selinux=@DEFDISABLESELINUX@
# If enabled, the runtime will create opentracing.io traces and spans.
# (See https://www.jaegertracing.io/docs/getting-started).
# (default: disabled)

View File

@@ -0,0 +1,88 @@
// Copyright (c) 2022 Ant Group
//
// SPDX-License-Identifier: Apache-2.0
//
package containerdshim
import (
"context"
"os"
"time"
"github.com/containerd/containerd/events"
)
type forwarderType string
const (
forwarderTypeLog forwarderType = "log"
forwarderTypeContainerd forwarderType = "containerd"
// A time span used to wait for publish a containerd event,
// once it costs a longer time than timeOut, it will be canceld.
timeOut = 5 * time.Second
// ttrpc address passed from container runtime.
// For now containerd will pass the address, and CRI-O will not
ttrpcAddressEnv = "TTRPC_ADDRESS"
)
type eventsForwarder interface {
forward()
forwarderType() forwarderType
}
type logForwarder struct {
s *service
}
func (lf *logForwarder) forward() {
for e := range lf.s.events {
shimLog.WithField("topic", getTopic(e)).Infof("post event: %+v", e)
}
}
func (lf *logForwarder) forwarderType() forwarderType {
return forwarderTypeLog
}
type containerdForwarder struct {
s *service
ctx context.Context
publisher events.Publisher
}
func (cf *containerdForwarder) forward() {
for e := range cf.s.events {
ctx, cancel := context.WithTimeout(cf.ctx, timeOut)
err := cf.publisher.Publish(ctx, getTopic(e), e)
cancel()
if err != nil {
shimLog.WithError(err).Error("post event")
}
}
}
func (cf *containerdForwarder) forwarderType() forwarderType {
return forwarderTypeContainerd
}
func (s *service) newEventsForwarder(ctx context.Context, publisher events.Publisher) eventsForwarder {
var forwarder eventsForwarder
ttrpcAddress := os.Getenv(ttrpcAddressEnv)
if ttrpcAddress == "" {
// non containerd will use log forwarder to write events to log
forwarder = &logForwarder{
s: s,
}
} else {
forwarder = &containerdForwarder{
s: s,
ctx: ctx,
publisher: publisher,
}
}
return forwarder
}

View File

@@ -0,0 +1,45 @@
// Copyright (c) 2022 Ant Group
//
// SPDX-License-Identifier: Apache-2.0
//
package containerdshim
import (
"context"
"os"
"testing"
"github.com/containerd/containerd/events"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/vcmock"
"github.com/stretchr/testify/assert"
)
func TestNewEventsForwarder(t *testing.T) {
assert := assert.New(t)
sandbox := &vcmock.Sandbox{
MockID: testSandboxID,
}
s := &service{
id: testSandboxID,
sandbox: sandbox,
containers: make(map[string]*container),
}
// newEventsForwarder will not call publisher to publish events
// so here we can use a nil pointer to test newEventsForwarder
var publisher events.Publisher
// check log forwarder
forwarder := s.newEventsForwarder(context.Background(), publisher)
assert.Equal(forwarderTypeLog, forwarder.forwarderType())
// check containerd forwarder
os.Setenv(ttrpcAddressEnv, "/foo/bar.sock")
defer os.Setenv(ttrpcAddressEnv, "")
forwarder = s.newEventsForwarder(context.Background(), publisher)
assert.Equal(forwarderTypeContainerd, forwarder.forwarderType())
}

View File

@@ -17,7 +17,6 @@ import (
eventstypes "github.com/containerd/containerd/api/events"
"github.com/containerd/containerd/api/types/task"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/events"
"github.com/containerd/containerd/namespaces"
cdruntime "github.com/containerd/containerd/runtime"
cdshim "github.com/containerd/containerd/runtime/v2/shim"
@@ -51,10 +50,6 @@ const (
chSize = 128
exitCode255 = 255
// A time span used to wait for publish a containerd event,
// once it costs a longer time than timeOut, it will be canceld.
timeOut = 5 * time.Second
)
var (
@@ -100,7 +95,8 @@ func New(ctx context.Context, id string, publisher cdshim.Publisher, shutdown fu
go s.processExits()
go s.forward(ctx, publisher)
forwarder := s.newEventsForwarder(ctx, publisher)
go forwarder.forward()
return s, nil
}
@@ -256,17 +252,6 @@ func (s *service) StartShim(ctx context.Context, opts cdshim.StartOpts) (_ strin
return address, nil
}
func (s *service) forward(ctx context.Context, publisher events.Publisher) {
for e := range s.events {
ctx, cancel := context.WithTimeout(ctx, timeOut)
err := publisher.Publish(ctx, getTopic(e), e)
cancel()
if err != nil {
shimLog.WithError(err).Error("post event")
}
}
}
func (s *service) send(evt interface{}) {
// for unit test, it will not initialize s.events
if s.events != nil {

View File

@@ -136,6 +136,7 @@ type hypervisor struct {
GuestSwap bool `toml:"enable_guest_swap"`
Rootless bool `toml:"rootless"`
DisableSeccomp bool `toml:"disable_seccomp"`
DisableSeLinux bool `toml:"disable_selinux"`
}
type runtime struct {
@@ -881,6 +882,7 @@ func newClhHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
SGXEPCSize: defaultSGXEPCSize,
EnableAnnotations: h.EnableAnnotations,
DisableSeccomp: h.DisableSeccomp,
DisableSeLinux: h.DisableSeLinux,
}, nil
}

View File

@@ -388,10 +388,13 @@ func (clh *cloudHypervisor) StartVM(ctx context.Context, timeout int) error {
// virtiofsd are executed by kata-runtime after this call, run with
// the SELinux label. If these processes require privileged, we do
// notwant to run them under confinement.
if err := label.SetProcessLabel(clh.config.SELinuxProcessLabel); err != nil {
return err
if !clh.config.DisableSeLinux {
if err := label.SetProcessLabel(clh.config.SELinuxProcessLabel); err != nil {
return err
}
defer label.SetProcessLabel("")
}
defer label.SetProcessLabel("")
if clh.config.SharedFS == config.VirtioFS {
clh.Logger().WithField("function", "StartVM").Info("Starting virtiofsd")

View File

@@ -354,6 +354,7 @@ func (c *Container) Logger() *logrus.Entry {
return virtLog.WithFields(logrus.Fields{
"subsystem": "container",
"sandbox": c.sandboxID,
"container": c.id,
})
}

View File

@@ -793,10 +793,13 @@ func (fc *firecracker) StartVM(ctx context.Context, timeout int) error {
// are executed by kata-runtime after this call, run with the SELinux
// label. If these processes require privileged, we do not want to run
// them under confinement.
if err := label.SetProcessLabel(fc.config.SELinuxProcessLabel); err != nil {
return err
if !fc.config.DisableSeLinux {
if err := label.SetProcessLabel(fc.config.SELinuxProcessLabel); err != nil {
return err
}
defer label.SetProcessLabel("")
}
defer label.SetProcessLabel("")
err = fc.fcInit(ctx, fcTimeout)
if err != nil {

View File

@@ -511,6 +511,9 @@ type HypervisorConfig struct {
// Disable seccomp from the hypervisor process
DisableSeccomp bool
// Disable selinux from the hypervisor process
DisableSeLinux bool
}
// vcpu mapping from vcpu number to thread number

View File

@@ -23,18 +23,17 @@ import (
"time"
"unsafe"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/rootless"
govmmQemu "github.com/kata-containers/govmm/qemu"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
govmmQemu "github.com/kata-containers/govmm/qemu"
"github.com/kata-containers/kata-containers/src/runtime/pkg/katautils/katatrace"
pkgUtils "github.com/kata-containers/kata-containers/src/runtime/pkg/utils"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/device/config"
persistapi "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist/api"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/rootless"
vcTypes "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/types"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/uuid"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
@@ -818,10 +817,12 @@ func (q *qemu) StartVM(ctx context.Context, timeout int) error {
// virtiofsd are executed by kata-runtime after this call, run with
// the SELinux label. If these processes require privileged, we do
// notwant to run them under confinement.
if err := label.SetProcessLabel(q.config.SELinuxProcessLabel); err != nil {
return err
if !q.config.DisableSeLinux {
if err := label.SetProcessLabel(q.config.SELinuxProcessLabel); err != nil {
return err
}
defer label.SetProcessLabel("")
}
defer label.SetProcessLabel("")
if q.config.SharedFS == config.VirtioFS {
err = q.setupVirtiofsd(ctx)
@@ -835,7 +836,6 @@ func (q *qemu) StartVM(ctx context.Context, timeout int) error {
}
}
}()
}
var strErr string

View File

@@ -18,7 +18,7 @@ spec:
katacontainers.io/kata-runtime: cleanup
containers:
- name: kube-kata-cleanup
image: quay.io/kata-containers/kata-deploy:2.3.2
image: quay.io/kata-containers/kata-deploy:2.3.3
imagePullPolicy: Always
command: [ "bash", "-c", "/opt/kata-artifacts/scripts/kata-deploy.sh reset" ]
env:

View File

@@ -16,7 +16,7 @@ spec:
serviceAccountName: kata-label-node
containers:
- name: kube-kata
image: quay.io/kata-containers/kata-deploy:2.3.2
image: quay.io/kata-containers/kata-deploy:2.3.3
imagePullPolicy: Always
lifecycle:
preStop:

View File

@@ -19,6 +19,8 @@ shims=(
"clh"
)
default_shim="qemu"
# If we fail for any reason a message will be displayed
die() {
msg="$*"
@@ -97,6 +99,11 @@ function configure_different_shims_base() {
KATA_CONF_FILE=/opt/kata/share/defaults/kata-containers/configuration-${shim}.toml /opt/kata/bin/containerd-shim-kata-v2 "\$@"
EOT
chmod +x "$shim_file"
if [ "${shim}" == "${default_shim}" ]; then
echo "Creating the default shim-v2 binary"
ln -sf "${shim_file}" /usr/local/bin/containerd-shim-kata-v2
fi
done
}
@@ -112,6 +119,8 @@ function cleanup_different_shims_base() {
mv "$shim_backup" "$shim_file"
fi
done
rm /usr/local/bin/containerd-shim-kata-v2
}
function configure_crio_runtime() {

View File

@@ -40,7 +40,7 @@ if [ -d "$patches_dir" ]; then
echo "INFO: Found ${#patches[@]} patches"
for patch in ${patches[@]}; do
echo "INFO: Apply $patch"
git apply "$patch" || \
patch -p1 < "$patch" || \
{ echo >&2 "ERROR: Not applied. Exiting..."; exit 1; }
done
else

View File

@@ -16,6 +16,7 @@ RUN apt-get update && \
flex \
git \
iptables \
libelf-dev && \
libelf-dev \
patch && \
if [ "$(uname -m)" = "s390x" ]; then apt-get install -y --no-install-recommends libssl-dev; fi && \
apt-get clean && rm -rf /var/lib/lists/

View File

@@ -43,6 +43,7 @@ RUN apt-get update && apt-get upgrade -y && \
pkg-config \
libseccomp-dev \
libseccomp2 \
patch \
python \
python-dev \
rsync \