Commit Graph

5462 Commits

Author SHA1 Message Date
Dan Mihai
60beb5236d runtime: snp: enable CoCo annotations
Use @DEFENABLEANNOTATIONS_COCO@ in configuration-qemu-snp.toml,
for consistency with the tdx and coco-dev configuration files.

k8s-initdata.bats was failing during CI on SNP without this change,
because the cc_init_data annotation was disabled.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-12 15:38:33 +00:00
Ruoqing He
f6e93c2094 libs: Fix test_get_uds_with_sid_with_zero
Test case for `get_uds_with_sid` with an empty run directory would not
hit the 0 match arm, i.e. "sandbox with the provided prefix {short_id:?}
is not found", because `get_uds_with_sid` will try to create the
directory with provided short id before detecting `target_id`.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-09-11 02:04:54 +00:00
Ruoqing He
b10e5a2250 libs: Fix test_get_uds_with_sid_ok
Preset directory `kata98654sandboxpath1` will produce more than one
`target_id` in `get_uds_with_sid`, which causes test to fail. Remove
that directory to make this test work.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-09-11 02:04:54 +00:00
Ruoqing He
efeba0b8ed libs: Detect guest protection before testing
`test_arch_guest_protection_*` test cases get triggered simultaneously,
which is impossible for a single machine to pass. Modify tests to detect
protection file before preceding.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-09-11 02:04:54 +00:00
Ruoqing He
a9ba18d48c libs: Fix test_execute_hook test
Case 4 of `test_execute_hook` would fail because `args` could not be
empty, while by providing `build_oci_hook` with `vec![]` would result in
empty args at execution stage.

