Commit Graph

16313 Commits

Author SHA1 Message Date
Gao Xiang
b681dfb594 kernel: support CONFIG_TMPFS_XATTR=y
Currently, Kata EROFS support needs it, otherwise it will:
[    0.564610] erofs: (device sda): mounted with root inode @ nid 36.
[    0.564858] overlayfs: failed to set xattr on upper
[    0.564859] overlayfs: ...falling back to index=off,metacopy=off.
[    0.564860] overlayfs: ...falling back to xino=off.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2025-05-24 20:43:35 +08:00
RuoqingHe
a9ffdfc2ae
Merge pull request #11294 from wainersm/delint_confidential_kbs
tests/k8s: delint confidential_kbs.sh
2025-05-23 17:00:28 +02:00
Fupan Li
e9b45126fc
Merge pull request #11254 from sampleyang/main
runtime-rs: fix vfio pci address domain 0001 problem
2025-05-23 18:13:10 +08:00
yangsong
06c7c5bccb runtime-rs: fix vfio pci address domain 0001 problem
Some nvidia gpu pci address domain with 0001,
current runtime default deal with 0000:bdf,
which cause address errors during device initialization
and address conflicts during device registration.

Fixes #11252

Signed-off-by: yangsong <yunya.ys@antgroup.com>
2025-05-23 14:33:06 +08:00
Wainer dos Santos Moschetta
ddf333feaf tests/k8s: fix shellcheck SC1091 in confidential_kbs.sh
Fixed "note: Not following: ./../../../tools/packaging/guest-image/lib_se.sh:
openBinaryFile: does not exist (No such file or directory) [SC1091]"

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
2025-05-22 15:38:27 -03:00
Wainer dos Santos Moschetta
c9fb0b9c85 tests/k8s: fix shellcheck SC2154 in confidential_kbs.sh
Fixed "warning: HKD_PATH is referenced but not assigned. [SC2154]"

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
2025-05-22 15:02:20 -03:00
Wainer dos Santos Moschetta
68d91d759a tests/k8s: add set -e to confidential_ksh.sh
Although the script will inherit that setting from the caller scripts,
expliciting it in the file will vanish shellcheck "warning: Use 'pushd
... || exit' or 'pushd ... || return' in case pushd fails. [SC2164]"

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
2025-05-22 14:55:24 -03:00
Wainer dos Santos Moschetta
b4adfcb3cb tests/k8s: apply shellcheck tips to confidential_kbs.sh
Addressed the following shellcheck advices:

SC2046 (warning): Quote this to prevent word splitting.
SC2248 (style): Prefer double quoting even when variables don't contain special characters
SC2250 (style): Prefer putting braces around variable references even when not strictly required.
SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
2025-05-22 14:52:38 -03:00
alex.lyn
043bab3d3e runtime-rs: Handle port allocation in PCIe topology for vfio devices
It's import to handle port allocation in a PCIe topology before vfio
deivce hotplug via QMP.
The code ensures that VFIO devices are properly allocated to available
ports (either root ports or switch ports) and updates the device's bus
and port information accordingly.
It'll first retrieves the PCIe port type from the topology using
pcie_topo.get_pcie_port(). And then, searches for an available node in
the PCIe topology with RootPort or SwitchPort type and allocates the
VFIO device to the found available port. Finally, Updates the device's
bus with the allocated port's ID and type.

Fixes # 10361

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-22 18:58:41 +08:00
alex.lyn
01b822de16 runtime-rs: Get available port node in the PCIe topology
This commit implements the `find_available_node` function,
which searches the PCIe topology for the first available
`TopologyPortDevice` or `SwitchDownPort`.
If no available node is found in either the `pcie_port_devices`
or the connected switches' downstream ports, the function returns
`None`.

Fixes # 10361

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-22 18:58:41 +08:00
alex.lyn
533d07a2c3 runtime-rs: Introduce qemu-rs vfio device hotplug handler
This commit note that the current implementation restriction where
'multifunction=on' is temporarily unsupported. While the feature
isn't available in the present version, we explicitly acknowledge
this limitation and commit to addressing it in future iterations
to enhance functional completeness.

Tracking issue #11292 has been created to monitor progress towards
full multifunction support.

Fixes #10361

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-22 18:58:06 +08:00
Steve Horsman
91f2e97aae
Merge pull request #11267 from Rtoax/p001-fix-osbuilder-lib.sh-indent
osbuilder: lib.sh: Fix indent
2025-05-22 09:54:18 +01:00
alex.lyn
f1796fe9ba runtime-rs: Add more fields in VfioDevice to express vfio devices
To support port devices for vfio devices, more fields need to be
introduced to help pass port type, bus and other information.

