Commit Graph

10414 Commits

Author SHA1 Message Date
Fabiano Fidêncio
4d835f6089 cache_components: Add the ability to cache the rootfs
This is the most complex part to cache, as the cached component can be
only used if:
* There were no changes in the agent
* There were no changes in the libs (used by the agent)
* There were no changes in the rootfs build scripts
* There is no change in the version of the following components:
  * attestation-agent (part of the rootfs)
  * gperf (used to build libseccomp)
  * libseccomp (used to build the agent)
  * pause image (part of the rootfs)
  * skopeo (part of the rootfs)
  * umoci (part of the rootfs)
  * rust (used to build the kata-containers and attestation agents)

We're relying on the last commit merged on places related to the rootfs
generation  and using that as the rootfs version and that should be good
enough for what we need.

Apart from everything already mentioned, we've also added the ability to
cache the `root_hash_vanilla.txt` and `root_hash_tdx.txt` files, as
those are needed for when building the shim-v2, in order to have
measured boot working there.

It's important to note that we've added the ability to cache *both*
files, and I've taken that path as the shim-v2 cache work (which will
come soon) relies on both files.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-12-12 16:07:45 +01:00
Fabiano Fidêncio
d3e0190786
Merge pull request #5876 from fidencio/topic/CC-rework-build-dependencies-so-measured-rootfs-can-be-used
Rework how we build the payload so measured boot can be used with the Operator
2022-12-12 16:03:45 +01:00
Fabiano Fidêncio
740387b569
Merge pull request #5829 from singhwang/main
fix kata deploy error after node reboot.
2022-12-12 14:20:14 +01:00
Fabiano Fidêncio
aa351bc989 kata-deploy-binaries: Print extra_opts when building shim-v2
This will help us, in the future, to debug any possible issue related to
the measured rootfs arguments passed to the shim during the build time.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-12-12 13:54:56 +01:00
Fabiano Fidêncio
e1f075dc60 actions: Consider root_hash_*.txt for the CC actions
The ability to do a measured boot has been overlooked when releasing the
payload consumed by the Confidential Containers project, and this
happened as we depend, at the shim-v2 build time, of a `root_hash_*.txt`
generated in the `tools/osbuilder/` directory, which is then used to add
a specific parameter to the `kernel_params` in the Kata Containers
configuration files.

With everything said above, the best way we can ensure this is done is
by saving those files during the rootfs build, download them during the
shim-v2 build (which *must* happen only after the rootfs builds happen),
and correctly use them there.

Fixes: #5847

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-12-12 13:54:56 +01:00
Fabiano Fidêncio
788f1e6d61 config: Adjust TDXKERNELPARAMS for different VMMs
As Cloud Hypervisor and QEMU are using different rootfs images (the
former with `offline_fs_kbc` as aa_kbc, and the latter with `eaa_kbc`),
we need to differentiate the kernel parameters passed to each one of
those, as the `root_hash.txt` file used for measured boot will differ
according to the rootfs used.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-12-12 13:54:56 +01:00
Fabiano Fidêncio
24c7066425 config: Drop $(ROOTMEASURECONFIG) from SEV kernel param
This is not used at all, as SEV relies on an initrd instead of relying
on an image.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-12-12 13:54:56 +01:00
Fabiano Fidêncio
0a1de98179 build_image: config: Allow passing a specific root_hash_suffix
By doing this we can ensure that when building different rootfs-images
we won't end up overring the `root_hash.txt` file.

Plus, this will help us later in this series to pass the correct
argument to be used with the respective image.

Nothing's been done for SEV as it uses a initrd instead of an image.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-12-12 13:54:52 +01:00
singhwang
b087667ac5 kata-deploy: Fix the pod of kata deploy starts to occur an error
If a pod of kata is deployed on a machine, after the machine restarts, the pod status of kata-deploy will be CrashLoopBackOff.

Fixes: #5868
Signed-off-by: SinghWang <wangxin_0611@126.com>
2022-12-12 19:11:38 +08:00
Peng Tao
79cf38e6ea runtime-rs: clear OCI spec namespace path
None of the host namespace paths make sense in the guest. Let's clear
them all before sending the spec to the agent.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-12-12 11:07:14 +00:00
Peng Tao
62f4603e81 runtime-rs: reset rdma cgroup
We don't support rdma cgroups yet. Let's make sure it is reset to empty.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-12-12 09:57:24 +00:00
Peng Tao
5b6596f54e runtime-rs: CreateContainerRequest has Default
We can just use it to initialize the default fields.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-12-12 09:57:24 +00:00
Peng Tao
e9e82ce28b runtime-rs: fix is_pid_namespace_enabled check
We should test is_pid_namespace_enabled before amending the container
spec, where the pid namespace path is cleared and resulting
sandbox_pidns to always being false.

Fixes: #5881
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-12-12 09:54:48 +00:00
Xuewei Niu
8079a9732d kata-sys-util: fix issues where umount2 couldn't get the correct path
Strings in Rust don't have \0 at the end, but C does, which leads to `umount2`
in the libc can't get the correct path. Besides, calling `nix::mount::umount2`
to avoid using an unsafe block is a robust solution.

