Files
kata-containers/src/tools/kata-ctl
stevenhorsman 531877f28f deps: Upgrade nix crate from 0.26.4 to 0.31.3
Upgrade the nix crate across the workspace to version 0.30.1 to address
security vulnerabilities and adopt safer file descriptor handling patterns.

### Breaking Changes in nix 0.28.0

1. **File Descriptor Type Changes**
   - Functions now return `OwnedFd` instead of `RawFd` (i32)
   - Functions requiring file descriptors now expect types implementing `AsFd` trait
   - This provides RAII-based automatic cleanup and prevents fd leaks

2. **API Signature Changes**
   - `pipe()`, `pipe2()`, `openpty()` now return `OwnedFd` tuples
   - `socket()` returns `OwnedFd` instead of `RawFd`
   - `open()`, `memfd_create()` return `OwnedFd`
   - `setns()`, `write()`, `fcntl()` require `AsFd` trait
   - `madvise()` requires `NonNull<c_void>` instead of raw pointer
   - `bind()`, `listen()`, `connect()` require `AsFd` and `Backlog` type

3. **Module Feature Flags**
   - Modules now require explicit feature flags (mman, reboot, etc.)

### Additional Breaking Changes in nix 0.30.1

1. **symlinkat() API Change**
   - `dirfd` parameter now requires `AsFd` trait instead of `Option<RawFd>`
   - Use `BorrowedFd::borrow_raw(libc::AT_FDCWD)` for current directory

2. **Type Alias Deprecation**
   - `MemFdCreateFlag` renamed to `MFdFlags` for consistency

### Changes Made

**Workspace Configuration (Cargo.toml)**
- Updated nix to 0.30.1 with features: fs, mount, sched, process, ioctl,
  signal, socket, feature, user, hostname, term, event, mman, reboot

**File Descriptor Handling Patterns**
- Use `BorrowedFd::borrow_raw(raw_fd)` to wrap RawFd for AsFd requirements
- Use `.as_fd().as_raw_fd()` to extract raw fd without ownership transfer
- Use `.into_raw_fd()` only when ownership transfer is needed
- Use `NonNull::new().unwrap()` for madvise pointer conversion

**Deprecated API Replacements**
- `eventfd()` → `EventFd::from_value_and_flags()`
- `Errno::from_i32()` → `Errno::from_raw()`
- `listen(fd, backlog)` → `listen(&fd, Backlog::new(backlog).unwrap())`
- `MemFdCreateFlag` → `MFdFlags`

Generated by: IBM Bob
Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2026-06-19 03:49:16 -07:00
..
2022-10-25 20:34:40 -07:00
2022-10-10 13:42:35 +01:00

Kata Containers control tool

Overview

The kata-ctl tool is a rust rewrite of the kata-runtime utility program.

The program provides a number of utility commands for:

  • Using advanced Kata Containers features.
  • Problem determination and debugging.

Audience and environment

Users and administrators.

Build the tool

$ make

Install the tool

$ make install

If you would like to install the tool to a specific directory, then you can provide it through the INSTALL_PATH variable.

$ make install INSTALL_PATH=/path/to/your/custom/install/directory

Run the tool

$ kata-ctl ...

For example, to determine if your system is capable of running Kata Containers, run:

$ kata-ctl check all

Full details

For a usage statement, run:

$ kata-ctl --help

Cross-builds

For developers that want to build and test the kata-ctl tool on various architectures, the makefile included does have support for that. This would however, require installing the cross compile toolchain for the target architecture on the host along with required libraries.

Cross is an open source tool that offers zero setup cross compile and requires no changes to the system installation for cross-compiling rust binaries. It makes use of docker containers for cross-compilation.

You can install cross with:

cargo install -f cross

cross relies on docker or podman. For dependencies take a look at: https://github.com/cross-rs/cross#dependencies

There is an included cross configuration file Cross.yaml that can be used to compile kata-ctl for various targets. This configuration helps install required dependencies inside a docker container.

For example, to compile for target s390x-unknown-linux-gnu included in Cross.yaml simple run:

cross build --target=s390x-unknown-linux-gnu

You may also need to add the target on your host system prior to the above step as:

rustup target add s390x-unknown-linux-gnu

Documentation for included tools:

| Component | Description | | log-parser | Tool that aid in analyzing logs from the kata runtime. |