Commit Graph

412 Commits

Author SHA1 Message Date
James O. D. Hunt
d7e410ad2b
Merge pull request #8314 from jodh-intel/kata-ctl-show-confidential-guest
kata-runtime/kata-ctl: Add security details to output
2023-10-30 07:41:22 +00:00
HanZiyao
a3b003c345 agent: support bind mounts between containers
This feature supports creating bind mounts directly between containers through annotations.

Fixes: #6715

Signed-off-by: HanZiyao <h56983577@126.com>
2023-10-26 16:34:50 +08:00
James O. D. Hunt
d707fa2c0d kata-runtime/kata-ctl: Add security details to output
Add the hypervisor security details to the output of the `kata-runtime
env` and `kata-ctl env` commands so the user can see, amongst other
things, the value of `confidential_guest`.

Fixes: #8313.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2023-10-25 16:34:42 +01:00
Peng Tao
45e82b6581
Merge pull request #8192 from bergwolf/github/deps
runtime/kata-ctl: update dependencies
2023-10-16 16:39:17 +08:00
alex.lyn
73e81f5e39 runitme-rs: unify base64 encoding for direct-volume
Direct-volume needs to use the same base64 character set as
kata-runtime/direct-volume does.

Fixes: #8175

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-10-11 14:00:13 +08:00
Peng Tao
500d1c5cee kata-ctl: update rustls-webpki/webpki dependency
The old ones have security issues.
ref: https://github.com/briansmith/webpki/issues/69
https://github.com/briansmith/webpki/issues/69

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2023-10-10 03:56:45 +00:00
Chao Wu
6f98fbafde
Merge pull request #6706 from guixiongwei/feat/thp
feat(runtime-rs): introduce huge page mode to select VM RAM's backend
2023-09-22 15:27:06 +08:00
Beraldo Leal
730ef51693 deps: updating dependencies
Updating dependencies after make check, make test.

Signed-off-by: Beraldo Leal <bleal@redhat.com>
2023-09-19 16:54:35 -04:00
Fabiano Fidêncio
2bc3a616ae kata-ctl: Use loop instead of kvm module in tests
This makes it pssible to run the tests in the cost free runners, which
are not KVM capable.

Fixes: #7974 -- part 0

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-09-16 12:53:08 +02:00
Fabiano Fidêncio
46daddc500 kata-ctl: Ensure GENERATED_CODE is a dep of make test
Otherwise `make test` will simply fail with:
```
error[E0583]: file not found for module `version`
```

Fixes: #7974 -- part 0

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-09-16 12:53:01 +02:00
Fabiano Fidêncio
473ec87806 kata-ctl: Add kata-types to the Cargo.lock file
Commit message covered everything. :-)

Fixes: #7974 -- part 0

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-09-16 12:52:40 +02:00
Fabiano Fidêncio
ea19549a99 kata-ctl: Ensure GENERATED_CODE is a dep of make check
Otherwise `make check` would fail with:
```
Error writing files: failed to resolve mod `version`:
/home/runner/work/kata-containers/kata-containers/src/tools/kata-ctl/src/ops/version.rs
does not exist make: *** [../../../utils.mk:176: standard_rust_check] Error 1
```

Fixes: #7974 -- part 0

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-09-16 12:52:36 +02:00
stevenhorsman
a75fd5eb81 runk: Fix rust unecessary mut error
- Fix `error: variable does not need to be mutable`
in rust 1.72

Fixes: #7902
Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2023-09-12 11:31:49 +01:00
stevenhorsman
a31c145172 kata-ctl: useless-vec warning
- Fix clippy::useless-vec warning

Fixes: #7902
Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2023-09-12 11:31:49 +01:00
stevenhorsman
c8419fc3bb kata-ctl: Resolve non-minimal-cfg warning
- In rust 1.72, clippy warned clippy::non-minimal-cfg
as the cfg has only one condition, so doesn't
need to be wrapped in the any combinator.

Fixes: #7902
Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2023-09-12 11:31:49 +01:00
stevenhorsman
3eaf68d954 agent-ctl: Allow clippy lint
- Allow `clippy::redundant-closure-call`
which has issues with the guard function passed into
the `run_if_auto_values` macro

Fixes: #7902
Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2023-09-12 11:31:49 +01:00
Yipeng Yin
a16b0962b5 chore(cargo): update cargo lock
Update cargo lock for runtime-rs, agent and kata-ctl.

Signed-off-by: Yipeng Yin <yinyipeng@bytedance.com>
2023-09-12 15:27:38 +08:00
Manabu Sugimoto
25d151bd1b runk: Modify kill command's error message for containerd tests
The error message when the kill command is executed with the container's
state == Stopped should be "container not running" because the containerd
tests expect that OCI runtimes return the error message and compare it.
If the error message is different from the expected one, the tests fail.

Fixes: #7650

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2023-08-16 00:39:50 +09:00
Yuan-Zhuo
731e7c763f kata-ctl: add monitor subcommand for runtime-rs
The previous kata-monitor in golang could not communicate with runtime-rs
to gather metrics due to different sandbox addresses.
This PR adds the subcommand monitor in kata-ctl to gather metrics from
runtime-rs and monitor itself.

Fixes: #5017

Signed-off-by: Yuan-Zhuo <yuanzhuo0118@outlook.com>
2023-07-28 17:30:08 +08:00
Yuan-Zhuo
d74639d8c6 kata-ctl: provide the global TIMEOUT for creating MgmtClient
Several functions in kata-ctl need to establish a connection with runtime-rs through MgmtClient.
This PR provides a global TIMEOUT to avoid multiple definitions.

Fixes: #5017

Signed-off-by: Yuan-Zhuo <yuanzhuo0118@outlook.com>
2023-07-28 17:23:37 +08:00
Manabu Sugimoto
ff4cfcd8a2 runk: Add Docker guide to README
`runk` can launch containers using Docker, so add the guide
to it's README.

```sh
$ sudo dockerd --experimental --add-runtime="runk=/usr/local/bin/runk"
$ sudo docker run -it --rm --runtime runk busybox echo hello runk
hello runk
```

Fixes: #7431

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2023-07-25 20:10:49 +09:00
Archana Shinde
61e4032b08 kata-ctl: Remove all utility functions to get platform protection
Since these have been added to kata-sys-util, remove these from
kata-ctl. Change all invocations to get platform protection to make use
of kata-sys-util.

Fixes: #7144

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-07-13 20:08:13 +05:30
Archana Shinde
dacdf7c282 kata-ctl: Remove cpu related functions from kata-ctl
Remove cpu related functions which have been moved to kata-sys-util.
Change invocations in kata-ctl to make use of functions now moved to
kata-sys-util.

Signed-off-by: Nathan Whyte <nathanwhyte35@gmail.com>
Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-07-13 20:08:13 +05:30
Archana Shinde
610f7986e4 check: Relax the unrestricted_guest check when running in a VM
When running on a VM, the kernel parameter "unrestricted_guest" for
kernel module "kvm_intel" is not required. So, return success when running
on a VM without checking value of this kernel parameter.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-06-21 07:30:35 -07:00
Archana Shinde
1b406b9d0c kata-ctl:Implement functionality to check host is capable of running VM
Implement functionality to add to the env output if the host is capable
of running a VM.

Fixes: #6727

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-06-21 07:30:22 -07:00
Archana Shinde
56d2ea9b78 kata-ctl: Refactor kernel module check
Adding vhost and vhost-net to the kernel modules. These do not require
any kernel module parameters to be checked. Currently, kernel params is
a required field. Make this as optional. Could make this as <Option>,
but making this a slice instead, as a module could have multiple kernel
params. Refactor the function that checks are for kernel modules into
two with one specifically checking if the module is loaded and other
checking for module parameters.

