Commit Graph

8512 Commits

Author SHA1 Message Date
Samuel Ortiz
56751089c0 katautils: Use a syscall wrapper for the hook JSON state
There is no real equivalent of a thread ID on Darwin.

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
2022-02-28 08:01:53 -08:00
Samuel Ortiz
7d64ae7a41 runtime: Add a syscall wrapper package
It allows to support syscall variations between host OSes.

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
2022-02-28 08:01:53 -08:00
Samuel Ortiz
abc681ca5f katautils: Add Darwin stub for the netNS API
And move the current implementation into a Linux only file.

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
2022-02-28 08:01:53 -08:00
Fabiano Fidêncio
9e3353a7e4
Merge pull request #3732 from YchauWang/wyc-docs-developer
docs: Developer-Guide build a custom Kata agent with musl
2022-02-28 12:14:39 +01:00
Fabiano Fidêncio
de57466212 config: Expand confidential_guest comments
Let's clarify that an error will be reported in case confidential_guest
is enabled, but the hardware where Kata Containers is running doesn't
provide the required feature set.

Fixes: #3787

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-02-28 11:57:42 +01:00
Fabiano Fidêncio
641d475fa6 config: clh: Use "Intel TDX" instead of just "TDX"
Let's use "Intel TDX" rather than just "TDX", as it can ease the
understanding of the terminology.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-02-28 10:27:21 +01:00
Fabiano Fidêncio
0bafa2def9 config: clh: Mention supported TEEs
Let's mention the supported TEEs to be used with confidential guests.

Right now, Cloud Hyperisor supports only Intel TDX, used together with
TD Shim.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-02-28 10:24:33 +01:00
bin
81ed269ed2 runtime: use Cmd.StdoutPipe instead of self-created pipe
Nydusd uses a bufio.Scanner to check if nydusd process has
existed, but stderr/stdout passed to Cmd is self-created pipe,
this pipe will not be closed if the process start failing.

Use standard Cmd.StdoutPipe can close the stdout and kata shim
will detect the existence of the nydusd process, then call cmd.Wait to
reap the process' resources.

Fixes: #3783

Signed-off-by: bin <bin@hyper.sh>
2022-02-28 16:52:49 +08:00
Bin Liu
441fdbaf9f
Merge pull request #3753 from sailorvii/main
kata-agent: Fix mismatching error of cgroup and mountinfo.
2022-02-28 16:07:26 +08:00
sailorvii
8edca8bbd1 kata-agent: Fix mismatching error of cgroup and mountinfo.
The content about systemd in "/proc/self/cgroup" is as:
1:name=systemd:/kubepods/pod1815643d-3789-4e4e-aaf4-00de024912e1/0e15a65bd5f7b30a0b818d90706212354d8b3f0998a1495473c3be9a24706ccf

and in "/prol/self/mountinfo" is as:
30 29 0:26 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:6 - cgroup cgroup rw,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd

The keys extracted from the two files are the same as "name=systemd". So no need to rename the key to "systemd".

Fixes: #3385

Signed-off-by: sailorvii <challengingway@hotmail.com>
2022-02-28 10:03:09 +08:00
Eric Ernst
3997c962c2
Merge pull request #3767 from tanweernoor/02242022-kata-containers-issue-3631
runtime, config: make selinux configurable
2022-02-26 08:44:29 -08:00
Eric Ernst
08976b591b
Merge pull request #3776 from fidencio/wip/fix-unbound-variable-tools-clh
Fix unbound variable / typo on error mesage
2022-02-25 15:49:08 -08:00
Fabiano Fidêncio
a9ba7c132b clh: Fix typo on HotplugRemoveDevice
A copy and paste mistake was made and the error on HotplugRemoveDevice()
should be about removal and not about addition.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-02-25 22:35:32 +01:00
Fabiano Fidêncio
827ab82a82 tools: clh: Fix unbound variable
4c164afbac renamed extra_build_args to
features, but did it only in one place, leading to:
```
21:15:28 /home/jenkins/workspace/kata-containers-2.0-ubuntu-ARM-PR/go/src/github.com/kata-containers/kata-containers/tools/packaging/static-build/cloud-hypervisor/build-static-clh.sh: line 55: features: unbound variable
21:15:29 make[1]: *** [tools/packaging/kata-deploy/local-build/Makefile:30: cloud-hypervisor-tarball-build] Error 1
```