Fixes: #5871

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2022-12-12 11:50:32 +08:00
Yipeng Yin
4661ea8d3b runtime-rs: fix standalone share fs
Standalone share fs should add virtiofs device in setup_device_before_start_vm
and return the storages to mount the directory in guest. And it uses
hypervisor's jailer root directly instead of jail config.

Besides, we tweaked the parameter, so it adapts to rust version virtiofsd
now. And its cache policy which forbids caching is "never" now,  instead of
"none". Hence, we change the default cache mode.

Fixes: #5655

Signed-off-by: Yipeng Yin <yinyipeng@bytedance.com>
2022-12-12 10:58:09 +08:00
GabyCT
67e82804c5
Merge pull request #5865 from GabyCT/topic/fixspacesovmfscript
tools: Fix indentation for ovmf script
2022-12-09 15:33:49 -06:00
Fabiano Fidêncio
2d48300bf8 build_image: Don't add root_hash.txt to the final tarball
Adding the `root_hash.txt` to the final tarball doesn't bring any
benefit to the project, as the file dependency is for building the
shim-v2 and passing the correct measurement for the kernel command line.

It's important to mention that when building shim-v2, it doesn't look
for the file in `/opt/confidential-containers/share/kata-containers`,
bur rather in the `${repo_root_dir}/tools/osbuilder/`, as shown here:
ac3683e26e/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh (L228-L232)

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-12-09 21:01:54 +01:00
Fabiano Fidêncio
de4f1231c0
Merge pull request #5852 from BbolroC/payload-390x-fix
CC: Fix issues on cc-payload-ci workflow for s390x
2022-12-09 20:26:08 +01:00
Fabiano Fidêncio
bd753b5834
Merge pull request #5863 from fidencio/topic/CC-rework-tdx-config-files
CC | Rework TDX runtime configuration files
2022-12-09 16:52:21 +01:00
Jianyong Wu
c5abc5ed4d config: speed up rng init when kernel boot for arm64
For now, rng init is too slow for kata3.0/dragonball. Enable
random_trust_cpu can speed up rng init when kernel boot.

Fixes: #5870
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2022-12-09 14:20:18 +08:00
Gabriela Cervantes
3e6114b2ef tools: Fix indentation for ovmf script
This PR fixes the indentation for the ovmf script for packaging.

Fixes #5864

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
2022-12-08 16:12:20 +00:00
Fabiano Fidêncio
a75e83ab41 config: Drop clh-tdx-eaa-kbc configuration file
It turns out that there's more work needed to be done on the Cloud
Hypervisor side so we can fully support EAA_KBC with it.

For now, let's remove the configuration as the tests are not currently
passing when using it, and stick to the `offline_fs_kbc` and its
specific image for the Cloud Hypervisor + TDX case.

Fixes: #5862

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-12-08 13:29:15 +01:00
Fabiano Fidêncio
788c327cac config: Set qemu-tdx as the one with eaa_kbc support
The `qemu-tdx` configuration is tied to using `offline_fs_kbc` as the
aa_kbc, which is something we're moving away from.

With this in mind, let's rename the `qemu-tdx-eaa-kbc` to `qemu-tdx` and
decrease the amount of the way too many configurations that we ship.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-12-08 13:09:21 +01:00
Fabiano Fidêncio
7257470fdc
Merge pull request #5855 from Megan-Wright/CCv0
CC: Merge main into CCv0 branch
2022-12-08 12:10:57 +01:00
Greg Kurz
5ef7ed72ae
Merge pull request #5610 from UiPath/fix-process-wait
runtime: prevent waiting 50 ms minimum for a process exit
2022-12-08 11:02:39 +01:00
Mathias Flagey
ebe5c5adf9
docs: Update virtiofsd build script in the developer guide
Script to execute to build virtiofsd has been changed in #5426 but not in the doc. This commit update the developer guide.

Fixes: #5860

Signed-off-by: Mathias Flagey <mathiasflagey1201@gmail.com>
2022-12-08 09:29:10 +01:00
Peng Tao
0a1d1ec2fa
Merge pull request #5830 from openanolis/fix-high-cpu
runtime-rs: fix high cpu
2022-12-08 12:16:06 +08:00
Steve Horsman
39394fa2a8
Merge pull request #5844 from jtumber-ibm/patch-1
agent: remove `sysinfo` dependency
2022-12-07 16:35:05 +00:00
Fupan Li
cce316b5e9
Merge pull request #5607 from justxuewei/feat/sandbox-level-volume
runtime-rs: bind mount volumes in sandbox level
2022-12-07 19:23:38 +08:00
Megan Wright
7c1b3f0b61 CCv0: Merge main into CCv0 branch
Merge remote-tracking branch 'upstream/main' into CCv0