Modify `build_oci_hook` to set args as `None` when empty vector is
provided.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-09-11 02:04:54 +00:00
Steve Horsman
58259aa5f4 Merge pull request #11754 from stevenhorsman/go.mod-1.24.6-bump
versions: Tidy up go.mod versions
2025-09-10 14:11:33 +01:00
Alex Lyn
1d26d07110 Merge pull request #11781 from lifupan/fupan_main_qemu
runtime-rs: log out the qemu console when debug enabled
2025-09-10 16:59:30 +08:00
Steve Horsman
e502fa2feb Merge pull request #11731 from kata-containers/dependabot/go_modules/src/tools/csi-kata-directvolume/github.com/ulikunitz/xz-0.5.14
build(deps): bump github.com/ulikunitz/xz from 0.5.11 to 0.5.14 in /src/tools/csi-kata-directvolume
2025-09-10 09:47:28 +01:00
Steve Horsman
3f25b88f89 Merge pull request #11737 from kata-containers/dependabot/cargo/src/runtime-rs/tracing-subscriber-0.3.20
build(deps): bump tracing-subscriber from 0.3.17 to 0.3.20 in /src/runtime-rs
2025-09-10 09:47:07 +01:00
Fupan Li
16be168062 runtime-rs: log out the qemu console when debug enabled
When hypervisor's debug enabled, log out the qemu's console
messages for kernel boot debugging.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2025-09-10 14:19:15 +08:00
Fupan Li
5715408d61 runtime-rs: add the console device to kernel boot for qemu
Add the console device to kernel boot, thus we can log
out the kernel's boot message for debug.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2025-09-10 14:10:45 +08:00
stevenhorsman
87356269d8 versions: Tidy up go.mod versions
Update go 1.23 references to go 1.24.6 to match
versions.yaml

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2025-09-08 14:03:47 +01:00
stevenhorsman
2d28f3d267 agent-ctl: version: bump hypervisor
Bump the version of runtime-rs' hypervisor crate
to upgrade (indirectly) protobug and remediate vulnerability
RUSTSEC-2024-0437

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2025-09-08 13:23:03 +01:00
dependabot[bot]
5ae34ab240 build(deps): bump github.com/ulikunitz/xz
Bumps [github.com/ulikunitz/xz](https://github.com/ulikunitz/xz) from 0.5.11 to 0.5.14.
- [Commits](https://github.com/ulikunitz/xz/compare/v0.5.11...v0.5.14)

---
updated-dependencies:
- dependency-name: github.com/ulikunitz/xz
  dependency-version: 0.5.14
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-08 11:30:49 +01:00
Alex Lyn
4644a02871 Merge pull request #11752 from Apokleos/fix-hooks-devcgrp
runtime-rs: Remove default value of Linux.Resources.Devices and correctly set Hooks in OCI Spec to meet with Agent Policy requirements
2025-09-07 18:01:02 +08:00
Dan Mihai
9b0b7fc795 genpolicy: print Input and Policy storages
Print the Storage data structures, to help with debugging.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-04 16:03:03 +00:00
Alex Lyn
e235fc1efb runtime-rs: Remove default value of Linux.Resources.Devices in OCI Spec
In certain scenarios, particularly under CoCo/Agent Policy enforcement,
the default initial value of `Linux.Resources.Devices` is considered
non-compliant, leading to container creation failures. To address this
issue and ensure consistency with the behavior in `runtime-go`, this
commit removes the default value of `Linux.Resources.Devices` from the
OCI Spec.

This cleanup ensures that the OCI Spec aligns with runtime expectations
and prevents policy violations during container creation.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-03 18:42:34 +08:00
Alex Lyn
203f7090a6 runtime-rs: Ensure the setting of hooks when OCI Hooks is existing.
Only the StartContainer hook needs to be reserved for execution in the
guest, but we also make sure that the setting happens only when the OCI
Hooks does exist, otherwise we do nothing.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-03 17:38:40 +08:00
Hyounggyu Choi
150c90e32a Merge pull request #11728 from BbolroC/fix-sealed-secret-volume
runtime-rs: Adjust path for sealed secret mount check
2025-09-02 16:57:33 +02:00
Fupan Li
9cc1c76ade Merge pull request #11729 from kata-containers/dependabot/go_modules/src/tools/log-parser/gopkg.in/yaml.v3-3.0.1
build(deps): bump gopkg.in/yaml.v3 from 3.0.0 to 3.0.1 in /src/tools/log-parser
2025-09-02 17:05:51 +08:00
dependabot[bot]
8330dd059f build(deps): bump tracing-subscriber in /src/runtime-rs
Bumps [tracing-subscriber](https://github.com/tokio-rs/tracing) from 0.3.17 to 0.3.20.
- [Release notes](https://github.com/tokio-rs/tracing/releases)
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-subscriber-0.3.17...tracing-subscriber-0.3.20)

---
updated-dependencies:
- dependency-name: tracing-subscriber
  dependency-version: 0.3.20
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-29 20:44:35 +00:00
Xuewei Niu
f6ff9cf717 Merge pull request #11689 from Caspian443/fix-devmapper-selinux-mount-issue
runtime-rs: Empty block-rootfs Storage.options and align with Go runtime
2025-08-29 15:29:46 +08:00
dependabot[bot]
3a0416c99f build(deps): bump gopkg.in/yaml.v3 in /src/tools/log-parser
Bumps gopkg.in/yaml.v3 from 3.0.0 to 3.0.1.

---
updated-dependencies:
- dependency-name: gopkg.in/yaml.v3
  dependency-version: 3.0.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-28 14:03:22 +00:00
Hyounggyu Choi
65fdb18c96 runtime-rs: Adjust path for sealed secret mount check
Mount validation for sealed secret requires the base path to start with
`/run/kata-containers/shared/containers`. Previously, it used
`/run/kata-containers/sandbox/passthrough`, which caused test
failures where volume mounts are used.

This commit renames the path to satisfy the validation check.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2025-08-28 15:38:07 +02:00
Fabiano Fidêncio
08d2ba1969 cgroups: Fix "." parent cgroup special case
ef642fe890 added a special case to avoid
moving cgroups that are on the "default" slice in case of deletion.

However, this special check should be done in the Parent() method
instead, which ensures that the default resource controller ID is
returned, instead of ".".

Fixes: #11599

Signed-off-by: Fabiano Fidêncio <fidencio@northflank.com>
2025-08-27 08:15:15 +02:00
Caspian443
617af4cb3b runtime-rs: Empty block-rootfs Storage.options and align with Go runtime
- Set guest Storage.options for block rootfs to empty (do not propagate host mount options).
- Align behavior with Go runtime: only add xfs nouuid when needed.

Signed-off-by: Caspian443 <scrisis843@gmail.com>
2025-08-26 01:27:21 +00:00
Caspian443
9a7aadaaca libs: Introduce rootfs fs types
- Add new kata-types::fs module with:
  - VM_ROOTFS_FILESYSTEM_EXT4
  - VM_ROOTFS_FILESYSTEM_XFS
  - VM_ROOTFS_FILESYSTEM_EROFS
- Export fs module in src/libs/kata-types/src/lib.rs
- Remove duplicated filesystem constants from src/runtime-rs/crates/hypervisor/src/lib.rs
- Update src/runtime-rs/crates/hypervisor/src/kernel_param.rs (and tests) to import from kata_types::fs

Signed-off-by: Caspian443 <scrisis843@gmail.com>
2025-08-26 01:26:53 +00:00
Fabiano Fidêncio
fd1b8ceed1 runtime: qemu: Add reclaim_guest_freed_memory [BACKPORT]
Similar to what we've done for Cloud Hypervisor in the commit
9f76467cb7, we're backporting a runtime-rs
feature that would be benificial to have as part of the go runtime.

This allows users to use virito-balloon for the hypervisor to reclaim
memory freed by the guest.

Signed-off-by: Fabiano Fidêncio <fidencio@northflank.com>
2025-08-22 23:56:47 +02:00
stevenhorsman
8cbb1a4357 runtime: Fix non constant Errorf formatting
As part of the go 1.24.6 bump there are errors about the incorrect
use of a errorf, so switch to the non-formatting version, or add
the format string as appropriate

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2025-08-22 10:44:15 +02:00
stevenhorsman
381da9e603 versions: Bump golang to 1.24.6
golang 1.25 has been released, so 1.23 is EoL,
so we should update to ensure we don't end up with security issues

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2025-08-22 10:44:15 +02:00
Alex Lyn
91913f9e82 Merge pull request #11711 from stevenhorsman/remote-allow-cc_init_data-annotation
runtime: Enable init_data annotation
2025-08-22 14:41:53 +08:00
Fupan Li
1a0fbbfa32 Merge pull request #11699 from Apokleos/support-nonprotection
runtime-rs: Support initdata within NonProtection scenarios
2025-08-22 10:24:47 +08:00
stevenhorsman
081823b388 runtime: Enable init_data annotation
In #11693 the cc_init_data annotation was changes to be hypervisor
scoped, so each hypervisor needs to explicitly allow it in order to
use it now, so add this to both the go and rust runtime's remote
configurations

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2025-08-21 19:26:10 +01:00
Alex Lyn
e430727cb6 runtime-rs: Change the initdata device driver with block_device_driver
Currently, we change vm_rootfs_driver as the initdata device driver
with block_device_driver.

Fixes #11697

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-08-21 18:56:26 +08:00
Alex Lyn
5cc028a8b1 runtime-rs: Support initdata within NonProtection scenarios
we also need support initdat within nonprotection even though the
platform is detected as NonProtection or usually is called nontee
host. Within these cases, there's no need to validate the item of
`confidential_guest=true`, we believe the result of the method
`available_guest_protection()?`.

Fixes #11697

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-08-21 18:56:23 +08:00
Hyounggyu Choi
faf5aed965 runtime-rs: Adjust VSOCK timeouts for IBM SEL
The default `reconnect_timeout` (3 seconds) was found to be insufficient for
IBM SEL when using VSOCK. This commit updates the timeouts as follows:

- `dial_timeout_ms`: Set to 90ms to match the value used in go-runtime for IBM SEL
- `reconnect_timeout_ms`: Increased to 5000ms based on empirical testing

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2025-08-21 12:35:44 +02:00
Hyounggyu Choi
b7d2973ce5 Merge pull request #11696 from BbolroC/enable-initdata-ibm-sel-runtime-rs
runtime-rs Enable initdata IBM SEL
2025-08-21 09:23:46 +02:00
Hyounggyu Choi
2ec70bc8e2 runtime-rs: Enable initdata spec for IBM SEL
Add support for the `InitData` resource config on IBM SEL,
so that a corresponding block device is created and the
initdata is passed to the guest through this device.

Note that we skip passing the initdata hash via QEMU’s
object, since the hypervisor does not yet support this
mechanism for IBM SEL. It will be introduced separately
once QEMU adds the feature.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2025-08-20 18:57:50 +02:00
Markus Rudy
30aff429df Merge pull request #11647 from Park-Jiyeonn/opt/sealed-secret-prefix-check
Optimize sealed secret scanning to avoid full file reads
2025-08-20 17:18:20 +02:00
Alex Lyn
014ab2fce6 Merge pull request #11693 from BbolroC/revert-initdata-annotation
runtime-rs: Fix issues for initdata
2025-08-20 21:17:52 +08:00
Fupan Li
29ab8df881 Merge pull request #11514 from Apokleos/ci-for-libs
CI: Introduce CI for libs to Improve code quality and reduce noises
2025-08-20 18:59:27 +08:00
Hyounggyu Choi
0ac8f1f70e Merge pull request #11705 from Apokleos/remove-default-guesthookpath
kata-types: remove default setting of guest_hook_path
2025-08-20 11:15:25 +02:00
Hyounggyu Choi
0daafecef2 Revert "runtime-rs: Correct the coresponding initdata annotation const"
This reverts commit 37685c41c7.

This renames the relevant constant for initdata.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2025-08-20 10:15:23 +02:00
Hyounggyu Choi
f0db4032f2 Revert "kata-types: Align the initdata annotation with kata-runtime's definition"
This reverts commit ede773db17.

`cc_init_data` should be under a hypervisor category because
it is a hypervisor-specific feature. The annotation including
`runtime` also breaks a logic for `is_annotation_enabled()`.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2025-08-20 10:15:23 +02:00
Hyounggyu Choi
208cec429a runtime-rs: Introduce CoCo-specific enable_annotations
We need to include `cc_init_data` in the enable_annotations
array to pass the data. Since initdata is a CoCo-specific
feature, this commit introduces a new array,
`DEFENABLEANNOTATIONS_COCO`, which contains the required
string and applies it to the relevant CoCo configuration.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2025-08-20 10:15:23 +02:00
Hyounggyu Choi
1f978ecc31 runtime-rs: Fix issues for empty initdata annotation test
Currently, there are 2 issues for the empty initdata annotation
test:

- Empty string handling
- "\[CDH\] \[ERROR\]: Get Resource failed" not appearing

`add_hypervisor_initdata_overrides()` does not handle
an empty string, which might lead to panic like:

```
called `Result::unwrap()` on an `Err` value: gz decoder failed
Caused by:
    failed to fill whole buffer
```

This commit makes the function return an empty string
for a given empty input and updates the assertion string
to one that appears in both go-runtime and runtime-rs.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2025-08-20 10:15:23 +02:00
alex.lyn
0f19465b3a shim-interface: Do cargo check and reduce warnings
Reduce shim-interface's warings caused by non-formatted or unchecked operations.

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-08-20 15:36:09 +08:00
alex.lyn
e05197e81c safe-path: Do cargo check and reduce warnings
Reduce warings caused by non-formatted or unchecked operations.

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-08-20 15:36:09 +08:00
alex.lyn
683d673f4f protocols: Do cargo format to make codes clean
Fix protocols' warings by correctly do cargo check/format.

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-08-20 15:36:09 +08:00
alex.lyn
38242d3a61 kata-types: Do cargo check and reduce warnings
Reduce noises caused by non-formated codes.

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-08-20 15:36:09 +08:00