Fixes #10361

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-22 16:00:40 +08:00
Fupan Li
15cbc545ca runtime-rs: fix the issue of delete cgroup failed
When try to delete a cgroup, it's needed to move all of the
tasks/procs in the cgroup into root cgroup and then delete it.

Since for cgroup v2, it doesn't  support to move thread into
root cgroup, thus move the processes instead of moving tasks
can fix this issue.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2025-05-22 12:15:02 +08:00
Steve Horsman
9356ed59d5
Merge pull request #11130 from wainersm/tests-better-report
tests/k8s: better tests reporting for CI
2025-05-21 17:21:35 +01:00
Steve Horsman
b519e9fdff
Merge pull request #11293 from wainersm/tests_increase_kbs_timeout
tests/k8s: increase wait time of KBS service ingress
2025-05-21 17:14:52 +01:00
Steve Horsman
a897bce29f
Merge pull request #11298 from stevenhorsman/release-3.17.0-bump
release: Bump version to 3.17.0
2025-05-21 12:06:24 +01:00
stevenhorsman
7b90ff3c01 release: Bump version to 3.17.0
Bump VERSION and helm-chart versions

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2025-05-21 12:04:39 +01:00
Fabiano Fidêncio
5378e581d8
Merge pull request #11144 from Apokleos/hotplug-block-qemu-rs
Support hot-plug block device in qemu-rs with QMP
2025-05-21 11:31:48 +02:00
Lukáš Doktor
67ee9f3425
ci.ocp: Improve logging of extra new resources
this script relies on temporary subscriptions and won't cleanup any
resources. Let's improve the logging to better describe what resources
were created and how to clean them, if the user needs to do so.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
2025-05-21 11:02:36 +02:00
Lukáš Doktor
32dbc5d2a9
ci.ocp: Use SCRIPT_DIR to allow execution from any folder
We used hardcoded "ci/openshift-ci/cluster" location which expects this
script to be only executed from the root. Let's use SCRIPT_DIR instead
to allow execution from elsewhere eg. by user bisecting a failed CI run.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
2025-05-21 10:30:03 +02:00
Lukáš Doktor
0e4fb62bb4
ci.ocp: Retry first az command as login takes time to propagate
In CI we hit problem where just after `az login` the first `az
network vnet list` command fails due to permission. We see
"insufficient permissions" or "pending permissions", suggesting we should
retry later. Manual tests and successful runs indicate we do have the
permissions, but not immediately after login.

Azure docs suggest using extra `az account set` but still the
propagation might take some time. Add a loop retrying
the first command a few times before declaring failure.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
2025-05-21 10:28:01 +02:00
Fabiano Fidêncio
6c9b199ef1
Merge pull request #11289 from BbolroC/fix-vfio-coldplug
runtime: Preserve hotplug devices for vfio-coldplug mode
2025-05-21 09:48:25 +02:00
Wainer dos Santos Moschetta
fdcf11d090 tests/k8s: increase wait time of KBS service ingress
kbs_k8s_svc_host() returns the ingress IP when the KBS service is
exposed via an ingress. In Azure AKS the ingress can time a while to be
fully ready and recently we have noticed on CI that kbs_k8s_svc_host()
has returned empty value. Maybe the problem is on current timeout being
too low, so let's increase it to 50 seconds to see if the situation
improves.

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
2025-05-20 15:20:08 -03:00
Wainer dos Santos Moschetta
80a816db9d workflows/run-k8s-tests-coco-nontee: add step to report tests
Run `gha-run.sh report-tests` to generate the report of the tests.

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
2025-05-20 14:43:38 -03:00
Wainer dos Santos Moschetta
8c4637d629 tests/k8s: print tests report
Added 'report-tests' command to gha-run.sh to print to stdout a report
of the tests executed.