Fixes: #3775

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-02-25 22:35:25 +01:00
Tanweer Noor
082d538cb4 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-25 10:33:46 -08:00
Fabiano Fidêncio
ea1876f057
Merge pull request #3771 from fidencio/wip/clh-tdx
clh: Add TDX support
2022-02-25 18:45:31 +01:00
Samuel Ortiz
1103f5a4d4 virtcontainers: Use FilesystemSharer for sharing the containers files
Switching to the generic FilesystemSharer brings 2 majors improvements:

1. Remove container and sandbox specific code from kata_agent.go
2. Allow for non Linux implementations to provide ways to share
   container files and root filesystems with the Kata Linux guest.

Fixes #3622

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
2022-02-25 17:22:27 +01:00
Samuel Ortiz
533c1c0e86 virtcontainers: Keep all filesystem sharing prep code to sandbox.go
With the Linux implementation of the FilesystemSharer interface, we can
now remove all host filesystem sharing code from kata_agent and keep it
where it belongs: sandbox.go.

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
2022-02-25 17:22:27 +01:00
Samuel Ortiz
61590bbddc virtcontainers: Add a Linux implementation for the FilesystemSharer
This gathers the current kata agent and container filesystem sharing
code into a FilesystemSharer implementation.

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
2022-02-25 17:22:27 +01:00
Samuel Ortiz
03fc1cbd7e virtcontainers: Add a filesystem sharing interface
Filesystem sharing here means the ability to share some parts of the
host filesystem with the guest. It's mostly about sharing files and
container bundle root filesystems.

In order to allow for different file and rootfs sharing implementations,
we define a FilesystemSharer interface.

This interface provides a preparation step, where concrete
implementations will be able to e.g. prepare the host filesysstem.
Then it provides 2 methods, one for sharing any file (regular file or a
directory) and another one for sharing a container root filesystem

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
2022-02-25 17:22:27 +01:00
Fabiano Fidêncio
72434333aa clh: Add TDX support
Let's enable TDX support for Cloud Hypervisor, using td-shim as its
desired firmware.

Fixes: #3632

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-02-25 16:49:21 +01:00
Fabiano Fidêncio
a13b4d5ad8 clh: Add firmware to the config file
"firmware" option was already present for a while, but it's never been
exposed to the configuration file before.

Let's do it now as it can be used, in combination with the newly added
confidential_guest option, to boot a guest VM using the so called
`td-shim`[0] with Cloud Hypervisor.

[0]: https://github.com/confidential-containers/td-shim

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-02-25 16:49:21 +01:00
Fabiano Fidêncio
a8827e0c78 hypervisors: Confidential Guests do not support NVDIMM
NVDIMM is also not supported with Confidential Guests and Virtio Block
devices should be used instead.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-02-25 16:49:21 +01:00
Fabiano Fidêncio
f50ff9f798 hypervisors: Confidential Guests do not support Memory hotplug
Similarly to VCPUs and Device hotplug, Confidential Guests also do not
support Memory hotplug.

Let's make it clear in the documentation and guard the code on both QEMU
and Cloud Hypervisor side to ensure we don't advertise Memory hotplug as
being supported when running Confidential Guests.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-02-25 16:49:21 +01:00
Fabiano Fidêncio
df8ffecde0 hypervisors: Confidential Guests do not support Device hotplug
Similarly to VCPUs hotplug, Confidential Guests also do not support
Device hotplug.

Let's make it clear in the documentation and guard the code on both QEMU
and Cloud Hypervisor side to ensure we don't advertise Device hotplug as
being supported when running Confidential Guests.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-02-25 16:49:21 +01:00
Fabiano Fidêncio
28c4c044e6 hypervisors: Confidential Guests do not support VCPUs hotplug
As confidential guests do not support VCPUs hotplug, let's set the
"DefaultMaxVCPUs" value to "NumVCPUs".