Refactor some of the tests to take into account these changes.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-06-09 14:10:31 -07:00
James O. D. Hunt
452f286552
Merge pull request #6764 from byron-marohn/fix_5401
kata-ctl: Switch to slog logging; add --log-level and --json-logging arguments
2023-06-07 16:08:53 +01:00
GabyCT
5ad8aaf9df
Merge pull request #7035 from GabyCT/topic/logparserdoc
log-parser: Update log parser link at README
2023-06-06 12:02:25 -06:00
Gabriela Cervantes
980d084f47 log-parser: Update log parser link at README
This PR updates the link to the correspondent Developer Guide at the
enabling full containerd debug that we have for kata 2.0 documentation.

Fixes #7034

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
2023-06-05 15:59:52 +00:00
Yushuo
410bc18143 agent-ctl: fix the compile error
When the version of libc is upgraded to 0.2.145, older getrandom could not adapt
to new API, and this will make agent-ctl fail to compile.

We upgrade the version of `rand`, so the low version of getrandom will no longer
need.

Fixes: #7032

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
2023-06-05 21:48:36 +08:00
Jayant Singh
77519fd120 kata-ctl: Switch to slog logging; add --log-level, --json-logging args
Fixes: #5401, #6654

- Switch kata-ctl from eprintln!()/println!() to structured logging via
  the logging library which uses slog.
- Adds a new create_term_logger() library call which enables printing
  log messages to the terminal via a less verbose / more human readable
  terminal format with colors.
- Adds --log-level argument to select the minimum log level of printed messages.
- Adds --json-logging argument to switch to logging in JSON format.

Co-authored-by: Byron Marohn <byron.marohn@intel.com>
Co-authored-by: Luke Phillips <lucas.phillips@intel.com>
Signed-off-by: Jayant Singh <jayant.singh@intel.com>
Signed-off-by: Byron Marohn <byron.marohn@intel.com>
Signed-off-by: Luke Phillips <lucas.phillips@intel.com>
Signed-off-by: Kelby Madal-Hellmuth <kelby.madal-hellmuth@intel.com>
Signed-off-by: Liz Lawrens <liz.lawrens@intel.com>
2023-06-02 20:13:22 +00:00
alex.lyn
5ddc4f94c5 runtime-rs/kata-ctl: Enhancement of DirectVolumeMount.
Move the get_volume_mount_info to kata-types/src/mount.rs.
If so, it becomes a common method of DirectVolumeMountInfo
and reduces duplicated code.

Fixes: #6701

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-05-26 11:18:29 +08:00
Peng Tao
4cb83dc219 kata-ctl: update tokio dependency
Update to 1.28.1 To pick up the latest fixes.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2023-05-18 08:25:13 +00:00
Peng Tao
df615ff252 runk: update tokio dependency
Update to 1.28.1 to pick up latest fixes.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2023-05-18 08:24:41 +00:00
Narendra Patel
593840e075 kata-ctl: Allow INSTALL_PATH= to be specified
Update the kata-ctl install rule to allow it to be installed to a given directory

The Makefile was updated to use an INSTALL_PATH variable to track where the
kata-ctl binary should be installed.  If the user doesn't specify anything,
then it uses the default path that cargo uses.  Otherwise, it will install it
in the directory that the user specified.  The README.md file was also updated
to show how to use the new option.

Fixes #5403

Co-authored-by: Cesar Tamayo <cesar.tamayo@intel.com>
Co-authored-by: Kevin Mora Jimenez <kevin.mora.jimenez@intel.com>
Co-authored-by: Narendra Patel <narendra.g.patel@intel.com>
Co-authored-by: Ray Karrenbauer <ray.karrenbauer@intel.com>
Co-authored-by: Srinath Duraisamy <srinath.duraisamy@intel.com>
Signed-off-by: Narendra Patel <narendra.g.patel@intel.com>
2023-05-15 17:21:49 -04:00
Amulya Meka
76f975e5e6
Merge pull request #6742 from Amulyam24/agent-build
runtime: remove overriding ARCH value by default for ppc64le
2023-05-12 12:34:50 +05:30
Chelsea Mafrica
5f8008b69c kata-ctl: add unit test for kvm check
Check that kvm test fails when run as non-root and when device specified
is not /dev/kvm.

Fixes #5338

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
2023-05-10 10:29:20 -07:00
Chelsea Mafrica
a085a6d7b4 kata-ctl: add generic kvm check
Add kvm check using ioctl macro to create a syscall that checks the kvm
api version and if creation of a vm is successful.

Fixes #5338

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
2023-05-10 10:29:20 -07:00
Fabiano Fidêncio
6881b9558b
Merge pull request #6512 from gabevenberg/log-parser-rs
Log-parser-rs
2023-05-10 08:22:59 +02:00
Chao Wu
7218229af0
Merge pull request #6594 from Apokleos/warning_fix_1.68.0
warning_fix: fix warnings when build with cargo-1.68.0
2023-05-10 09:51:45 +08:00
Tim Zhang
b0b5d7082e
Merge pull request #6753 from amshinde/add-cross-building-with-cross
cross-compile: Include documentation and configuration for cross-compile
2023-05-09 16:31:40 +08:00
Archana Shinde
8495f830b7 cross-compile: Include documentation and configuration for cross-compile
`cross` is an open source tool that provides zero-setup cross compile
for rust binaries. Add documentation on this tool for compiling
kata-ctl tool and Cross.toml file that provides required configuration
for installing dependencies for various targets.
This is pretty useful for a developer to make sure code compiles and
passes checks for various architectures.

Fixes: #6765

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-05-04 14:13:00 -07:00
Gabe Venberg
6594a9329d tools: made log-parser-rs
Eventual replacement of kata-log-parser, but for now replicates its
functionaility for the new runtime-rs syntax. Takes in log files,
parses, sorts by timestamp, spits them out in json, csv, xml, toml, and
a few others.

Fixes #5350

Signed-off-by: Gabe Venberg <gabevenberg@gmail.com>
2023-05-02 13:16:54 -05:00
Archana Shinde
4064192896 env: Utilize arch specific functionality to get cpu details
Have kata-env call architecture specific function to get cpu details
instead of generic function to get cpu details that works only for
certain architectures. The functionality for cpu details has been fully
implemented for x86_64 and arm architectures, but needs to be
implemented for s390 and powerpc.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-04-27 16:45:41 -07:00
Archana Shinde
fb40c71a21 env: Check for root privileges
Check for root privileges early on.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-04-27 16:45:41 -07:00
Archana Shinde
1016bc17b7 config: Add api to fetch config from default config path
Add api to fetch config from default config path and use that in
kata-ctl tool.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-04-27 16:45:41 -07:00
Archana Shinde
b908a780a0 kata-env: Pass cmd option for file path
Add ability to write the environment information to a file
or stdout if file path is absent.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-04-27 16:45:41 -07:00
Archana Shinde
b1920198be config: Workaround the way agent and hypervisor configs are fetched
This is essentially a workaround for the issue:
https://github.com/kata-containers/kata-containers/issues/5954

runtime-rs chnages the Kata config format adding agent_name and
hypervisor_name which are then used as keys to fetch the agent and
hypervisor configs. This will not work for older configs.
So use the first entry in the hashmaps to fetch the configs as a
workaround while the config change issue is resolved.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-04-27 16:45:41 -07:00
Archana Shinde
f2b2621dec kata-env: Implement the kata-env command.
Command implements functionality to get user environment settings.

Fixes: #5339

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-04-27 16:45:41 -07:00
Amulyam24
defb643346 runtime: remove overriding ARCH value by default for ppc64le
Currently, ARCH value is being set to powerpc64le by default.
powerpc64le is only right in context of rust and any operation
which might use this variable for a different purpose would fail on ppc64le.

Fixes: #6741