For example:
```
SUMMARY (2025-02-17-14:43:53):
 Pass:  0
 Fail:  1

STATUSES:
 not_ok foo.bats

OUTPUTS:
::group::foo.bats
1..3
not ok 1 test 1
not ok 2 test 2
ok 3 test 3
1..2
not ok 1 test 1
not ok 2 test 2
::endgroup::
```

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
2025-05-20 14:43:38 -03:00
Wainer dos Santos Moschetta
5e3b8a019a tests/k8s: split and save bats outputs in files
Currently run_kubernetes_tests.sh sends all the bats outputs to stdout
which can be very difficult to browse to find a problem, mainly on
CI. With this change, each bats execution have its output sent to
'reports/yyy-mm-dd-hh:mm:ss/<status>-<bats file>.log' where <status>
is either 'ok' (tests passed) or 'not_ok' (some tests failed).

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
2025-05-20 14:43:38 -03:00
Steve Horsman
f8c5aa6df6
Merge pull request #11259 from fitzthum/bump-gc-0140
Update Trustee and Guest Components for CoCo v0.14.0
2025-05-20 18:05:17 +01:00
Lukáš Doktor
c203d7eba6
ci.ocp: Set peer-pods-azure license
We forgot to add the license header when introducing this test.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
2025-05-20 17:03:48 +02:00
Steve Horsman
b4aa1e3fbd
Merge pull request #11279 from skazi0/repo-components
osbuilder: ubuntu: Add REPO_COMPONENTS setting
2025-05-20 16:03:48 +01:00
Lukáš Doktor
b97b20295b
ci.ocp: Make peer-pods setup executable
set permissions of the peer-pods-azure.sh script to executable

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
2025-05-20 17:03:48 +02:00
Sumedh Alok Sharma
9a4432d197
Merge pull request #11233 from Ankita13-code/ankitapareek/execprocess-additional-input-validation
genpolicy: validate input process fields for ExecProcessRequest
2025-05-20 20:11:41 +05:30
Jacek Tomasiak
91fb4353f6
osbuilder: ubuntu: Add REPO_COMPONENTS setting
Added variable REPO_COMPONENTS (default: "main") which sets components
used by mmdebstrap for rootfs building.
This is useful for custom image builders who want to include EXTRA_PKGS
from components other than the default "main" (e.g. "universe").

Fixes: #11278
Signed-off-by: Jacek Tomasiak <jtomasiak@arista.com>
Signed-off-by: Jacek Tomasiak <jacek.tomasiak@gmail.com>
2025-05-20 14:01:48 +02:00
Fabiano Fidêncio
29099d139b
Merge pull request #11280 from kata-containers/dependabot/cargo/src/tools/kata-ctl/ring-0.17.14
build(deps): bump ring from 0.17.5 to 0.17.14 in /src/tools/kata-ctl
2025-05-20 13:47:22 +02:00
Fabiano Fidêncio
0bc0623037
Merge pull request #11277 from skazi0/repo-url
osbuilder: ubuntu: Expose REPO_URL variables
2025-05-20 13:46:01 +02:00
Ankita Pareek
ad75595dc8 genpolicy: Add tests for various input validations for ExecProcessRequest
These additional tests cover edge cases specific to-
- Terminal validation
- Capabilities validation
- Working directory (Cwd) validation
- NoNewPrivileges validation
- User validation
- Environment variables validation

Signed-off-by: Ankita Pareek <ankitapareek@microsoft.com>
2025-05-20 11:19:55 +00:00
Saul Paredes
1e466bf39c genpolicy: fix validation of env variables sourced from metadata.namespace
Use $(sandbox-namespace) wildcard in case none is specified in yaml. If wildcard is present, compare
input against annotation value.

Fixes regression introduced in https://github.com/microsoft/kata-containers/pull/273
where samples that use metadata.namespace env var were no longer working.

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
2025-05-20 11:19:46 +00:00
Dan Mihai
a113b9eefd genpolicy: validate probe process fields
Validate more process fields for k8s probe commands - e.g.,
livenessProbe, readinessProbe, etc.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-05-20 11:15:30 +00:00
Dan Mihai
c0b8c6ed5e genpolicy: validate process for commands from settings
Validate more process fields for commands enabled using the
ExecProcessRequest "commands" and/or "regex" fields from the
settings file.
Add function to get the container from state based on container_id
matching instead of matching it against every policy container data

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
Signed-off-by: Ankita Pareek <ankitapareek@microsoft.com>
2025-05-20 11:15:30 +00:00
Dan Mihai
6f78aaa411 genpolicy: use process inputs for allow_process()
Using process data inputs for allow_process() is easier to
read/understand compared with the older OCI data inputs.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-05-20 11:15:30 +00:00
Steve Horsman
2871c31162
Merge pull request #11273 from mythi/tdx-qemu-params
config: update QEMU TDX configuration
2025-05-20 10:22:59 +01:00
Steve Horsman
4b317dddfa
Merge pull request #11271 from stevenhorsman/gatekeeper-truncate-names
ci: gatekeeper: Require names update
2025-05-20 10:20:05 +01:00
alex.lyn
4b27ca9233 runtime-rs: Implement volume copy allowlist check
For security reasons, we have restricted directory copying.

Introduces the `is_allowlisted_copy_volume` function to verify
if a given volume path is present in an allowed copy directory.
This enhances security by ensuring only permitted volumes are
copied