The reason to do this is to ensure that guests will be started with the
correct amount of VCPUs, without giving to the guest with all the
possible VCPUs the host could provide.

One clear side effect of this limitation is that workloads that would
require more VCPUs on their yaml definition will not run on this
scenario.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-02-25 16:49:21 +01:00
Fabiano Fidêncio
29ee870d20 clh: Add confidential_guest to the config file
ConfidentialGuest is an option already present and exposed for QEMU,
which is used for using Kata Containers together with different sorts of
Guest Protections, such as TDX and SEV for x86_64, PEF for ppc64le, and
SE for s390x.

Right now we error out in case confidential_guest is enabled, as we will
be implementing the needed blocks for this as part of this series.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-02-25 16:49:21 +01:00
Fabiano Fidêncio
9621c59691 clh: refactor image / initrd configuration set
This is a small code refactor removing a deadcode based the checks
already done in the generic hypervisor abstraction.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-02-25 16:49:21 +01:00
Fabiano Fidêncio
dcdc412e25 clh: use common kernel params from the hypervisor code
The hypervisor code already defines 3 common kernel root params for the
following cases:
* NVDIMM
* NVDIMM without DAX support
* Virtio Block

As parameters used for cloud-hypervisor have an overlap with the ones
provided by the NVDIMM case, let's take advantage of that.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-02-25 16:49:21 +01:00
Fabiano Fidêncio
4c164afbac versions: Update Cloud Hypervisor to 5343e09e7b8db
Let's bump the Cloud Hypervisor version to 5343e09e7b8db, as that brings
a few fixes we're interested in, such as:

* hypervisor, vmm: Handle TDX hypercalls with INVALID_OPERAND
  - https://github.com/cloud-hypervisor/cloud-hypervisor/pull/3723
    - This is needed for the TDX support on the cloud hypervisor driver,
      which is part of this very same series.

* openapi: Update the PciBdf types
  - https://github.com/cloud-hypervisor/cloud-hypervisor/pull/3748
    - This is needed due to a change in a DeviceNode field, which would
      cause a marshalling / demarshalling error when running with a
      version of cloud-hypervisor that includes the TDX fixes mentioned
      above.

* scripts: dev_cli: Don't quote $features_build
* scripts: dev_cli: Add --features option
  - https://github.com/cloud-hypervisor/cloud-hypervisor/pull/3773
    - This is needed due to changes in the scripts used to build Cloud
      Hypervisor, which are used as part of Kata Containers CIs and
      github actions.

      Due to this change, we're also adapting the build scripts as part
      of this very same commit.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-02-25 16:49:16 +01:00
Jakob Naucke
bbfe7d6591
Merge pull request #3599 from Jakob-Naucke/no-virtio-rng-ccw
virtcontainers: Do not add a virtio-rng-ccw device
2022-02-25 15:27:02 +01:00
Francesco Giudici
3da6006de4
Merge pull request #3751 from fgiudici/kata-monitor_issue3705
kata-monitor: fix collecting metrics for sandboxes not started through CRI
2022-02-25 14:53:12 +01:00
Jakob Naucke
b2a65f9031
virtcontainers: Use available s390x hugepages
in TestHandleHugepages. On s390x, hugepage sizes must be set at boot, so
test with any that are present (default is 1M).

Depends-on: github.com/kata-containers/kata-containers#3770
Fixes: #3763
Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2022-02-25 13:11:00 +01:00
Chelsea Mafrica
6a11dbfa8a
Merge pull request #3762 from Amulyam24/fix-build
runtime: fix package declaration for ppc64le
2022-02-24 12:45:31 -08:00
Amulyam24
cb4230e60e runtime: fix package declaration for ppc64le
Incorrect package name causes build to fail. Fix it
in vm_ppc64le.go

Fixes: #3761