Signed-off-by: Amulyam24 <amulmek1@in.ibm.com>
2023-04-27 16:17:48 +05:30
Archana Shinde
f2ebdd81c2 utils: Get rid of spurious print statement left behind.
The print was used for debugging, get ris of it.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-04-26 22:12:30 -07:00
Archana Shinde
9a94f1f149 make: Export VERSION and COMMIT
These will be consumed by kata-ctl, so export these so that
they can be used to replace variables available to the rust binary.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-04-26 22:12:30 -07:00
Archana Shinde
7565b33568 kata-ctl: Implement Display trait for GuestProtection enum
Implement Display for enum to display in env output.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-04-26 22:12:30 -07:00
Archana Shinde
94a00f9346 utils: Make certain constants in utils.rs public
These would be used outside of utils.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-04-26 22:12:30 -07:00
Archana Shinde
376884b8a4 cargo: Update version of clap to 4.1.13
This version includes macros related to using command options.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-04-26 22:12:30 -07:00
alex.lyn
17daeb9dd7 warning_fix: fix warnings when build with cargo-1.68.0
Fixes: #6593

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-04-27 10:29:50 +08:00
David Esparza
7fdaab49bc
Merge pull request #6295 from dborquez/add_kernel_module_checks_kvm
kata-ctl: checks for kvm, kvm_intel modules loaded
2023-04-24 13:33:18 -06:00
David Esparza
432d407440
kata-ctl: checks for kvm, kvm_intel modules loaded
Ensure that kvm and kvm_intel modules are loaded.
Renames the get_cpu_info() function to read_file_contents()

Fixes #5332

Signed-off-by: David Esparza <david.esparza.borquez@intel.com>
2023-04-20 11:29:36 -06:00
Tim Zhang
0a582f7815 trace-forwarder: remove unused crate protobuf
Remove unused crate protobuf.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2023-04-17 19:49:21 +08:00
Tim Zhang
73253850e6 kata-ctl: remove unused crate ttrpc
Remove unused crate ttrpc.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2023-04-17 19:49:21 +08:00
Tim Zhang
76d2e30547 agent-ctl: Bump ttrpc from 0.6.0 to 0.7.1
Fixes: #6646

Signed-off-by: Tim Zhang <tim@hyper.sh>
2023-04-17 19:49:21 +08:00
Archana Shinde
07e49c63e1
Merge pull request #6257 from amshinde/kata-ctl-env
kata-ctl: add function to get platform protection.
2023-03-29 11:55:07 -07:00
Archana Shinde
a914283ce0 kata-ctl: add function to get platform protection.
This function checks for tdx, sev or snp protection on x86
platform.

Fixes: #1000

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-03-28 15:40:25 -07:00
Eduardo Lima (Etrunko)
a8b55bf874 dependency: update cgroups-rs
Huge pages failure with cgroups v2.
https://github.com/kata-containers/cgroups-rs/issues/112

Fixes: #6470

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2023-03-15 12:21:12 -03:00
alex.lyn
b582c0db86 kata-ctl/exec: add new command exec to enter guest VM.
The patchset will help users to easily enter guest VM by debug
console sock.

In order to enter guest VM smoothly, users needs to do some
configuration, options as below:
(1) Set debug_console_enabled = true with default vport 1026.
(2) Or add agent.debug_console agent.debug_console_vport=<PORT>
into kernel_params, and the vport is <PORT> you set.

The detail of usage:
$ kata-ctl exec -h
kata-ctl-exec
Enter into guest VM by debug console

USAGE:
kata-ctl exec [OPTIONS] <SANDBOX_ID>

ARGS:
<SANDBOX_ID> pod sandbox ID

Fixes: #5340

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-02-16 17:05:53 +08:00
Chelsea Mafrica
2f5bc0f408 kata-ctl: Expand unit tests for CPU check
Change unit tests for CPU check to table-driven tests and expand test
cases including temp files for cpuinfo.

Fixes #5919

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
2023-02-10 14:18:44 -08:00
Archana Shinde
94b1d9814c cargo: Update Cargo.lock files
The cargo.locks file under src/libs and agent-ctl seem to be outdated.
Updating these.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-02-08 13:50:54 -08:00
Jianyong Wu
5d37d31ac7 cgroups: upgrade cgroupfs to 0.3.1
Trait method cause for std::error::Error is deprecated thus need replace
it with source method for cgroups-fs::error::ErrorKind.

Fixes: #6192
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2023-02-07 18:09:31 +08:00
Archana Shinde
d3bb254188 utils: Add function to check vhost-vsock
Add function to check if the host-system has the vhost-vsock
kernel module.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-02-03 15:41:59 -08:00
Jianyong Wu
b7dd97cac6 kata-ctl: fix permission deny issue in test_add_remove
test_add_remove and test_get_sandbox_id_for_volume need root user, but
test_drop_privs can temporarily change the user to "nobody" that can
lead to the failure of these tests.

Serialise these three tests can fix it.

Fixes: #6055
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2023-02-03 11:34:39 +08:00
Chelsea Mafrica
fa1f08f5da
Merge pull request #5812 from amshinde/kata-ctl-env-util
Utility functions for kata-env
2023-01-17 18:45:54 -08:00
Bin Liu
42efe013c1
Merge pull request #6078 from utam0k/libcli-0.4.0
runk: Upgrade liboci-cli to v0.0.4
2023-01-17 09:48:09 +08:00
utam0k
095e8fdef4
runk: Use the original Kill command instead of the customed it.
We can remove the custom kill command.

Fixes: #6083

Signed-off-by: utam0k <k0ma@utam0k.jp>
2023-01-16 21:35:47 +09:00
utam0k
0f9e23a3d9
runk: Upgrade liboci-cli to v0.0.4
https://github.com/containers/youki/releases/tag/v0.0.4

Fixes: #6083

Signed-off-by: utam0k <k0ma@utam0k.jp>
2023-01-16 21:35:09 +09:00
Archana Shinde
8d4c2cf1b9 kata-ctl: Allow certain constants to go unused
The generic constants for cpu vendor and model may be superseded
by architecture specific constants. Allow these to be marked as
dead code to ignore warnings on architectures where they are overrided.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-01-15 18:07:35 -08:00
Archana Shinde
64c11a66fd kata-ctl: Have function to get cpu details to run on specific arch
This function relies on get_single_cpu function which has configured
to compile on amd64 and s390x.
Making the function get_generic_cpu_details to compile on these
architectures until we resolve the compilation for functions defined
in check.rs. This is a temporary solution until we cleanup check.rs to
make it build on all architectures.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-01-15 18:07:35 -08:00
Bin Liu
1592a385eb dependency: update cgroups-rs
Update cgroups-rs.

Fixes: #6039

Signed-off-by: Bin Liu <bin@hyper.sh>
2023-01-13 14:00:51 +08:00
Bin Liu
64c9114a39 tools: add --locked option for cargo install
There is a broken release of cgroup-rs, but cargo install will not use
the version in Cargo.lock, so add the `--locked` option to use the version
specified in the Cargo.toml

Fixes: #5376

Signed-off-by: Bin Liu <bin@hyper.sh>
2023-01-11 19:34:46 +08:00
Archana Shinde
594b57d082 utils: Add utility functions to get cpu and distro details.
These functions is meant to be used for the kata-env command.

Fixes: #5688

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-01-09 14:36:36 -08:00
Archana Shinde
d33e343613 check: Move PROC_CPUINFO from architecture specific files
Move PROC_CPUINFO into check.rs. This file is used accross
architectures and does not need to be in arch-specific files.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-01-09 14:31:33 -08:00
Bin Liu
03de5f41b2 kata-ctl: remove get_kata_version_by_url function
In `src/tools/kata-ctl/src/check.rs`, there is a function
`get_kata_version_by_url` in the tests mod,
indeed we can use the `get_kata_all_releases_by_url` in the main mod
to replace it.

Fixes: #5981

Signed-off-by: Bin Liu <bin@hyper.sh>
2023-01-09 15:32:16 +08:00
Fupan Li
2b34f0a54f
Merge pull request #5992 from liubin/fix/5987-kata-ctl-s390x-build-error
kata-ctl: fix build error on s390x
2023-01-09 15:28:37 +08:00
Zhongtao Hu
ec18368aba
Merge pull request #5858 from openanolis/refactor-guest-hook
agent: refactor guest hooks
2023-01-06 22:28:09 +08:00
Bin Liu
c21a8d5ff8 kata-ctl: fix build error on s390x
Some type is not imported in s390x's mod file.

Fixes: #5987