Fixes: #5854
Signed-off-by: Megan Wright <megan.wright@ibm.com>
2022-12-07 11:15:50 +00:00
Chelsea Mafrica
1ff4185111
Merge pull request #5842 from cyyzero/update_install_guide
docs: Update the rust version in the installation documentation
2022-12-06 23:40:35 -08:00
Yuan-Zhuo
7fdbbcda82 agent: Drop the Option for LinuxContainer.cgroup_manager
Cgroup manager for a container will always be created.
Thus, dropping the option for LinuxContainer.cgroup_manager
is feasible and could simplify the code.

Fixes: #5778

Signed-off-by: Yuan-Zhuo <yuanzhuo0118@outlook.com>
2022-12-07 13:40:38 +08:00
Hyounggyu Choi
6e6842c815 CC: Fix issues on cc-payload-ci workflow for s390x
This is to differentiate an artifact name between amd64 and s390x and add a
virtiofsd target for s390x.

Fixes: #5851

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2022-12-06 21:59:53 +01:00
Fabiano Fidêncio
9ac9f99c3a
Merge pull request #5846 from fidencio/topic/fix-install_cc_tee_kernel
kernel: Export KATA_BUILD_CC in install_cc_tee_kernel()
2022-12-06 16:37:50 +01:00
Fabiano Fidêncio
265347993d
Merge pull request #5826 from GeorginaKin/CCv0
CCv0: Merge main into CCv0 branch
2022-12-06 16:29:02 +01:00
Alexandru Matei
d04d45ea05 runtime: use pidfd to wait for processes on Linux
Use pidfd_open and poll on newer versions of Linux to wait
for the process to exit. For older versions use existing wait logic

Fixes: #5617

Signed-off-by: Alexandru Matei <alexandru.matei@uipath.com>
2022-12-06 16:31:05 +02:00
Alexandru Matei
e9ba0c11d0 runtime: use exponential backoff for process wait
Initial wait period between checks is 1ms, and the
next ones are min(wait_period*5, 50ms)

Signed-off-by: Alexandru Matei <alexandru.matei@uipath.com>
2022-12-06 16:30:58 +02:00
Steve Horsman
ac3683e26e
Merge pull request #5783 from BbolroC/multi-arch-payload-ci
CC: Add cc-payload-ci workflow for s390x
2022-12-06 12:15:19 +00:00
Fabiano Fidêncio
32e91d9d8a kernel: Export KATA_BUILD_CC in install_cc_tee_kernel()
As already done for install_cc_kernel(), let's ensure we export
KATA_BUILD_CC=yes as part of the install_cc_tee_kernel.

This is used to generate the hash of the devices in the initramfs.

Fixes: #5845

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-12-06 11:47:46 +01:00
Fabiano Fidêncio
e271eba4e0 kernel: Only print build info when not using cached artefacts
Let's move the info about building initramfs to *after* trying to
install the cached components.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-12-06 11:47:41 +01:00
James Tumber
748f22e7d0 agent: remove sysinfo dependency
Removes the redundant dependency `sysinfo`.

Fixes: #5843

Signed-off-by: James Tumber <james.tumber@ibm.com>
2022-12-06 10:18:53 +00:00
Quanwei Zhou
0019d653d6 runtime-rs: fix high cpu
Fixed the issue when using nonblocking, the `tokio::io::copy()` needing
to handle EAGAIN, resulting in high CPU usage.

Fixes: #5740
Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com>
2022-12-06 14:25:33 +08:00
Chao Wu
326d589ff5
Merge pull request #5822 from liubin/fix/5820-var-name-and-typo
runtime-rs: fix some variable names and typos
2022-12-06 14:24:11 +08:00
Zhongtao Hu
c12bb5008d
Merge pull request #5769 from jongwu/check_host_arm
kata-ctl: add host check for aarch64
2022-12-06 14:05:52 +08:00
Chen Yiyang
46b38458af
docs: Update the rust version in the installation documentation
Rust version in the installation documentation does not match the
requirements. Just fix it.

Fixes: #5841

Signed-off-by: Chen Yiyang <cyyzero@qq.com>
2022-12-06 12:50:32 +08:00
Chao Wu
538bddf4ee
Merge pull request #5811 from tzY15368/fix-katactl-conflict-dependency
kata-ctl: fix dependency version conflict
2022-12-06 10:44:48 +08:00
GabyCT
7830e94e8c
Merge pull request #5827 from GabyCT/topic/cachevirtofsdccc
CCv0: use virtiofsd cache
2022-12-05 09:31:31 -06:00
Hyounggyu Choi
69b037d53e CC: Add cc-payload-ci workflow for s390x
This is to adjust the existing cc-payload-ci workflow for s390x.

Fixes: #5660

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2022-12-05 14:23:23 +01:00
Fabiano Fidêncio
846c765c89
Merge pull request #5834 from mattarnoatibm/agent-target-dependencies
agent: Fix s390x agent build
2022-12-05 14:15:28 +01:00
Gabriela Cervantes
beceb3c844 CCv0: use virtiofsd cache
This PR allow us to use the virtiofsd cache tarball instead of
building it from source.

Fixes #5356

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
2022-12-05 12:41:53 +01:00