Signed-off-by: Amulyam24 <amulmek1@in.ibm.com>
2022-02-24 15:31:48 +05:30
Eric Ernst
c6cc038364
Merge pull request #3615 from sameo/topic/hypervisor
Make the hypervisor framework not Linux specific
2022-02-23 16:02:00 -08:00
GabyCT
7da7e0a8f5
Merge pull request #3724 from Jakob-Naucke/kata-deploy-s390x
kata-deploy: Simplify Dockerfile and support s390x
2022-02-23 11:38:01 -06:00
Francesco Giudici
fec26f8e51 kata-monitor: trivial: rename symbols & labels
We introduced collection of sandboxes metadata from the CRI that will be
attached to the sandbox metrics: this will allow to immediately match
sandboxes metrics with CRI workloads.
Rename the symbols from *Kube* to *CRI* as the metadata will be there
every time pods are created through CRI, also if kubernetes is not
installed (e.g., 'crictl runp').

Signed-off-by: Francesco Giudici <fgiudici@redhat.com>
2022-02-23 18:34:32 +01:00
Samuel Ortiz
9fd4e5514f runtime: Move the resourcecontrol package one layer up
And try to reduce the number of virtcontainers packages, step by step.

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
2022-02-23 15:48:40 +01:00
Samuel Ortiz
823faee83a virtcontainers: Rename the cgroups package
To resourcecontrol, and make it consistent with the fact that cgroups
are a Linux implementation of the ResourceController interface.

Fixes: #3601

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
2022-02-23 15:48:40 +01:00
Samuel Ortiz
0d1a7da682 virtcontainers: Rename and clean the cgroup interface
We call it a ResourceController, and we make it not so Linux specific.
Now the Linux implementations is the cgroups one.

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
2022-02-23 15:48:40 +01:00
Samuel Ortiz
ad10e201e1 virtcontainers: cgroups: Move non Linux routine to utils.go
Have an OS agnostic file for sharing routines.

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
2022-02-23 15:48:40 +01:00
Samuel Ortiz
d49d0b6f39 virtcontainers: cgroups: Define a cgroup interface
And move the current, Linux-specific implementation into
cgroups_linux.go

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
2022-02-23 15:48:40 +01:00
Francesco Giudici
3ac52e8193 kata-monitor: fix updating sandbox cache at startup
We now rely on fs events only to update the sandbox cache. This is not
true anyway for sandboxes already present at kata-monitor startup: we
just retrieve the list and add them in the cache only when we get their
CRI metadata. If CRI metadata is not available we will never add them to
the sandbox cache.
Fix this by immediately adding the sandboxes we find at startup time to
the sandbox cache.

Fixes: #3705

Signed-off-by: Francesco Giudici <fgiudici@redhat.com>
2022-02-23 11:21:06 +01:00
Francesco Giudici
160bb62138 kata-monitor: bump version to 0.3.0
Since kata-monitor now:
- relies on fs events *only* to update the sandbox cache
- adds CRI meta-data as labels (CRI pod name, namespace and uid)
it deserves a version bump.

Note that while we could let kata-monitor match the runtime version,
kata-monitor will usually work flawlessy with different kata shim
releases: so it makes sense to keep kata-monitor version separated.

Signed-off-by: Francesco Giudici <fgiudici@redhat.com>
2022-02-23 11:17:02 +01:00
wangyongchao.bj
1a3381b096 docs: Developer-Guide build a custom Kata agent with musl
The Developer-Guide.md build a custom kata agent with `x86_64-unknown-linux-musl`.
The `musl` should be changed by the system arch. The system arch is aarch64,
 ppc64le and s390x, the musl should be changed. When the arch is ppc64le or s390x,
the musl should be replaced by the gnu.

Fixes: #3731

Signed-off-by: wangyongchao.bj <wangyongchao.bj@inspur.com>
2022-02-23 15:29:53 +08:00
Fabiano Fidêncio
6a9e5f90f7
Merge pull request #3670 from sameo/topic/nerdctl
Support nerdctl OCI hooks
2022-02-22 23:03:33 +01:00
Fabiano Fidêncio
4729fd0fc2
Merge pull request #3736 from liubin/fix/3733-log-events-for-crio
shim: log events for CRI-O
2022-02-22 09:19:37 +01:00
bin
f6fc1621f7 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 11:02:50 +08:00
Julio Montes
753d639bb3
Merge pull request #3741 from GabyCT/topic/updatecontributing
docs: Update contributing link
2022-02-21 14:03:48 -06:00