Signed-off-by: Bin Liu <bin@hyper.sh>
2023-01-06 13:27:28 +08:00
Tingzhou Yuan
937a41346e kata-ctl: add unit tests for volume ops
Added table driven unit tests and
funcitionality test for functions in volume_ops.

`join_path` relies on safe_path::scoped_join
to validate the unsafe part of the input.
Testcase also takes into account the possibility of specially
constructed string that would get b64-encoded into path-like string.

Fixes #5341

Signed-off-by: Tingzhou Yuan <tzyuan15@bu.edu>
2023-01-04 01:34:40 -05:00
Tingzhou Yuan
8451db7c0c kata-ctl: direct-volume: add Add and Remove handlers
This commit adds direct-volume command handlers for kata-ctl,
 including add, remove, stats and resize. Stats and resize
makes HTTP over UDS calls to runtime-rs while add and remove
 runs locally on the host.

Fixes #5341

Signed-off-by: Tingzhou Yuan <tzyuan15@bu.edu>

kata-ctl: direct-volume: add Add and Remove handlers

This commit adds direct-volume command handlers for kata-ctl,
 including add, remove, stats and resize. Stats and resize
makes HTTP over UDS calls to runtime-rs while add and remove
 runs locally on the host.

Fixes #5341

Signed-off-by: Tingzhou Yuan <tzyuan15@bu.edu>
2023-01-04 01:34:38 -05:00
Tingzhou Yuan
cae78a6851 kata-ctl: add constants for direct-volume commands
added direct-volume mountinfo struct and constant path strings to kata-types

Fixes #5341

Signed-off-by: Tingzhou Yuan <tzyuan15@bu.edu>
2023-01-04 01:33:51 -05:00
Fabiano Fidêncio
67f0fd505d
Merge pull request #5967 from fidencio/topic/bump-rust-toolchain-to-1.66.0
versions: Update the rust toolchain to 1.66.0
2023-01-03 18:50:16 +01:00
Fabiano Fidêncio
079462d2eb runk: Fix needless_borrow warning
As we bumped the rust toolchain to 1.66.0, some new warnings have been
raised due to needless_borrow.

Let's fix them all here.

For more info about the warnings, please, take a look at:
https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-01-02 17:14:13 +01:00
Yushuo
85f9094f17 agent: refactor guest hooks
We have to execute some hooks both in host and guest. And in
/libs/kata-sys-util/src/hooks.rs, the coomon operations are implemented.

In this commit, we are going to refactor the code of guest hooks using
code in /libs/kata-sys-util/src/hooks.rs. At the same time, we move
function valid_env to kata-sys-util to make it usable by both agent and
runtime.

Fixes: #5857

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
2022-12-26 10:15:19 +08:00
Bin Liu
03a0c9d78e kata-ctl: skip test if access GitHub.com fail
This commit will call `error_for_status` after `send`, this call
will generate errors if status code between 400-499 and 500-599.

And sometime access github.com will fail, in this case we can
skip the test to prevent the CI failing.

Fixes: #5948

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-12-23 15:12:12 +08:00
Bin Liu
1dcbda3f0f kata-ctl: update Cargo.lock
kata-ctl depends on runtime-rs, and this commit:
fbf294da3f

added a new dependency named shim-interface, this Cargo.lock should be updated too.

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-12-23 15:06:50 +08:00
Jianyong Wu
3480780bd8 kata-ctl: add check framework support for non-x86
x86 changes the check framwork. Enable them for non-x86 accordingly.

Fixes: #5923
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2022-12-20 11:41:00 +08:00
Jianyong Wu
1bd533f10b kata-ctl: let check framework arch-agnostic
The current check framwork is specific for x86. Refactor the code
to let it arch-agnostic.

Fixes: #5923
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2022-12-20 11:41:00 +08:00
Alex
b5cfd09583
kata-ctl: Fixed format for check release options
Fixed formatting for check release options

Fixes: #5345

Signed-off-by: Alex <alee23@bu.edu>
Signed-off-by: David Esparza <david.esparza.borquez@intel.com>
2022-12-14 09:42:57 -06:00
James O. D. Hunt
2e15af777c
Merge pull request #5786 from alexlee-23/main
kata-ctl: check: only-list-releases and include-all-releases options
2022-12-14 11:25:36 +00:00
Alex
8dbfc3dc82 kata-ctl: Fixed format for check release options
Fixed formatting for check release options

Fixes: #5345

Signed-off-by: Alex <alee23@bu.edu>
2022-12-13 03:10:19 +00:00
Alex
f3091a9da4 kata-ctl: Add kata-ctl check release options
This pull request adds kata-ctl check only-list-releases and include-all-releases

Fixes: #5345

Signed-off-by: Alex <alee23@bu.edu>
2022-12-13 03:04:30 +00: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
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
Tingzhou Yuan
737420469a kata-ctl: fix dependency version conflict
Also added crate `runtime-rs/crates/runtimes` as dependency as it's
immediately depended upon by the `direct-volume` feature, see issue
5341 and PR 5467.

Fixes #5810

Signed-off-by: Tingzhou Yuan <tzyuan15@bu.edu>
2022-12-01 17:53:21 +00:00
Fabiano Fidêncio
212325a9db
Merge pull request #5649 from ManaSugi/runk/refactor-start-using-agent-code
runk: Re-implement start operation using the agent codes
2022-11-29 20:45:16 +01:00
GabyCT
013752667b
Merge pull request #5776 from liubin/tmp/debug-static-check
ci: let static checks don't depend on build
2022-11-28 07:51:42 -06:00
Bin Liu
6af037d379
Merge pull request #5154 from Yuan-Zhuo/main
agent: support systemd cgroup for kata agent.
2022-11-28 18:40:10 +08:00
Manabu Sugimoto
e12db92e4d runk: Re-implement start operation using the agent codes
This commit re-implements `start` operation by leveraging the agent codes.
Currently, `runk` has own `start` mechanism even if the agent already
has the feature to handle starting a container. This worsen the maintainability
and `runk` cannot keep up with the changes on the agent side easily.
Hence, `runk` replaces own implementations with agent's ones.

Fixes: #5648

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2022-11-28 19:11:21 +09:00
Bin Liu
e723bad0af ci: let static checks don't depend on build
Build is a time consumable operation, skip build while let
ci run faster.

Fixes: #5777

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-11-28 15:26:04 +08:00
Jianyong Wu
a5e4cad4b6 kata-ctl: add host check for aarch64
For now, we can check if host support running kata by check if "/dev/kvm"
exist on aarch64.

Fixes: #5768
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2022-11-25 18:55:32 +08:00
Bin Liu
7c8d474959
Merge pull request #5689 from kata-containers/kata-ctl-util
utils: Add utility function to fetch the kernel version.
2022-11-21 14:44:05 +08:00
Archana Shinde
e80a9f09fa utils: Add utility function to fetch the kernel version.
Add functionality to get kernel version and related unit tests.
This is intended to be used in the kata-env command going forward.

Fixes: #5688

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2022-11-18 15:39:57 -08:00
Fabiano Fidêncio
2f5f575a43 log-parser: Simplify check
```
14:13:15 parse.go:306:5: S1009: should omit nil check; len() for github.com/kata-containers/kata-containers/src/tools/log-parser.kvPairs is defined as zero (gosimple)
14:13:15 	if pairs == nil || len(pairs) == 0 {
14:13:15 	   ^
```

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-11-17 14:17:29 +01:00
Fabiano Fidêncio
d94718fb30 runtime: Fix gofmt issues
It seems that bumping the version of golang and golangci-lint new format
changes are required.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-11-17 14:16:12 +01:00
Fabiano Fidêncio
16b8375095 golang: Stop using io/ioutils
The package has been deprecated as part of 1.16 and the same
functionality is now provided by either the io or the os package.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-11-17 13:43:25 +01:00
Peng Tao
eab8d6be13 build: update golang version to 1.19.2
So that we get the latest language fixes.

There is little use to maitain compiler backward compatibility.
Let's just set the default golang version to the latest 1.19.2.