Currently, only directories under the path
`/var/lib/kubelet/pods/<uid>/volumes/{kubernetes.io~configmap,
kubernetes.io~secret, kubernetes.io~downward-api,
kubernetes.io~projected}` are allowed to be copied into the
guest. Copying of other directories will be prohibited.

Fixes #11237

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-20 16:57:10 +08:00
alex.lyn
8910bddce8 kata-types: Introduce k8s special volumes for projected and downward-api
Fixes #11237

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-20 16:55:49 +08:00
alex.lyn
6fa409df1a kata-agent: Improve file sync handling and address symlink issues
When synchronizing file changes on the host, a "symlink AlreadyExists"
issue occurs, primarily due to improper handling of symbolic links
(symlinks). Additionally, there are other related problems.

This patch will try to address these problems.
(1) Handle symlink target existence (files, dirs, symlinks) during host file
    sync. Use appropriate removal methods (unlink, remove_file, remove_dir_all).
(2) Enhance temporary file handling for safer operations and implement truncate
    only at offset 0 for resume support.
(3) Set permissions and ownership for parent directories.
(4) Check and clean target path for regular files before rename.

Fixes #11237

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-20 16:55:49 +08:00
alex.lyn
654e6db91f runtime-rs: Add inotify-based real-time directory synchronization
Introduce event-driven file sync mechanism between host and guest when
sharedfs is disabled, which will help monitor the host path in time and
do sync files changes:

1. Introduce FsWatcher to monitor directory changes via inotify;
2. Support recursive watching with configurable filters;
3. Add debounce logic (default 500ms cooldown) to handle burst events;
4. Trigger `copy_dir_recursively` on stable state;
5. Handle CREATE/MODIFY/DELETE/MOVED/CLOSE_WRITE events;

Fixes #11237

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-20 16:55:49 +08:00
alex.lyn
79b832b2f5 runtime-rs: Propagate k8s configs correctly when sharedfs is disabled
In Kubernetes (k8s), while Kata Pods often use virtiofs for injecting
Service Accounts, Secrets, and ConfigMaps, security-sensitive
environments like CoCo disable host-guest sharing. Consequently, when
SharedFs is disabled, we propagate these configurations into the guest
via file copy and bind mount for correct container access.

Fixes #11237

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-20 16:55:49 +08:00
alex.lyn
8da7cd1611 runtime-rs: Impl recursive directory copy with metadata preservation
Add async directory traversal using BFS algorithm:
(1) Support file type handling:
Regular files (S_IFREG) with content streaming;
Directories (S_IFDIR) with mode preservation;
Symbolic links (S_IFLNK) with target recreation;
(2) Maintain POSIX metadata:
UID/GID preservation,File mode bits, and Directory permissions
(3) Implement async I/O operations for:
Directory enumeration, file reading, symlink target resolution

Fixes #11237

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-20 16:55:49 +08:00
alex.lyn
378d04bdf0 runtime-rs: Add hotplug block device type with QMP
There's several cases that block device plays very import roles:

1. Direct Volume:
In Kata cases, to achieve high-performance I/O, raw files on the host
are typically passed directly to the Guest via virtio-blk, and then
bond/mounted within the Guest for container usage.

2. Trusted Storage
In CoCo scenarios, particularly in Guest image pull mode, images are
typically pulled directly from the registry within the Guest. However,
due to constrained memory resources (prioritized for containers), CoCo
leverages externally attached encrypted storage to store images,
requiring hot-plug capability for block devices.

and as other vmms, like dragonball and cloud-hypervisor in runtime-rs or
qemu in kata-runtime have already supported such capabilities, we need
support block device with hot-plug method (QMP) in qemu-rs. Let's do it.

Fixes #11143

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-20 16:46:54 +08:00
alex.lyn
2405301e2e runtime-rs: Support hotplugging block device via QMP
This commit introduces block device hotplugging capability using
QMP commands.
The implementation enables attaching raw block devices to a running
VM through the following steps:

1.Block Device Configuration
Uses `blockdev-add` QMP command to define a raw block backend with
(1) Direct I/O mode
(2) Configurable read-only flag
(3) Host file/block device path (`/path/to/block`)

2.PCI Device Attachment, Attaches the block device via `device_add`
QMP command as a `virtio-blk-pci` device:
(1) Dynamically allocates PCI slots using `find_free_slot()`
(2) Binds to user-specified PCIe bus (e.g., `pcie.1`)
(3) Returns PCI path for further management

Fixes #11143

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-20 16:46:54 +08:00