Fixes: #5494
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-11-16 19:02:39 +01:00
Bin Liu
b0c7bcce7c
Merge pull request #5556 from ManaSugi/runk/fix-kill-behavior
runk: Ignore an error when calling kill cmd with --all option
2022-11-04 08:42:27 +08:00
Manabu Sugimoto
df092185ee runk: Upgrade libseccomp crate to v0.3.0 in Cargo.lock
The libseccomp crate was upgraded to v0.3.0 by 4696ead,
but `Cargo.lock` of runk wasn't updated by mistake.
So, this commit updates `Cargo.lock` of runk to the latest dependencies.

Fixes: #5487

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2022-11-01 20:26:33 +09:00
Manabu Sugimoto
16dca4ecd4 runk: Ignore an error when calling kill cmd with --all option
Ignore an error handling that is triggered when the kill command is called
with `--all option` to the stopped container.

High-level container runtimes such as containerd call the kill command with
`--all` option in order to terminate all processes inside the container
even if the container already is stopped. Hence, a low-level runtime
should allow `kill --all` regardless of the container state like runc.

This commit reverts to the previous behavior.

Fixes: #5555

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2022-11-01 20:24:29 +09:00
David Esparza
37f0cd1c8f
Merge pull request #5436 from amshinde/kata-ctl-drop-privs
Kata ctl drop privs
2022-10-26 11:37:27 -05:00
Archana Shinde
c0f5bc81b7 cargo: Add Cargo.lock to version control
Add Cargo.lock to capture state of build.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2022-10-25 20:34:40 -07:00
Archana Shinde
474927ec90 gitignore: Add gitignore file
Ignore autogeneraated version.rs

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2022-10-25 20:34:40 -07:00
Archana Shinde
699f821e12 utils: Add function to drop priveleges
This function is meant to be used before operations
such as accessing network to make sure those operations
are not performed as a privilged user.

Fixes: #5331

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2022-10-25 20:34:40 -07:00
Yuan-Zhuo
d7bb4b5512 agent: support systemd cgroup for kata agent
1. Implemented a rust module for operating cgroups through systemd with the help of zbus (src/agent/rustjail/src/cgroups/systemd).
2. Add support for optional cgroup configuration through fs and systemd at agent (src/agent/rustjail/src/container.rs).
3. Described the usage and supported properties of the agent systemd cgroup (docs/design/agent-systemd-cgroup.md).

Fixes: #4336

Signed-off-by: Yuan-Zhuo <yuanzhuo0118@outlook.com>
2022-10-25 13:57:09 +08:00
Hendrik Brueckner
e95089b716 kata-ctl: add basic cpu check for s390x
Add a basic s390x cpu check for the "sie" feature to be present.
Also re-enable cpu check testing.

Fixes: #5438

Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
2022-10-21 12:04:28 +00:00
Hendrik Brueckner
871d2cf2c0 kata-ctl: Limit running tests to x86 and use native-tls on s390x
For s390x, use native-tls for reqwest because the rustls-tls/ring
dependency is not available for s390x.

Also exclude s390x, powerpc64le, and aarch64 from running the cpu
check due to the lack of the arch-specific implementation. In this
case, rust complains about unused functions in src/check.rs (both
normal and test context).

Fixes: #5438

Co-authored-by: James O. D. Hunt <james.o.hunt@intel.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
2022-10-21 11:54:26 +00:00
Hendrik Brueckner
9f2c7e47c9 Revert "kata-ctl: Disable network check on s390x"
This reverts commit 00981b3c0a.

Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
2022-10-18 11:12:18 +00:00
James O. D. Hunt
00981b3c0a kata-ctl: Disable network check on s390x
s390x apparently does not support rust-tls, which is required by the
network check (due to the `reqwest` crate dependency).

Disable the network check on s390x until we can find a solution to the
problem.

> **Note:**
>
> This fix is assumed to be a temporary one until we find a solution.
> Hence, I have not moved the network check code (which should be entirely
> generic) into an architecture specific module.

Fixes: #5435.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-10-17 10:24:06 +01:00
James O. D. Hunt
c322d1d12a kata-ctl: arch: Improve check call
Rework the architecture-specific `check()` call by moving all the
conditional logic out of the function.

Fixes: #5402.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-10-15 11:41:53 +01:00
Tingzhou Yuan
70676d4a99 kata-ctl: improve command descriptions for consistency
This change improves the command descriptions for kata-ctl and can avoid certain confusions in command functionality.

Fixes #5411

Signed-off-by: Tingzhou Yuan <tzyuan15@bu.edu>
2022-10-13 04:10:23 +00:00
James O. D. Hunt
00a42f69c0 kata-ctl: cargo: 2021 -> 2018
Revert to the 2018 edition of rust for consistency with other rust
components.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-10-12 11:46:51 +01:00
James O. D. Hunt
fb63274747 kata-ctl: rustfmt + clippy fixes
Make this file conform to the standard rust layout conventions and
simplify the code as recommended by `clippy`.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-10-12 11:46:48 +01:00
James O. D. Hunt
f7010b8061 kata-ctl: docs: Write basic documentation
Provide a basic document explaining a little about the `kata-ctl`
command.

Fixes: #5351.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-10-11 10:04:48 +01:00
James O. D. Hunt
15c343cbf2 kata-ctl: Don't rely on system ssl libs
Build using the rust TLS implementation rather than the system ones.
This resolves the `reqwest` crate build failure: it doesn't appear to
build against the native libssl libraries due to Kata defaulting to
using the musl libc.

Fixes: #5387.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-10-10 13:42:51 +01:00
James O. D. Hunt
c23584994a kata-ctl: clippy: Resolve warnings and reformat
Resolved a couple of clippy warnings and applied standard `rustfmt`.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-10-10 13:42:51 +01:00
David Esparza
133690434c kata-ctl: implement CLI argument --check-version-only
This kata-ctl argument returns the latest stable Kata
release by hitting github.com.
Adds check-version unit tests.

Fixes: #11

Signed-off-by: David Esparza <david.esparza.borquez@intel.com>
2022-10-10 13:42:51 +01:00
David Esparza
eb5423cb7f kata-ctl: switch to use clap derive for CLI handling
Switch from the functional version of `clap` to the declarative
methodology.

Signed-off-by: David Esparza <david.esparza.borquez@intel.com>
Commit-edited-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-10-10 13:42:51 +01:00
Chelsea Mafrica
018aa899cb kata-ctl: Add cpu check
Add architecture-specific code for x86_64 and generic calls handling
checks for CPU flags and attributes.

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
2022-10-10 13:42:50 +01:00
James O. D. Hunt
7c9f9a5a1d kata-ctl: Make arch test run at compile time
Changed the `panic!()` call to a `compile_error!()` one to ensure it
fires at compile time rather than runtime.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-10-10 13:42:50 +01:00
James O. D. Hunt
b63ba66dc3 kata-ctl: Formatting tweaks
Automatic format updates.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-10-10 13:42:50 +01:00
James O. D. Hunt
cca7e32b54 kata-ctl: Lint fixes to allow the branch to be built
Remove return value for branches that call `unimplemented!()`.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-10-10 13:42:50 +01:00
Chelsea Mafrica
8e7bb8521c kata-ctl: add code for framework for arch
Add framework for different architectures for check. In the existing
kata-runtime check, the network checks do not appear to be
architecture-specific while the kernel module, cpu, and kvm checks do
have separate implementations for different architectures.

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
2022-10-10 13:42:50 +01:00
David Esparza
303fc8b118 kata-ctl: Add unit tests cases
Add more unit tests cases to --version argument.

Signed-off-by: David Esparza <david.esparza.borquez@intel.com>
Commit-edited-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-10-10 13:42:43 +01:00
David Esparza
d0b33e9a32 versions: Add kata-ctl version entry
As we're switching to using the rust version of the kata-ctl, lets
provide with its own entry in the kata-ctl command line.

Signed-off-by: David Esparza <david.esparza.borquez@intel.com>
Commit-edited-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-10-10 13:42:35 +01:00
Chelsea Mafrica
002b18054d kata-ctl: Add initial rust code for kata-ctl
Use agent-ctl tool rust code as an example for a skeleton for the new
kata-ctl tool.

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
2022-10-10 10:10:37 +01:00
Gabriela Cervantes
9bd941098e docs: Update urls in runk documentation
This PR updates the urls that we have in the runk documentation.

Fixes #5259

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
2022-09-27 15:45:43 +00:00
Manabu Sugimoto
bcf6bf843c runk: Enable seccomp support by default
Enable seccomp support in `runk` by default.
Due to this, `runk` is built with `gnu libc` by default
because the building `runk` with statically linked the `libseccomp`
and `musl` requires additional configurations.
Also, general container runtimes are built with `gnu libc` as
dynamically linked binaries by default.
The user can disable seccomp by `make SECCOMP=no`.

Fixes: #4896

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2022-09-09 10:55:16 +09:00
Bin Liu
7cfc357c6e
Merge pull request #5034 from ManaSugi/runk/refactor-container-builder
runk: Refactor container builder
2022-09-08 11:30:07 +08:00
James O. D. Hunt
662ce3d6f2
Merge pull request #5086 from Yuan-Zhuo/main
docs: fix unix socket address in agent-ctl doc
2022-09-05 09:24:28 +01:00
Manabu Sugimoto
968c2f6e8e runk: Refactor container builder
Refactor the container builder code (`InitContainer` and `ActivatedContainer`)
to make it easier to understand and to maintain.

The details:

1. Separate the existing `builder.rs` into an `init_builder.rs` and
`activated_builder.rs` to make them easy to read and maintain.

2. Move the `create_linux_container` function from the `builder.rs` to
`container.rs` because it is shared by the both files.

3. Some validation functions such as `validate_spec` from `builder.rs`
to `utils.rs` because they will be also used by other components as
utilities in the future.

Fixes: #5033

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2022-09-05 14:36:30 +09:00
Yuan-Zhuo
5f4f5f2400 docs: fix unix socket address in agent-ctl doc
Following the instructions in guidance doc will result in the ECONNREFUSED,
thus we need to keep the unix socket address in the two commands consistent.

Fixes: #5085

Signed-off-by: Yuan-Zhuo <yuanzhuo0118@outlook.com>
2022-09-02 17:37:44 +08:00
Derek Lee
52bbc3a4b0 cargo.lock: update crates to comply with checks
Updates versions of crossbeam-channel because 0.52.0 is a yanked package
(creators mark version as not for release except as a dependency for
another package)

Updates chrono to use >0.42.0 to avoid:
https://rustsec.org/advisories/RUSTSEC-2020-0159

Updates lz4-sys.

Signed-off-by: Derek Lee <derlee@redhat.com>
2022-08-30 10:08:41 -07:00
Derek Lee
7914da72c9 cargo.tomls: Added Apache 2.0 to cargo.tomls
One of the checks done by cargo-deny is ensuring all crates have a valid
license. As the rust programs import each other, cargo.toml files
without licenses trigger the check. While I could disable this check
this would be bad practice.

This adds an Apache-2.0 license in the Cargo.toml files.

Some of these files already had a header comment saying it is an Apache
license. As the entire project itself is under an Apache-2.0 license, I
assumed all individual components would also be covered under that
license.

Signed-off-by: Derek Lee <derlee@redhat.com>
2022-08-30 09:30:03 -07:00
Archana Shinde
c174eb809e
Merge pull request #4983 from ManaSugi/runk/add-init-msg
runk: Add cli message for init command
2022-08-27 00:15:25 +05:30
Bin Liu
a7e64b1ca9
Merge pull request #4892 from openanolis/shuoyu/runtime-rs
runtime-rs: support loading kernel modules in guest vm
2022-08-25 15:01:23 +08:00
Bin Liu
875d946fb4
Merge pull request #4976 from ManaSugi/runk/refactor-delete-func
runk: Move delete logic to libcontainer
2022-08-25 14:30:30 +08:00
Yushuo
6cf16c4f76 agent-ctl: fix clippy error
Fixes: #4988

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
2022-08-25 11:00:49 +08:00
Manabu Sugimoto
b535bac9c3 runk: Add cli message for init command
Add cli message for init command to tell the user
not to run this command directly.

Fixes: #4367

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2022-08-25 00:32:35 +09:00
Manabu Sugimoto
bdf8a57bdb runk: Move delete logic to libcontainer
Move delete logic to `libcontainer` crate to make the code clean
like other commands.

Fixes: #4975

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2022-08-24 19:12:36 +09:00
Peng Tao
ffd1c1ff4f agent-ctl/trace-forwarder: udpate thread_local dependency
To bring in fix to CWE-362.

Fixes: #4968
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-08-24 17:10:49 +08:00
Peng Tao
69080d76da agent/runk: update regex dependency
To bring in fix to CVE-2022-24713.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-08-24 17:02:15 +08:00
Chen Yiyang
a6fbaac1bd
runk: add pause/resume commands
To make cgroup v1 and v2 works well, I use `cgroups::cgroup` in
`Container` to manager cgroup now. `CgroupManager` in rustjail has some
drawbacks. Frist, methods in Manager traits are not visiable. So we need
to modify rustjail and make them public. Second, CgrupManager.cgroup is
private too, and it can't be serialized. We can't load/save it in
status file. One solution is adding getter/setter in rustjail, then
create `cgroup` and set it when loading status. In order to keep the
modifications to a minimum in rustjail, I use `cgroups::cgroup`
directly. Now it can work on cgroup v1 or v2, since cgroup-rs do this
stuff.

Fixes: #4364 #4821

Signed-off-by: Chen Yiyang <cyyzero@qq.com>
2022-08-22 23:11:50 +08:00
Bin Liu
cb7f9524be
Merge pull request #4804 from openanolis/anolis/merge_runtime_rs_to_main
runtime-rs:merge runtime rs to main
2022-08-11 08:40:41 +08:00
Fabiano Fidêncio
065305f4a1 agent-ctl: Add an empty [workspace]
"An empty [workspace] can be used with a package to conveniently create a
workspace with the package and all of its path dependencies", according
to the https://doc.rust-lang.org/cargo/reference/workspaces.html

This is also matches with the suggestion provided by the Cargo itself,
due to the errors faced with the Cloud Hypervisor CI:
```
10:46:23 this may be fixable by adding `go/src/github.com/kata-containers/kata-containers/src/tools/agent-ctl` to the `workspace.members` array of the manifest located at: /tmp/jenkins/workspace/kata-containers-2-clh-PR/Cargo.toml
10:46:23 Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest.
```

Fixes: #4843

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-08-08 11:24:39 +02:00
Chen Yiyang
230a229052
runk: add ps sub-command
ps command supprot two formats, `json` and `table`. `json` format just
outputs pids in the container. `table` format will use `ps` utilty in
the host, search and output all processes in the container. Add a struct
`container` to represent a spawned container. Move the `kill`
implemention from kill.rs as a method of `container`.

Fixes: #4361

Signed-off-by: Chen Yiyang <cyyzero@qq.com>
2022-08-02 20:45:50 +08:00
Zhongtao Hu
9803393f2f runtime-rs: Merge branch 'main' into runtime-rs-merge-main-1
To keep runtime-rs up to date, we will merge main into runtime-rs every
week.

Fixes: #4790
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-08-02 10:53:01 +08:00
Zhongtao Hu
adfad44efe Merge remote-tracking branch 'origin/main' into runtime-rs-merge-tmp
To keep runtime-rs up to date, we will merge main into runtime-rs every
week.

Fixes:#4776
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-08-01 11:12:48 +08:00
Ryan Savino
9b1940e93e versions: update rust version
Fixes #4764

versions: update rust version to fix ccv0 attestation-agent build error
static-checks: kata tools, libs, and agent fixes

Signed-Off-By: Ryan Savino <ryan.savino@amd.com>
2022-07-29 18:41:43 -05:00
Quanwei Zhou
3d6156f6ec runtime-rs: support dragonball and runtime-binary
Fixes: #3785
Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com>
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-07-14 08:49:30 +08:00
Chen Yiyang
f59939a31f
runk: Support exec sub-command
`exec` will execute a command inside a container which exists and is not
frozon or stopped. *Inside* means that the new process share namespaces
and cgroup with the container init process. Command can be specified by
`--process` parameter to read from a file, or from other parameters such
as arg, env, etc. In order to be compatible with `create`/`run`
commands, I refactor libcontainer. `Container` in builder.rs is divided
into `InitContainer` and `ActivatedContainer`. `InitContainer` is used
for `create`/`run` command. It will load spec from given bundle path.
`ActivatedContainer` is used by `exec` command, and will read the
container's status file, which stores the spec and `CreateOpt` for
creating the rustjail::LinuxContainer. Adapt the spec by replacing the
process with given options and updating the namesapces with some paths
to join the container. I also rename the `ContainerContext` as
`ContainerLauncher`, which is only used to spawn process now. It uses
the `LinuxContaier` in rustjail as the runner. For `create`/`run`, the
`launch` method will create a new container and run the first process.
For `exec`, the `launch` method will spawn a process which joins a
container.

Fixes #4363

Signed-off-by: Chen Yiyang <cyyzero@qq.com>
2022-07-06 21:11:30 +08:00
Chao Wu
86123f49f2 Merge branch 'main' into runtime-rs
In order to keep update with the main, we will update runtime-rs every
week.

Fixes: #4485
Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-06-20 10:01:58 +08:00
James O. D. Hunt
9766a285a4
Merge pull request #4422 from snir911/dependabot_bumps
deps: Resolve dependabot bumps of containerd, crossbeam-utils, regex
2022-06-15 15:57:53 +01:00
Fupan Li
ff7874bc23 protobuf: upgrade the protobuf version to 2.27.0
Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2022-06-11 10:05:52 +08:00
Quanwei Zhou
d2a9bc6674 agent: agent-protocol support async
1. support async.
2. update ttrpc and protobuf
update ttrpc to 0.6.0
update protobuf to 2.23.0
3. support trans from oci

Fixes: #3746
Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com>
2022-06-10 19:36:55 +08:00
Liu Jiang
6f8acb94c2 libs: refine Makefile rules
Refine Makefile rules to better support the KATA ci env.

Fixes: #3536

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-06-10 18:25:24 +08:00
Liu Jiang
392f1ecdf5 libs: convert to a cargo workspace
Convert libs into a Cargo workspace, so all libraries could share the
build infrastructure.

Fixes #3282

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-06-10 18:25:24 +08:00
Bin Liu
ae911d0cd3
Merge pull request #4378 from cmaf/update-containerd-docs-critools
docs: Update source for cri-tools
2022-06-09 15:12:37 +08:00
Bin Liu
05022975c8
Merge pull request #4413 from jodh-intel/tools-full-err-output
tools: Enable extra detail on error
2022-06-09 13:52:08 +08:00
dependabot[bot]
d0ca2fcbbc build(deps): bump crossbeam-utils in /src/tools/trace-forwarder
Bumps [crossbeam-utils](https://github.com/crossbeam-rs/crossbeam) from 0.8.5 to 0.8.8.
- [Release notes](https://github.com/crossbeam-rs/crossbeam/releases)
- [Changelog](https://github.com/crossbeam-rs/crossbeam/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crossbeam-rs/crossbeam/compare/crossbeam-utils-0.8.5...crossbeam-utils-0.8.8)

---
updated-dependencies:
- dependency-name: crossbeam-utils
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-08 10:47:58 +03:00
dependabot[bot]
a60dcff4d8 build(deps): bump regex from 1.5.4 to 1.5.6 in /src/tools/agent-ctl
Bumps [regex](https://github.com/rust-lang/regex) from 1.5.4 to 1.5.6.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.5.4...1.5.6)

---
updated-dependencies:
- dependency-name: regex
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-08 10:47:58 +03:00
dependabot[bot]
dbf50672e1 build(deps): bump crossbeam-utils in /src/tools/agent-ctl
Bumps [crossbeam-utils](https://github.com/crossbeam-rs/crossbeam) from 0.8.5 to 0.8.8.
- [Release notes](https://github.com/crossbeam-rs/crossbeam/releases)
- [Changelog](https://github.com/crossbeam-rs/crossbeam/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crossbeam-rs/crossbeam/compare/crossbeam-utils-0.8.5...crossbeam-utils-0.8.8)

---
updated-dependencies:
- dependency-name: crossbeam-utils
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-08 10:47:58 +03:00
James O. D. Hunt
34bcef8846 docs: Add agent-ctl examples section
Add a new `Examples` section to the `agent-ctl` docs giving some
examples of how to use the tool with QEMU and stand-alone.

Fixes: #4414.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-06-08 08:39:38 +01:00
James O. D. Hunt
815157bf02 docs: Remove erroneous whitespace
Deleted an extra blank line.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-06-08 08:39:38 +01:00
James O. D. Hunt
f5099620f1 tools: Enable extra detail on error
The `agent-ctl` and `trace-forwarder` tools make use of
`anyhow::Context` to provide additional call site information on error.

However, previously neither tool was using the "alternate debug" format
to display the error, meaning full error output was not displayed.

Fixes: #4411.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-06-07 14:00:29 +01:00
Bin Liu
f981190621
Merge pull request #4383 from cyyzero/runk-list
runk: Support `list` sub-command
2022-06-06 10:25:33 +08:00
Chen Yiyang
38a3188206
runk: Support list sub-command
Support list sub-command. It will traverse the root directory, parse
status file and print basic information of containers. Behavior and
print format consistent with runc. To handle race with runk delete
or system user modify, the loop will continue to traverse when errors
are encountered.

Fixes: #4362

Signed-off-by: Chen Yiyang <cyyzero@qq.com>
2022-06-02 18:24:51 +08:00
Peng Tao
295a01f9b1
Merge pull request #4159 from egernst/topic/iptables
feature: add ability to interact with IPTables within the guest
2022-06-02 11:19:41 +08:00
Chelsea Mafrica
7ae11cad67 docs: Update source for cri-tools
Kubernetes-incubator was previously deprecated in favor of
kubernetes-sigs.

Fixes #4377

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
2022-06-01 12:48:48 -07:00
Bin Liu
3e2817f7b5
Merge pull request #4325 from ManaSugi/runk/error-terminal
runk: Return error when tty is used without console socket
2022-06-01 13:58:38 +08:00
Bin Liu
a9a3074828
Merge pull request #4339 from ManaSugi/runk/add-podman-instruction
runk: Add Podman guide in README
2022-06-01 11:05:42 +08:00
Eric Ernst
af2ef3f7a5 agent-ctl: introduce handle for iptables get/set
Add support for the updated agent API for iptables

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2022-05-31 09:27:58 -07:00
Manabu Sugimoto
c7b3941c96 runk: Enable test for the agent built with standard-oci-runtime feature
This enables tests for the kata-agent for runk that is built
with standard-oci-runtime feature in CI.

Fixes: #4351

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2022-05-31 21:54:28 +09:00
Manabu Sugimoto
648b8d0aec runk: Return error when tty is used without console socket
runk always launches containers with detached mode,
so users have to use a console socket with run or
create operation when a terminal is used.
If users set `terminal` to `true` in `config.json` and
try to launch a container without specifying a console
socket, runk returns an error with a message early.

Fixes: #4324

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2022-05-31 09:55:39 +09:00
Manabu Sugimoto
5205efd9b4 runk: Add Podman guide in README
runk can launch containers using Podman, so add the guide
in README.

Fixes: #4338

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2022-05-30 19:06:46 +09:00
Manabu Sugimoto
d862ca0590 runk: Handle rootfs path in config.json properly
This commit enables runk to handle `root.path` in `config.json`
properly even if the path is specified by a relative path that
includes the single (`.`) or the double (`..`) dots.
For example, with a bundle at `/to/bundle` and a rootfs directly
under `/to/bundle` such as `/to/bundle/{bin,dev,etc,home,...}`,
the `root.path` value can be either `/to/bundle` or just `.`.
This behavior conforms to OCI runtime spec.
Accordingly, a bundle path managed by runk's status file
(`status.json`) always is statically stored as a canonical path.
Previously, a bundle path has been got by `oci_state()` of rustjail's
API that returns the path as the parent directory path of a rootfs
(`root.path`). In case of the kata-agent, this works properly because
the kata containers assume that the rootfs path is always
`/to/bundle/rootfs`. However in case of standard OCI runtimes,
a rootfs can be placed anywhere under a bundle, so the rootfs path
doesn't always have to be at a `/to/bundle/rootfs`.

Fixes: #4334

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2022-05-30 14:41:26 +09:00
Tim Zhang
35619b45aa runk: merge oci-kata-agent into runk
Merge two bins into one.

Fixes: #4291

Signed-off-by: Tim Zhang <tim@hyper.sh>
2022-05-23 16:54:09 +08:00
Snir Sheriber
271933fec0 log-parser: fix some of the documentation
minor fixes of links and text

Signed-off-by: Snir Sheriber <ssheribe@redhat.com>
2022-05-10 13:23:25 +03:00
Snir Sheriber
c7dacb1211 log-parser: move the kata-log-parser from the tests repo
to the kata-containers repo under the src/tools/log-parser folder
and vendor the modules

Fixes: #4100
Signed-off-by: Snir Sheriber <ssheribe@redhat.com>
2022-05-10 13:23:25 +03:00
Fupan Li
8aad2c59c5
Merge pull request #4184 from liubin/fix/4182-runk-kill-all
runk: use custom Kill command to support --all option
2022-05-09 17:56:10 +08:00
Bin Liu
97d7b1845b runk: use custom Kill command to support --all option
runk uses liboci-cli crate to parse command line options,
but liboci-cli does not support --all option for kill command,
though this is the runtime spec behavior.

But crictl will issue kill --all command when stopping containers,
as a workaround, we use a custom kill command instead of the one
provided by liboci-cli.

Fixes: #4182

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-04-30 19:34:18 +08:00
Bin Liu
7772f7dd99 runk: set BinaryName for runk for containerd
The default runtime for io.containerd.runc.v2 is runc,
to use runk, the containerd configuration should set the
default runtime to runk or add BinaryName options for the
runtime.

Fixes: #4177

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-04-29 22:26:32 +08:00
James O. D. Hunt
cc839772d3
Merge pull request #2785 from ManaSugi/standard-container-runtime
tools: Add a Rust-based standard OCI container runtime based on Kata agent
2022-04-29 13:20:59 +01:00
James O. D. Hunt
666aee54d2 docs: Add VSOCK localhost example for agent-ctl
Update the `agent-ctl` docs to show how to use a VSOCK local address
when running the agent and the tool in the same environment. This is an
alternative to using a Unix socket.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-04-28 13:33:23 +01:00
James O. D. Hunt
86d348e065 docs: Use VM term in agent-ctl doc
Use the standard "VM" acronym to mean Virtual Machine.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-04-28 13:33:19 +01:00
James O. D. Hunt
4b9b62bb3e agent-ctl: Fix abstract socket connections
Unbreak the `agent-ctl` tool connecting to the agent with a Unix domain
socket.

It appears that [1] changed the behaviour of connecting to the agent
using a local Unix socket (which is not used by Kata under normal
operation).

The change can be seen by reverting to commit
72b8144b56 (the one before [1]) and
running the agent manually as:

```bash
$ sudo KATA_AGENT_SERVER_ADDR=unix:///tmp/foo.socket target/x86_64-unknown-linux-musl/release/kata-agent
```

Before [1], in another terminal we see this:

```bash
$ sudo lsof -U 2>/dev/null |grep foo|awk '{print $9}'
@/tmp/foo.socket@
```

But now, we see the following:

```bash
$ sudo lsof -U 2>/dev/null |grep foo|awk '{print $9}'
@/tmp/foo.socket
```

Note the last byte which represents a nul (`\0`) value.

The `agent-ctl` tool used to add that trailing nul but now it seems to not
be needed, so this change removes it, restoring functionality. No
external changes are necessary so the `agent-ctl` tool can connect to
the agent as below like this:

```bash
$ cargo run -- -l debug connect --server-address "unix://@/tmp/foo.socket" --bundle-dir "$bundle_dir" -c Check -c GetGuestDetails
```

[1] - https://github.com/kata-containers/kata-containers/issues/3124

Fixes: #4164.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-04-28 13:33:09 +01:00
Manabu Sugimoto
b221a2590f tools: Add runk
Add a Rust-based standard OCI container runtime based on
Kata agent.

You can build and install runk as follows:

```sh
$ cd src/tools/runk
$ make
$ sudo make install
$ runk --help
```

Fixes: #2784

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2022-04-28 00:48:57 +09:00
holyfei
0239502781 agent: modify the type of swappiness to u64
The type of MemorySwappiness in runtime is uint64, and the type of swappiness in agent is int64,
if we set max uint64 in runtime and pass it to agent, the value will be equal to -1. We should
modify the type of swappiness to u64

Fixes: #4123

Signed-off-by: holyfei <yangfeiyu20092010@163.com>
2022-04-22 16:55:37 +08:00
shuochen0311
27fb490228 agent: add get volume stats handler in agent
retrieve the stats of direct-assigned volumes from the guest

Fixes: #3454

Signed-off-by: shuochen0311 <shuo.chen@databricks.com>
2022-03-03 18:57:02 -08:00
bin
734b618c16 agent-ctl: run cargo fmt/clippy in make check
Run cargo fmt/clippy in make check and
clear clippy warnings.

Fixes: #3656

Signed-off-by: bin <bin@hyper.sh>
2022-02-14 20:12:57 +08:00
bin
12c37fafc5 trace-forwarder: add make check for Rust
Add make check to run cargo fmt/clippy
for Rust projects.

Fixes: #3656

Signed-off-by: bin <bin@hyper.sh>
2022-02-14 20:12:48 +08:00
Shengjing Zhu
905e124b77 docs: fix agent proto file path
Fixes: #3391

Signed-off-by: Shengjing Zhu <zhsj@debian.org>
2022-01-06 00:22:49 +08:00
Fupan Li
615224e993 agent: move the protocols to upper libs
move the protocols to upper libs thus it can
be shared between agent and other rust runtime.

Depends-on: github.com/kata-containers/tests#4306

Fixes: #3348

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2022-01-05 16:58:06 +08:00
Fupan Li
330e3dcc93 agent: move the oci crate to upper libs
Move the oci crate to upper libs thus it can be
shared between agent and other rust runtimes.

Fixes: #3348

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2022-01-05 16:58:06 +08:00
James O. D. Hunt
b1f4e945b3 security: Update rust crate versions
Update the rust dependencies that have upstream security fixes. Issues
fixed by this change:

- [`RUSTSEC-2020-0002`](https://rustsec.org/advisories/RUSTSEC-2020-0002) (`prost` crate)
- [`RUSTSEC-2020-0036`](https://rustsec.org/advisories/RUSTSEC-2020-0036) (`failure` crate)
- [`RUSTSEC-2021-0073`](https://rustsec.org/advisories/RUSTSEC-2021-0073) (`prost-types` crate)
- [`RUSTSEC-2021-0119`](https://rustsec.org/advisories/RUSTSEC-2021-0119) (`nix` crate)

This change also includes:

- Minor code changes for the new version of `prometheus` for the agent.

- A *downgrade* of the version of the `futures` crate to the (new)
  latest version (`0.3.17`) since version `0.3.18` was removed [1].

Fixes: #3296.

[1] - See https://crates.io/crates/futures/versions

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2021-12-22 07:41:16 +00:00
Peng Tao
7c4263b3e1 src: reorg source directories
To make the code directory structure more clear:

└── src
    ├── agent
    ├── libs
    │   └── logging
    ├── runtime
    ├── runtime-rs (to be added)
    └── tools
        ├── agent-ctl
        └── trace-forwarder

Fixes: #3204
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2021-12-14 10:30:08 +08:00