Commit Graph

4749 Commits

Author SHA1 Message Date
Jeremi Piotrowski
dfa6af54df
Merge pull request #7806 from jongwu/clh_serial
clh:arm64: use arm AMBA UART for hypervisor debug
2023-09-18 12:29:07 +02:00
Greg Kurz
1f16b6627b runtime/qemu: Rework QMP/HMP support
PR #6146 added the possibility to control QEMU with an extra HMP socket
as an aid for debugging. This is great for development or bug chasing
but this raises some concerns in production.

The HMP monitor allows to temper with the VM state in a variety of ways.
This could be intentionally or mistakenly used to inject subtle bugs in
the VM that would be extremely hard if not even impossible to debug. We
definitely don't want that to be enabled by default.

The feature is currently wired to the `enable_debug` setting in the
`[hypervisor.qemu]` section of the configuration file. This setting has
historically been used to control "debug output" and it is used as such
by some downstream users (e.g. Openshift). Forcing people to have the
extra HMP backdoor at the same time is abusive and dangerous.

A new `extra_monitor_socket` is added to `[hypervisor.qemu]` to give
fine control on whether the HMP socket is wanted or not. This setting
is still gated by `enable_debug = true` to make it clear it is for
debug only. The default is to not have the HMP socket though. This
isn't backward compatible with #6416 but it is for the sake of "better
safe than sorry".

An extra monitor socket makes the QEMU instance untrusted. A warning is
thus logged to the journal when one is requested.

While here, also allow the user to choose between HMP and QMP for the
extra monitor socket. Motivation is that QMP offers way more options to
control or introspect the VM than HMP does. Users can also ask for
pretty json formatting well suited for human reading. This will improve
the debugging experience.

This feature is only made visible in the base and GPU configurations
of QEMU for now.

Fixes #7952

Signed-off-by: Greg Kurz <groug@kaod.org>
2023-09-18 12:13:01 +02:00
Fabiano Fidêncio
0e3bfac3b3
Merge pull request #7976 from fidencio/topic/ci-static-checks-rework-part-0
ci: Rework static checks
2023-09-18 11:01:18 +02:00
Peng Tao
6eedd9b0b9
Merge pull request #7738 from Xuanqing-Shi/7732/handle-non-empty-endpoints-in-RemoveEndpoints
runtime: incorrect handling of non-empty []Endpoint parameter in Remo…
2023-09-18 10:58:28 +08:00
Fabiano Fidêncio
08f2e5ae0b runtime-rs: Ensure static-checks-build is a dep of make test
Otherwise `make test` will simply fail with:
```
error[E0583]: file not found for module `config`
```

Fixes: #7974 -- part 0

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-09-16 12:53:13 +02: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
ec826f328f agent: Ensure GENERATED_CODE is a dep of make test
Otherwise `make test` will 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:52:57 +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
Archana Shinde
9c233bb9e0 test: Add test to verify try_from for clh Netconfig
Add tests to verify conversion from runtime NetworkConfig
to clh specific config.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-09-16 00:24:14 -07:00
Archana Shinde
9049d311df runtime-rs: Add network support for cloud-hypervisor
This PR adds support for adding a network device before starting the
cloud-hypervisor VM.

Support for adding and removing network devices is not really added to
the resource manager, so supporting this for cloud-hypervisor is not
scoped in this PR.

This also changes "pending_devices" for clh implementation from an
Option of vector to simply a vector. This simplifies the structure a bit
as we can simple iterate over the pending devices instead of having to
check for a "Some" value as this is not really required.

Fixes: #6333

Signed-off-by: Shuaiyi Zhang <zhang_syi@qq.com>
Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-09-15 23:25:20 -07:00
Jianyong Wu
241c355e07 clh:arm64: use arm AMBA uart for hypervisor debug
cloud hypervisor on arm64 only support arm AMBA UART(pl011) as
tty. So, the console should be set to "ttyAMA0" instead of "ttyS0"
when enable hypervisor debug mode.

Fixes: #5080
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2023-09-15 01:44:23 +00:00
Jeremi Piotrowski
3a1db7a86b runtime: clh: Support enabling iommu
by enabling IOMMU on the default PCI segment. For hotplug to work we need a
virtualized iommu and clh exposes one if there is some device or PCI segment
that requests it. I would have preferred to add a separate PCI segment for
hotplugging vfio devices but unfortunately kata assumes there is only one
segment all over the place. See create_pci_root_bus_path(),
split_vfio_pci_option() and grep for '0000'.

Enabling the IOMMU on the default PCI segment requires passing enabling IOMMU on
every device that is attached to it, which is why it is sprinkled all over the
place.

CLH does not support IOMMU for VirtioFs, so I've added a non IOMMU segment for
that device.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2023-09-14 14:23:28 +02:00
Jeremi Piotrowski
bfc93927fb runtime: Remove redundant check in checkPCIeConfig
There is no way for this branch to be hit, as port is only set when it is
different than config.NoPort.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2023-09-14 14:23:28 +02:00
Jeremi Piotrowski
7c4e73b609 runtime: Add test cases for checkPCIeConfig
These test cases shows which options are valid for CLH/Qemu, and test that we
correctly catch unsupported combinations.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2023-09-14 14:23:28 +02:00
Jeremi Piotrowski
fc51e4b9eb runtime: Check config for supported CLH (cold|hot)_plug_vfio values
The only supported options are hot_plug_vfio=root-port or no-port.
cold_plug_vfio not supported yet.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2023-09-14 14:23:28 +02:00
Jeremi Piotrowski
509771e6f5 runtime: clh: Add hot_plug_vfio entry to config
hot_plug_vfio needs to be set to root-port, otherwise attaching vfio devices to
CLH VMs fails. Either cold_plug_vfio or hot_plug_vfio is required, and we have
not implemented support for cold_plug_vfio in CLH yet.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2023-09-14 14:23:28 +02:00
Peng Tao
55ca7e8aec
Merge pull request #7907 from Xuanqing-Shi/7876/network-devices-naming-conflict
runtime: Naming conflict of network devices
2023-09-13 19:29:41 +08:00
shixuanqing
1636abbe1c runtime: issue with non-empty []Endpoint in RemoveEndpoints
In the RemoveEndpoints(), when the endpoints paramete isn't empty,
using idx may result in wrong endpoint removals. To improve,
directly passing the endpoint parameter helps
locate the correct elements within n.eps.

Fixes: #7732

Signed-off-by: shixuanqing <1356292400@qq.com>

Fixes: #7732

Signed-off-by: shixuanqing <1356292400@qq.com>

Update src/runtime/virtcontainers/network_linux.go

Co-authored-by: Xuewei Niu <justxuewei@apache.org>
2023-09-13 09:47:18 +00:00
Peng Tao
9766f9090c
Merge pull request #7719 from beraldoleal/nullable
Remove gogoproto.nullable extension
2023-09-13 15:11:56 +08:00
James O. D. Hunt
7feb8de9dc
Merge pull request #7887 from jodh-intel/hypervisor-remove-debug-kernel-options
runtime-rs: hypervisor: Remove debug kernel options
2023-09-12 16:31:48 +01: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
stevenhorsman
1d8b78959d runtime-rs: Fix 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
99f3d69e94 runtime-rs: Remove mut
Fix `error: variable does not need to be mutable`

Fixes: #7902
Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2023-09-12 11:31:49 +01:00
stevenhorsman
16fbc27b09 dragonball: Allow ambiguous-glob-reexports
The bindgen generated code is triggering lots of
ambiguous-glob-reexports warnings in rust 1.70+

Fixes: #7902
Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2023-09-12 11:31:49 +01:00
stevenhorsman
bbf1919516 dragonball: 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 all combinators.

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

Fixes: #7902
Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2023-09-12 11:31:49 +01:00
stevenhorsman
f3a0fd5907 agent: config: Fix useles-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
9e423bd3d6 libs: Fix clippy unnecesary hashes error
- Fix error: unnecessary hashes around raw string literal

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
Chao Wu
c800d0739f
Merge pull request #7889 from UiPath/fix-dragonball-build
dragonball: fix for non-deterministic builds
2023-09-12 14:06:18 +08:00
shixuanqing
ca4b6b051d runtime: Naming conflict of network devices
When creating a new endpoint, we check existing endpoint names and automatically adjust the naming of the new endpoint to ensure uniqueness.

Fixes: #7876

Signed-off-by: shixuanqing <1356292400@qq.com>
2023-09-12 04:29:51 +00:00
Guixiong Wei
202049f35e feat(runtime-rs): introduce huge page type to select VM RAM's backend
This commit allows us to specify the huge page backend when enabling huge
page. Currently, we support two backends: thp and hugetlbfs, the default
is hugetlbfs.

To ensure backward compatibility, we introduce another configuration item
"hugepage_type" to select the memory backend, which is available only when
"enable_hugepages" is true. Besides, we add an annotation
"io.katacontainers.config.hypervisor.hugepage_type" to configure huge page
type per pod.

Fixes: #6703

Signed-off-by: Guixiong Wei <weiguixiong@bytedance.com>
Signed-off-by: Yipeng Yin <yinyipeng@bytedance.com>
2023-09-12 11:28:27 +08:00
Zhongtao Hu
e1f54f96d0
Merge pull request #7766 from Apokleos/wrap-vsock-virtiofs
runtime-rs: bring hybrid vsock devices in manager.
2023-09-12 09:27:34 +08:00
Fabiano Fidêncio
d7f991d139
Merge pull request #7151 from Yuan-Zhuo/fix-systemd-cgroup
agent: optimize the code of systemd cgroup manager
2023-09-11 20:15:51 +02:00
James O. D. Hunt
c0f697fcc5 runtime: Allow kernel_params annotation
To support the removal of the `initcall_debug` and `earlyprintk=`
options from the default guest kernel cmdline, add `kernel_params` to the list
of enabled annotations to allow those kernel options (or others) to be
set using `kata-deploy` for either runtime.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2023-09-11 12:12:12 +01:00
Alexandru Matei
b03e49794e dragonball: fix for non-deterministic builds
Fixes: #7888

Signed-off-by: Alexandru Matei <alexandru.matei@uipath.com>
2023-09-11 14:07:10 +03:00
James O. D. Hunt
976d10150c runtime-rs: hypervisor: Remove debug kernel options
Removed the following kernel command line options:

- `earlyprintk=ttyS0`
- `initcall_debug`

Both these options are only useful when debugging a guest kernel failure
which is not a common occurrence.

Further, the `earlyprintk=` option can have a large negative performance
impact (it can increase the VM boot time significantly).

If the user wishes to use either of these options, they can add them to the
`kernel_params=` setting in the Kata configuration file's hypervisor
stanza.

Fixes: #7886.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2023-09-11 09:43:39 +01:00
Fabiano Fidêncio
6cd5d83a37
Merge pull request #7865 from gkurz/fix-more-virtiofs-args
runtime: Fix more virtiofs args
2023-09-09 21:30:16 +02:00
Yuan-Zhuo
470d065415 agent: optimize the code of systemd cgroup manager
1. Directly support CgroupManager::freeze through systemd API.
2. Avoid always passing unit_name by storing it into DBusClient.
3. Realize CgroupManager::destroy more accurately by killing systemd unit rather than stop it.
4. Ignore no such unit error when destroying systemd unit.
5. Update zbus version and corresponding interface file.

Acknowledgement: error handling for no such systemd unit error refers to

Fixes: #7080, #7142, #7143, #7166

Signed-off-by: Yuan-Zhuo <yuanzhuo0118@outlook.com>
Signed-off-by: Yohei Ueda <yohei@jp.ibm.com>
2023-09-09 13:56:43 +08:00
Greg Kurz
72c510d057 runtime/virtiofsd: Drop all references to "--cache=none"
This syntax belongs to the legacy C virtiofsd implementation that
we don't support anymore since kata-containers 3.1.3 because
of other API breaking changes.

People have been warned to switch from "none" to "never" since
kata-containers 2.5.2. Let's officially do that.

The compat code that would convert "none" to "never" isn't
needed anymore. Just drop it.

Fixes #7864

Signed-off-by: Greg Kurz <groug@kaod.org>
2023-09-08 17:57:30 +02:00
Beraldo Leal
ead724bec1 protocol: removing gogo.nullable feature
gogo.nullable is the main gogo.protobuf' feature used here. Since we are
trying to remove gogo.protobuf, the first reasonable step seems to be
remove this feature. This is a core update, and it will change how the
structs are defined. I could spot only a few places using those structs,
based on make check/build.

Fixes #7723.

Signed-off-by: Beraldo Leal <bleal@redhat.com>
2023-09-08 11:49:01 -04:00
Beraldo Leal
d8e4bb9859 protocol: remove unused PROTO_FILE env
There is no reference to PROTO_FILE and this is not working. Also we are
not inside a Makefile, so makes sense to adapt the usage to reflect the
script instead of a make command.

Signed-off-by: Beraldo Leal <bleal@redhat.com>
2023-09-08 11:49:01 -04:00
Beraldo Leal
5e1106a770 protocol: remove unused import_path
import_path is used as the default package when no input files specify
go_package. However, all the files we are currently building already
have a go_package definition, making this behavior both redundant and
error-prone.

Additionally, one of our files (types.pb.go) resides outside the grpc
directory, indicating that it's indeed ignored but also inconsistent.

Signed-off-by: Beraldo Leal <bleal@redhat.com>
2023-09-08 11:49:01 -04:00
Beraldo Leal
87accaaecb protocol: use workdir during build
Currently, the script searches for .proto files within $GOPATH/.
Consequently, modifications to a definition file in the current working
directory won't influence the output .pb.go if the directory is outside
of $GOPATH. For developers, it's more intuitive to alter the local
codebase than the version stored in $GOPATH.

With this modification, the generated .pb.go files will be relative to
the current working directory, removing the need to clone this project
under $GOPATH/src/github.com/kata-containers.

Signed-off-by: Beraldo Leal <bleal@redhat.com>
2023-09-08 11:49:01 -04:00
Beraldo Leal
711a7ed965 protocol: remove mapping definitions
The definitions are already specified in the .proto files using the
go_package option. Centralizing them in one location reduces the
potential for errors and simplifies the script.

Signed-off-by: Beraldo Leal <bleal@redhat.com>
2023-09-08 11:49:01 -04:00
Beraldo Leal
8db84c1bd2 protocol: force GOPATH to be set
Currently, if GOPATH is not set, errors will raise since protoc is using
GOPATH to find packages.

Signed-off-by: Beraldo Leal <bleal@redhat.com>
2023-09-08 11:49:01 -04:00
Beraldo Leal
68156d77ac protocol: breaking lines to improve readability
Just a small change to improve the readability of modules before the
actual changes.

Signed-off-by: Beraldo Leal <bleal@redhat.com>
2023-09-08 11:49:01 -04:00
Chao Wu
cd8c217ee1
Merge pull request #6879 from openanolis/chao/update_upstream_upcall_feature
Dragonball: optimize the placement of dbs-upcall features
2023-09-07 18:07:53 +08:00
Peng Tao
435e890cd9
Merge pull request #7703 from bergwolf/github/nerdctl-fc
runtime: run prestart hooks before starting VM for FC
2023-09-07 10:55:31 +08:00
Chao Wu
deed1b927d Dragonball: optimize the placement of dbs-upcall features
Currently, the dbs-upcall features have 2 problems that are needed to be
fixed :

There are redundant dbs-upcall features that are needed to be removed.
Some place should be controlled by dbs-upcall but not being implemented.

This commit will fix those two problems.

fixes: #6878

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2023-09-07 10:27:29 +08:00
Greg Kurz
81536f21af runtime/qemu: Pass "--xattr" to virtiofsd instead of "-o xattr"
The "-o" syntax belongs to the legacy C virtiofsd. It is deprecated
with the rust implementation.

Signed-off-by: Greg Kurz <groug@kaod.org>
2023-09-06 17:50:35 +02:00
Fabiano Fidêncio
b1dd09a4d3 runtime: Allow virtio_fs_extra_args annotation
Some use cases may just require passing extra arguments to virtiofsd,
and having this disabled by default makes it impossible to set when
using kata-deploy, as changes in the configuration file would be
overwritten by the daemon-set.

With this in mind, let's allow users to pass whatever thet need (and
here I'm specifically looking at `--xattr`) as a virtio_fs_extra_arg.

Fixes: #7853

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-09-06 17:11:16 +02:00
Zhongtao Hu
aa85e0b3ec
Merge pull request #7714 from justxuewei/volumes-cleanup
runtime-rs: Fix volumes and rootfs cleanup issues
2023-09-06 10:13:55 +08:00
alex.lyn
7870b33a2d runtime-rs: bring hybridVsock devices in manager.
Currently, virtio_vsock are still outside of the device
manager. This causes some management issues,such as the
inability to unify PCI address management.

Just do some work for hybrid vsock.

Fixes: #7655

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-09-05 08:46:56 +08:00
Fabiano Fidêncio
27dab249a0
Merge pull request #7800 from jodh-intel/kata-sys-util-update-tdx-protection-checks
kata-sys-util: protection: Update TDX checks
2023-09-02 14:47:51 +02:00
Jiang Liu
57e7bf14a6 agent: refine StorageDeviceGeneric::cleanup()
Refine StorageDeviceGeneric::cleanup() to improve safety.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-09-02 14:22:21 +08:00
Jiang Liu
53edb19374 agent: implement StorageDeviceGeneric::cleanup()
Refactor cleanup_sandbox_storage as StorageDeviceGeneric::cleanup().

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-09-02 14:00:26 +08:00
Jiang Liu
0c63453e28 types: make StorageDevice::cleanup() return possible error code
Make StorageDevice::cleanup() return possible error code.

Fixes: #7818

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-09-02 13:27:06 +08:00
Jiang Liu
3a3d77b3b5 agent: move StorageDeviceGeneric from kata-types into agent
Move StorageDeviceGeneric from kata-types into agent, so we can
refactor code later.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-09-02 13:12:17 +08:00
Jiang Liu
d848126b61
Merge pull request #7821 from jiangliu/storage-leak
agent: avoid possible leakage of storage device
2023-09-02 12:40:40 +08:00
Jiang Liu
9cd706d1c9 agent: avoid possible leakage of storage device
When a storage device is used by more than one container, the second
and forth instances will cause storage device reference count leakage,
thus cause storage device leakage. The reason is:
add_storages() will increase reference count of existing storage device,
but forget to add the device to the `mount_list` array, thus leak the
reference count.

Fixes: #7820

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-09-01 22:52:42 +08:00
Dan Mihai
bf21411e90 tests: add policy to k8s tests
Use AGENT_POLICY=yes when building the Guest images, and add a
permissive test policy to the k8s tests for:
- CBL-Mariner
- SEV
- SNP
- TDX

Also, add an example of policy rejecting ExecProcessRequest.

Fixes: #7667

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2023-09-01 14:28:08 +00:00
Dan Mihai
d0e0610679 runtime: config: use the SEV initrd for SNP
Thanks Unmesh Deodhar!

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2023-09-01 14:28:08 +00:00
Fabiano Fidêncio
67fed26f18 runtime: Use TDX image with in the qemu-tdx config
Let's make sure we use the TDX image as part of the QEMU TDX
configuration, which will help us to have the policies tested here.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-09-01 14:28:08 +00:00
Jeremi Piotrowski
bde06758b1
Merge pull request #7761 from jepio/iocopy-fix-race
runtime: Fix data race in ioCopy
2023-09-01 09:30:54 +02:00
James O. D. Hunt
c290eaed8c kata-sys-util: protection: Update TDX checks
Update the protection checking code to detect newer versions of Intel
TDX (whose userland interface has now stabilised).

> **Note:** that we don't need to retain the existing behaviour since:
>
> - We haven't yet landed the TDX feature (#6448).
> - Systems wishing to use TDX will need to use the latest available
>   system components (such as firmware and host kernel).

Also added an explicit TDX unit test.

Fixes: #7384.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2023-08-31 16:15:15 +01:00
Jeremi Piotrowski
c2ba29c15b runtime: Fix data race in ioCopy
IoCopy is a tricky function (I don't claim to fully understand its contract),
but here is what I see: The goroutine that runs it spawns 3 goroutines - one
for each stream to handle (stdin/stdout/stderr). The goroutine then waits for
the stream goroutines to exit. The idea is that when the process exits and is
closed, the stdout goroutine will be unblocked and close stdin - this should
unblock the stdin goroutine. The stderr goroutine will exit at the same time as
the stdout goroutine. The iocopy routine then closes all tty.io streams.

The problem is that the stdout goroutine decrements the WaitGroup before
closing the stdin stream, which causes the iocopy goroutine to race to close
the streams. Move the wg.Done() of the stdout routine past the close so that
*this* race becomes impossible. I can't guarantee that this doesn't affect some
unspecified behavior.

Fixes: #5031
Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2023-08-31 10:17:38 +02:00
Peng Tao
2e4c874726 runtime/vc: runPrestartHooks should ignore GetHypervisorPid failure
If we are running FC hypervisor, it is not started when prestart hooks
are executed. So we should just ignore such error and just go ahead and
run the hooks.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2023-08-30 03:06:11 +00:00
Peng Tao
21204caf20 runtime: fail early when starting docker container with FC
FC does not support network device hotplug. Let's add a check to fail
early when starting containers created by docker.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2023-08-30 02:52:01 +00:00
Peng Tao
32fd013716 runtime: run prestart hooks before starting VM for FC
Add a new hypervisor capability to tell if it supports device hotplug.
If not, we should run prestart hooks before starting new VMs as nerdctl
is using the prestart hooks to set up netns. To make nerdctl + FC
to work, we need to run the prestart hooks before starting new VMs.

Fixes: #6384
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2023-08-30 02:52:01 +00:00
Beraldo Leal
00e7ffd988 tests: check vmx only on Intel machines
When running on amd machines, those tests will fail because there is no
vmx flag. Following other tests that checks for cpuType, let's adapt
them to restrict vmx only on Intel machines.

Fixes #7788.
Related #5066

Signed-off-by: Beraldo Leal <bleal@redhat.com>
2023-08-29 20:04:31 -04:00
Beraldo Leal
80146f2078 tests: Fixes cpuType check on AMD machines
cpuType is not initialized yet. gets 0 (Intel) by default, failing on
AMD machines.

Fixes #7785

Signed-off-by: Beraldo Leal <bleal@redhat.com>
2023-08-29 17:04:07 -04:00
Chao Wu
e4fb20c74a
Merge pull request #7585 from lifupan/main
dragonball: vsock add fifo/pipe stream support for passed fd hybridSt…
2023-08-29 23:39:21 +08:00
Fabiano Fidêncio
d1b54ede29 qemu: tdx: Workaround SMP issue with TDX 1.5
`...,sockets=1,cores=numvcpus,threads=1,...` must be used.

Fixes: #7770

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-08-28 13:41:36 +02:00
Archana Shinde
1e34220c41 qemu: tdx: Adapt to the TDX 1.5 stack
QEMU for TDX 1.5 makes use of private memory map/unmap.
Make changes to govmm to support this. Support for private backing fd
for memory is added as knob to the qemu config.

Userspace's map/unmap operations are done by fallocate() ioctl on the
backing store fd.
Reference:
https://lore.kernel.org/linux-mm/20220519153713.819591-1-chao.p.peng@linux.intel.com/

Fixes: #7770

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-08-28 13:41:36 +02:00
Zhongtao Hu
f0440a9cfe
Merge pull request #7742 from frezcirno/fix-log-forwarder-loop
runtime-rs: check peer close in log_forwarder
2023-08-26 10:44:09 +08:00
Jiang Liu
91db888d83
Merge pull request #7602 from jiangliu/agent-storage
Refine storage device management for kata-agent
2023-08-25 22:20:18 +08:00
Zixuan Tan
dffc16e5b3 runtime-rs: check peer close in log_forwarder
The log_forwarder task does not check if the peer has closed, causing a
meaningless loop during the period of “kata vm exit”, when the peer
closed, and “ShutdownContainer RPC received” that aborts the log forwarder.

This patch fixes the problem.

Fixes: #7741

Signed-off-by: Zixuan Tan <tanzixuan.me@gmail.com>
2023-08-25 19:00:07 +08:00
Jiang Liu
aaa5ab1264 agent: simplify storage device by removing StorageDeviceObject
Simplify storage device implementation by removing StorageDeviceObject.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-25 17:23:16 +08:00
Greg Kurz
9991772b26
Merge pull request #7718 from littlejawa/fix_filemode_when_zero
kata-agent: use default filemode for block device when it is set to 0
2023-08-24 11:40:28 +02:00
Jiang Liu
0e7248264d agent: move storage device related code into dedicated files
Move storage device related code into dedicated files.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-24 13:48:51 +08:00
Xuewei Niu
268e846558 runtime-rs: Fix volumes and rootfs cleanup issues
There are several processes for container exit:

- Non-detach mode: `Wait` request is sent by containerd, then
  `wait_process()` will be called eventually.
- Detach mode: `Wait` request is not sent, the `wait_process()` won’t be
  called.
    - Killed by ctr: For example, a container runs `tail -f /dev/null`, and
      is killed by `sudo ctr t kill -a -s SIGTERM <CID>`. Kill request is
      sent, then `kill_process()` will be called. User executes `sudo ctr c
      rm <CID>`, `Delete` request is sent, then `delete_process()` will be
      called.
    - Exited on its own: For example, a container runs `sleep 1s`. The
      container’s state goes to `Stopped` after 1 second. User executes
      the delete command as below.

Where do we do container cleanup things?

- `wait_process()`: No, because it won’t be called in detach mode.
- `delete_process()`: No, because it depends on when the user executes the
  delete command.
- `run_io_wait()`: Yes. A container is considered exited once its IO ended.
  And this always be called once a container is launched.

Fixes: #7713

Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2023-08-24 13:23:47 +08:00
Jiang Liu
8f49ee33b2 agent: refine storage related code a bit
Refine storage related code by:
- remove the STORAGE_HANDLER_LIST
- define type alias
- move code near to its caller

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-24 13:09:10 +08:00
Jiang Liu
60ca12ccb0 agent: switch to new storage subsystem
Switch to new storage subsystem to create a StorageDevice for each
storage object.

Fixes: #7614

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-24 13:09:09 +08:00
Jiang Liu
fcbda0b419 kata-types: introduce StorageDevice and StorageHandlerManager
Introduce StorageDevice and StorageHandlerManager, which will be used
to refine storage device management for kata-agent.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-24 13:08:55 +08:00
Jiang Liu
b03b1f6134 agent: simplify the way to manage storage object
Simplify the way to manage storage objects, and introduce
StorageStateCommon structures for coming extensions.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-24 12:58:24 +08:00
Jiang Liu
8392c71bf2 sys-util: support more mount flags in parse_mount_options()
Support more mount flags in parse_mount_options().

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-24 12:17:39 +08:00
Jiang Liu
c00d8f3d48 agent: use create_mount_destination() from kata-sys-util
Use create_mount_destination() from kata-sys-util crate to reduce
redundant code.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-24 12:17:38 +08:00
Jiang Liu
5e867f0538 types: add more mount related constants
Add more mount related constants.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-24 12:17:36 +08:00
Jiang Liu
880e6c9a76 agent: use function from kata-sys-utils to reduce code
Use function get_linux_mount_info() from kata-sys-util crate to share
common code.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-24 12:17:34 +08:00
QuanweiZhou
a6921dd837
Merge pull request #7698 from jiangliu/virtual-volume
kata-types: introduce KataVirtualVolume to support nydus, direct volume and image pull
2023-08-24 11:50:39 +08:00
Fabiano Fidêncio
7705c5962e
Merge pull request #7728 from ManaSugi/fix/typo-test-toml
libs,tests: fix typo disable_guest_seccomp in configuration-anno-1.toml
2023-08-23 23:55:41 +02:00
Peng Tao
18d42da21e runtime/fc: fix image/initrd annotation handling
Right now if we configure an image annotation and have a config file
setting initrd, the initrd config would override the image annotation.

Make sure annotations are preferred over config options in image and initrd
path handling.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2023-08-23 03:47:28 +00:00
Peng Tao
9fda7059a5 runtime/clh: fix image/initrd annotation handling
We should make sure annotations are preferred over
config options in image and initrd path handling.

Fixes: #7705
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2023-08-23 03:47:28 +00:00
Peng Tao
1a0092d631 runtime/qemu: fix image/initrd annotation handling
Right now if we configure an image annotation and have a config file
setting initrd, the initrd config would override the image annotation.

Add a helper function ImageOrInitrdAssetPath to make sure annotations
are preferred over config options in image and initrd path handling.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2023-08-23 03:47:27 +00:00
Manabu Sugimoto
22d8f335d6 libs,tests: fix typo disable_guest_seccomp in configuration-anno-1.toml
Change `pdisable_guest_seccomp` to `disable_guest_seccomp`

Fixes: #7727

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2023-08-23 12:08:18 +09:00
Julien Ropé
40914b25d4 kata-agent: use default filemode for block device when it is set to 0
When the FileMode field for the device is unset (0), use a default value instead
to allow the use of the device from the container.
This behaviour is seen from cri-o typically.

Note: this is what runc is doing, which is why regular containers don't have an
issue. This change makes sure kata behaves the same as runc.

Fixes: #7717

Signed-off-by: Julien Ropé <jrope@redhat.com>
2023-08-22 16:08:14 +02:00
Jiang Liu
4aee3eade0 kata-types: implement serde methods for KataVirtualVolume
Implement serilization/deserialization methods for KataVirtualVolume.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-21 16:46:56 +08:00
Jiang Liu
b875e39323 kata-types: validate KataVirtualVolume object
Implement method validate() for KataVirtualVolume to validate message
format.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-21 16:42:07 +08:00
Jiang Liu
fa2fdc1057 kata-types: implement two conversion helpers for KataVirtualVolume
Enable conversions from NydusExtraOptions/DirectVolumeMountInfo to
KataVirtualVolume.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-21 16:35:26 +08:00
Jiang Liu
6326af20e3 kata-types: introduce KataVirtualVolume
Introduce structure KataVirtualVolume to to encapsulate information
for extra mount options and direct volumes, so we could build a common
infrastructure to handle these cases.

Fixes: #7699

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-21 16:19:47 +08:00
Dan Mihai
cb056f8cb3 rootfs: agent: Policy support with AGENT_INIT=yes
When building with AGENT_POLICY=yes and AGENT_INIT=yes:
1. Include OPA and the Policy settings in rootfs.
2. Start OPA from the kata agent.

Before these changes, building with both AGENT_POLICY=yes and
AGENT_INIT=yes was unsupported.

Starting OPA from systemd (when AGENT_INIT=no) was already supported.

Fixes: #7615

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2023-08-17 22:37:58 +00:00
Wedson Almeida Filho
962378606e
Merge pull request #7627 from wedsonaf/error-conv
agent: simplify error handling
2023-08-16 21:02:38 -03:00
Fabiano Fidêncio
4adcf2192e
Merge pull request #7651 from ManaSugi/runk/containerd-test
runk: Modify kill command's error message for containerd tests
2023-08-16 15:37:48 +02:00
Zhongtao Hu
d90f7ac689 runtime-rs: add unit test for block driver
add unit test for block driver

Fixes:#7539
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2023-08-16 11:45:27 +08:00
Zhongtao Hu
e44919f0da runtime-rs: add load_test_config for unit test
add load_test_config for unit test

Fixes:#7539
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2023-08-16 11:32:56 +08:00
Zhongtao Hu
7f48a69379 runtime-rs: add driver option
add driver option when handle linux devices

Fixes:#7539
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2023-08-16 11:32:49 +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
Wedson Almeida Filho
76dac8f22c agent: simplify error handling
We extend the `Result` and `Option` types with associated types that
allows converting a `Result<T, E>` and `Option<T>` into
`ttrpc::Result<T>`.

This allows the elimination of many `match` statements in favor of
calling the map function plus the `?` operator. This transformation
simplifies the code.

Fixes: #7624

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
2023-08-15 06:55:27 -03:00
Fabiano Fidêncio
e107d1d94e
Merge pull request #7574 from microsoft/danmihai1/policy
agent: runtime: add Agent Policy feature
2023-08-15 11:29:13 +02:00
Bin Liu
ea81eb6c2e
Merge pull request #7169 from chethanah/runk/support-no-pid-ns
runk: Support without pid ns
2023-08-15 13:00:40 +08:00
Chelsea Mafrica
22465d22f0
Merge pull request #7638 from ManaSugi/fix/virtcontainers-doc
docs: Remove installation step in virtcontainers doc
2023-08-14 10:21:57 -07:00
Dan Mihai
ab829d1038 agent: runtime: add the Agent Policy feature
Fixes: #7573

To enable this feature, build your rootfs using AGENT_POLICY=yes. The
default is AGENT_POLICY=no.

Building rootfs using AGENT_POLICY=yes has the following effects:

1. The kata-opa service gets included in the Guest image.

2. The agent gets built using AGENT_POLICY=yes.

After this patch, the shim calls SetPolicy if and only if a Policy
annotation is attached to the sandbox/pod. When creating a sandbox/pod
that doesn't have an attached Policy annotation:

1. If the agent was built using AGENT_POLICY=yes, the new sandbox uses
   the default agent settings, that might include a default Policy too.

2. If the agent was built using AGENT_POLICY=no, the new sandbox is
   executed the same way as before this patch.

Any SetPolicy calls from the shim to the agent fail if the agent was
built using AGENT_POLICY=no.

If the agent was built using AGENT_POLICY=yes:

1. The agent reads the contents of a default policy file during sandbox
   start-up.

2. The agent then connects to the OPA service on localhost and sends
   the default policy to OPA.

3. If the shim calls SetPolicy:

   a. The agent checks if SetPolicy is allowed by the current
      policy (the current policy is typically the default policy
      mentioned above).

   b. If SetPolicy is allowed, the agent deletes the current policy
      from OPA and replaces it with the new policy it received from
      the shim.

   A typical new policy from the shim doesn't allow any future SetPolicy
   calls.

4. For every agent rpc API call, the agent asks OPA if that call
   should be allowed. OPA allows or not a call based on the current
   policy, the name of the agent API, and the API call's inputs. The
   agent rejects any calls that are rejected by OPA.

When building using AGENT_POLICY_DEBUG=yes, additional Policy logging
gets enabled in the agent. In particular, information about the inputs
for agent rpc API calls is logged in /tmp/policy.txt, on the Guest VM.
These inputs can be useful for investigating API calls that might have
been rejected by the Policy. Examples:

1. Load a failing policy file test1.rego on a different machine:

opa run --server --addr 127.0.0.1:8181 test1.rego

2. Collect the API inputs from Guest's /tmp/policy.txt and test on the
   machine where the failing policy has been loaded:

curl -X POST http://localhost:8181/v1/data/agent_policy/CreateContainerRequest \
--data-binary @test1-inputs.json

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2023-08-14 17:07:35 +00:00
Manabu Sugimoto
416445e7eb docs: Remove installation step in virtcontainers doc
Remove the installation step in the virtcontainers doc
because the virtcontainers install/uninstall targets have
been removed by 86723b51ae
and they are not used anymore.

Fixes: #7637

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2023-08-14 15:15:24 +09:00
stevenhorsman
8815ed0665 runtime: Remove config warnings
Remove configuration file shared_fs = none warnings
now that there is a solution to updating configMaps, secrets etc

Fixes: #7210
Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2023-08-11 16:31:08 +01:00
Yohei Ueda
afe1a6ac5a agent: support copying of directories and symlinks
This patch allows copying of directories and symlinks when
static file copying is used between host and guest. This change is
necessary to support recursive file copying between shim and agent.

Signed-off-by: Yohei Ueda <yohei@jp.ibm.com>
(cherry picked from commit de232b8030)
2023-08-11 16:31:08 +01:00
Pradipta Banerjee
ab13ef87ee runtime: propagate configmap/secrets etc changes for remote-hyp
For remote hypervisor, the configmap, secrets, downward-api or project-volumes are
copied from host to guest. This patch watches for changes to the host files
and copies the changes to the guest.

Note that configmap updates takes significantly longer than updates via downward-api.
This is similar across runc and Kata runtimes.

Fixes: #7210

Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
Signed-off-by: Julien Ropé <jrope@redhat.com>
(cherry picked from commit 3081cd5f8e)
(cherry picked from commit 68ec673bc4d9cd853eee51b21a0e91fcec149aad)
2023-08-11 16:31:08 +01:00
Yohei Ueda
c074ec4df1 runtime: Copy shared files recursively
This patch enables recursive file copying
when filesystem sharing is not used.

Signed-off-by: Yohei Ueda <yohei@jp.ibm.com>
Co-authored-by: stevenhorsman <steven@uk.ibm.com>
(cherry picked from commit 5422a056f2)
(cherry picked from commit 16055ce040bbd724be2916bc518d89b69c9e0ca5)

Fixes: #7210
2023-08-11 16:16:52 +01:00
Peng Tao
a39fd6c066
Merge pull request #7611 from ManaSugi/fix/fc-version
versions: Update firecracker version to 1.4.0
2023-08-11 16:43:37 +08:00
Chao Wu
7031b5db07
Merge pull request #7535 from ManaSugi/fix/allow-redundant-clone
agent: Allow clippy::redundant_clone in the unit tests
2023-08-11 14:17:56 +08:00
Manabu Sugimoto
cc922be5ec versions: Update firecracker version to 1.4.0
This patch upgrades Firecracker version from v1.1.0 to v1.4.0.

* Generate swagger models for v1.4.0 (from `firecracker.yaml`)
  - The version of go-swagger used is v0.30.0
* The firecracker v1.4.0 includes the following changes.
  - Added
    * Added support for custom CPU templates allowing users to adjust vCPU features
    exposed to the guest via CPUID, MSRs and ARM registers.
    * Introduced V1N1 static CPU template for ARM to represent Neoverse V1 CPU
    as Neoverse N1.
    * Added support for the virtio-rng entropy device. The device is optional. A
    single device can be enabled per VM using the /entropy endpoint.
    * Added a cpu-template-helper tool for assisting with creating and managing
    custom CPU templates.
  - Changed
    * Set FDP_EXCPTN_ONLY bit (CPUID.7h.0:EBX[6]) and ZERO_FCS_FDS bit
    (CPUID.7h.0:EBX[13]) in Intel's CPUID normalization process.
  - Fixed
    * Fixed feature flags in T2S CPU template on Intel Ice Lake.
    * Fixed CPUID leaf 0xb to be exposed to guests running on AMD host.
    * Fixed a performance regression in the jailer logic for closing open file
    descriptors.
    * A race condition that has been identified between the API thread and the VMM
    thread due to a misconfiguration of the api_event_fd.
    * Fixed CPUID leaf 0x1 to disable perfmon and debug feature on x86 host.
    * Fixed passing through cache information from host in CPUID leaf 0x80000006.
    * Fixed the T2S CPU template to set the RRSBA bit of the IA32_ARCH_CAPABILITIES
    MSR to 1 in accordance with an Intel microcode update.
    * Fixed the T2CL CPU template to pass through the RSBA and RRSBA bits of the
    IA32_ARCH_CAPABILITIES MSR from the host in accordance with an Intel microcode
    update.
    * Fixed passing through cache information from host in CPUID leaf 0x80000005.
    * Fixed the T2A CPU template to disable SVM (nested virtualization).
    * Fixed the T2A CPU template to set EferLmsleUnsupported bit
    (CPUID.80000008h:EBX[20]), which indicates that EFER[LMSLE] is not supported.

Fixes: #7610

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2023-08-10 16:48:13 +09:00
Fupan Li
39e67b06e9 dragonball: vsock add fifo/pipe stream support for passed fd hybridStream
Since the passed fd through unix socket would be any
stream fd such as pipe/fifo fd or any other socket
fd, thus we should deal with it as a normal hybrid
stream instead of a unix stream.

Fixes:#7584

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2023-08-10 11:07:10 +08:00
Wedson Almeida Filho
729b2dd611 agent: avoid creating new Vec instances when easily avoidable
There are many places where the code currently creates new `Vec`
instances when it's not really needed. The result is a perf hit because
it allocates memory, copies all elements, then frees the memory; in some
cases, copying elements also involves extra allocations (e.g., when
elements are strings, or structs containing strings).

This patch addresses a number of these cases.

Fixes: #7203

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
2023-08-09 02:38:36 -03:00
Jiang Liu
baabfa9f1f agent: refine implementation of mount related code
Refine implementation of mount by:
- log message with `path.display()` instead of `{:?}`
- add prefix "_" to unused variables
- pass by reference instead of by value to avoid creating redundant
  array
- exactly matching prefix "fsgid=" instead of "fsgid"
- avoid redundant clone() operations

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-08 18:03:03 +08:00
Jiang Liu
98ba211a34 agent: fix a bug in update_ephemeral_mounts()
There's a bug in function update_ephemeral_mounts() which only handles
the first storage object and ignores all other storage objects.

Fixes: #7551

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-08 18:03:02 +08:00
Jiang Liu
5333618d70 agent: make add_storage() take &[Storage] instead of Vec<Storage>
Simplify add_storage() by taking &[Storage] instead of Vec<Storage>.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-08 18:03:01 +08:00
Jiang Liu
37f34781d1 agent: simplify function online_cpu_memory()
Simplify function online_cpu_memory() by on calling update_cpuset_path()
for containers with cpuset configured.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-08 18:03:00 +08:00
Jiang Liu
d3c5422379 agent: refine style of code related to sandbox
Refine style of code related to sandbox by:
- remove unnecessary comments for caller to take lock, we have already taken
  `&mut self`.
- change "*count < 1 " to "*count == 0", `count` is type of u32.
- make remove_sandbox_storage() to take `&mut self` instead of `&self`.
- group related function to each others
- avoid search the map twice in function find_process()
- avoid unwrap() in function run_oom_event_monitor()
- avoid unwrap() in online_resources()

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-08 18:02:59 +08:00
Jiang Liu
71a9f67781 agent: avoid unwrap() in function do_remove_container()
Avoid unwrap() in function do_remove_container(), and also make
implmementation symmetric for both timeout and non-timeout cases.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-08 18:02:58 +08:00
Jiang Liu
84badd89d7 agent: avoid clone objects when possible
Optimize agent rpc implementation by:
- avoid clone objects when possible
- avoid unwrap() when possible
- explictly drop object to ensure order

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-08-08 18:02:56 +08:00
Chao Wu
b098960442
Merge pull request #7581 from justxuewei/bump-versions
deps: Bump dependent crate versions
2023-08-08 15:16:57 +08:00
Chao Wu
24bf637835
Merge pull request #7500 from pmores/fix-queue-num-in-dragonball-share-fs
fix number of queues handling in dragonball share fs device
2023-08-08 12:07:25 +08:00
Xuewei Niu
b23c5ed155 deps: Bump dependent crate versions
This pull request is mainly for updating vm-memory and vmm-sys-util.

The affacted crates include:

- vm-memory: from 0.9.0 to 0.10.0
- vmm-sys-util: from 0.10.0 to 0.11.0
- virtio-queue: from 0.6.0 to 0.7.0
- fuse-backend-rs: from 0.10.4 to 0.10.5
- linux-loader: from 0.6.0 to 0.8.0
- nydus-api: from 0.3.0 to 0.3.1
- nydus-rafs: from 0.3.1 to 0.3.2
- nydus-storage: from 0.6.3 to 0.6.4

Fixes: #0000

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2023-08-08 11:54:09 +08:00
Fupan Li
5a20d8dcaf
Merge pull request #7383 from justxuewei/dan
runtime-rs: Introduce directly attachable network
2023-08-08 09:54:28 +08:00
Wedson Almeida Filho
c36572418f agent: avoid unnecessary calls to Arc::clone
These calls cause two extra atomic instructions each time they're used,
one to increment and another one to decrement the refcount.

Since we don't need them because the referred value is guaranteed to
outlive the function, remove the calls.

Fixes: #7190

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
2023-08-03 20:53:05 -03:00
Wedson Almeida Filho
4fbe0a3a53 runtime: bind-mount mounted block device into container
When the mounted block device isn't a layer, we want to mount it into
containers, but since it's already mounted with the correct fs (e.g.,
tar, ext4, etc.) in the pod, we just bind-mount it into the container.

Fixes: #7536

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
2023-08-03 17:58:39 -03:00
Wedson Almeida Filho
7e1b1949d4 runtime: add support for kata overlays
When at least one `io.katacontainers.fs-opt.layer` option is added to
the rootfs, it gets inserted into the VM as a layer, and the file system
is mounted as an overlay of all layers using the overlayfs driver.

Additionally, if the `io.katacontainers.fs-opt.block_device=file` option
is present in a layer, it is mounted as a block device backed by a file
on the host.

Fixes: #7536

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
2023-08-03 17:58:39 -03:00
Wedson Almeida Filho
6c867d9e86 agent: add io.katacontainers.fs-opt.overlay-rw option
This causes the overlay-fs driver to add the `upperdir` and `workdir`
options to an overlay-fs mount so that the mount becomes writable using
a discardable directory under the container id.

Fixes: #7536

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
2023-08-03 17:58:39 -03:00
Wedson Almeida Filho
6163c35657 agent: skip mount options that start with "io.katacontainers."
This is so that file systems don't fail when we pass kata-specific
options from the snapshotter to kata.

Fixes: #7536

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
2023-08-03 17:58:39 -03:00
Fabiano Fidêncio
fa35afa982
Merge pull request #7542 from wedsonaf/ci-fix
Use version 0.10.4 of `fuse-backend-rs`
2023-08-03 22:50:11 +02:00
Wedson Almeida Filho
b2ff97aa01 dragonball: use version 0.10.4 of fuse-backend-rs
Version 0.10.5, which was just released, breaks `nydus-storage`.

This is a workaround to fix the CI which is blocking other PRs.

Fixes: #7541

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
2023-08-03 14:15:17 -03:00
Manabu Sugimoto
845eeb4d7b agent: Allow clippy::redundant_clone in the unit tests
Allow `clippy::redundant_clone` in the agent's unit tests
because rustc>=1.70 shows the errors as false-negatives.
These `clone()` are required because the following codes
refer to the variable, but the clippy analyzes them by mistake,
using the conservative and limited approach.
Ref. https://rust-lang.github.io/rust-clippy/master/index.html#/redundant_clone

Fixes: #7534

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2023-08-03 19:07:40 +09:00
Xuewei Niu
3958a39d07 runtime-rs: Introduce directly attachable network
Kata containers as VM-based containers are allowed to run in the host
netns. That is, the network is able to isolate in the L2. The network
performance will benefit from this architecture, which eliminates as many
hops as possible. We called it a Directly Attachable Network (DAN for
short).

The network devices are placed at the host netns by the CNI plugins. The
configs are saved at {dan_conf}/{sandbox_id}.json in the format of JSON,
including device name, type, and network info. At the very beginning stage,
the DAN only supports host tap devices. More devices, like the DPDK, will
be supported in later versions.

The format of file looks like as below:

```json
{
	"netns": "/path/to/netns",
	"devices": [{
		"name": "eth0",
		"guest_mac": "xx:xx:xx:xx:xx",
		"device": {
			"type": "vhost-user",
			"path": "/tmp/test",
			"queue_num": 1,
			"queue_size": 1
		},
		"network_info": {
			"interface": {
				"ip_addresses": ["192.168.0.1/24"],
				"mtu": 1500,
				"ntype": "tuntap",
				"flags": 0
			},
			"routes": [{
				"dest": "172.18.0.0/16",
				"source": "172.18.0.1",
				"gateway": "172.18.31.1",
				"scope": 0,
				"flags": 0
			}],
			"neighbors": [{
				"ip_address": "192.168.0.3/16",
				"device": "",
				"state": 0,
				"flags": 0,
				"hardware_addr": "xx:xx:xx:xx:xx"
			}]
		}
	}]
}
```

Fixes: #1922

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2023-08-03 15:33:34 +08:00
Zhongtao Hu
e719423262
Merge pull request #7127 from cmaf/runtime-rs-ch-blk-2
runtime-rs: Add block device handling for cloud hypervisor
2023-08-03 09:46:32 +08:00
Zvonko Kaiser
cf8899f260
Merge pull request #7494 from zvonkok/vfio-mode
vfio: Fix vfio device ordering
2023-08-02 19:45:22 +02:00
Chelsea Mafrica
a81ad3b587 runtime-rs: Add block device handling in cloud hypervisor
Add functions for adding a block device to a container for CH.

Fixes #6690

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
2023-08-02 09:18:48 -07:00
Fupan Li
1a6b27bf6a
Merge pull request #5797 from Yuan-Zhuo/add-metrics-for-runtime-rs
runtime-rs: add support for gather metrics in runtime-rs
2023-08-02 13:40:22 +08:00
Fupan Li
a536d4a7bf
Merge pull request #6672 from Yuan-Zhuo/add-monitor-in-kata-ctl
kata-ctl: add monitor subcommand for runtime-rs
2023-08-02 13:39:02 +08:00
Pavel Mores
28e5e9c86e runtime-rs: fix number of queues handling in dragonball share fs device
Looks like a copy/paste error...

Fixes #7501

Signed-off-by: Pavel Mores <pmores@redhat.com>
2023-07-31 17:25:47 +02:00
Zvonko Kaiser
cddcde1d40 vfio: Fix vfio device ordering
If modeVFIO is enabled we need 1st to attach the VFIO control group
device /dev/vfio/vfio an 2nd the actuall device(s) afterwards.Sort the
devices starting with device #1 being the VFIO control group device and
the next the actuall device(s)
/dev/vfio/<group>

Fixes: #7493

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-07-31 11:26:27 +00:00
Jiang Liu
b3901c46d6 runtime-rs: ignore errors during clean up sandbox resources
Ignore errors during clean up sandbox resources as much as we can.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-07-31 13:07:43 +08:00
Jiang Liu
62e328ca5c runtime-rs: refine implementation of TaskService
Refine implementation of TaskService, making handler_message() as a
method.

Fixes: #7479

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-07-29 00:47:33 +08:00
Jiang Liu
458e1bc712 runtime-rs: make send_message() as an method of ServiceManager
Simplify implementation by making send_message() as an method of
ServiceManager.

Fixes: #7479

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-07-29 00:47:31 +08:00
Jiang Liu
1cc1c81c9a runtime-rs: fix possibe bug in ServiceManager::run()
Multiple instances of task service may get registered by
ServiceManager::run(), fix it by making operation symmetric.

Fixes: #7479

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-07-29 00:47:30 +08:00
Jiang Liu
1a5f90dc3f runtime-rs: simplify implementation of service crate
Simplify implementation of service crate.

Fixes: #7479

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-07-29 00:47:28 +08: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
Yuan-Zhuo
02cc4fe9db runtime-rs: add support for gather metrics in runtime-rs
1. Implemented metrics collection for runtime-rs shim and dragonball hypervisor.
2. Described the current supported metrics in runtime-rs.(docs/design/kata-metrics-in-runtime-rs.md)

Fixes: #5017

Signed-off-by: Yuan-Zhuo <yuanzhuo0118@outlook.com>
2023-07-28 17:16:51 +08:00
Zhongtao Hu
61a8eabf8e
Merge pull request #7139 from openanolis/fix/devmanager
runtime-rs: change block index to 0
2023-07-28 14:04:19 +08:00
Chelsea Mafrica
e941b3a094
Merge pull request #7456 from alakesh/agent-fix-typo
agent: fix typo in constant
2023-07-27 09:31:24 -07:00
Zhongtao Hu
c8fcd29d9b runtime-rs: use device manager to handle virtio-pmem
use device manager to handle virtio-pmem device

Fixes: #7119
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2023-07-27 20:18:49 +08:00
Zhongtao Hu
901c192251 runtime-rs: support configure vm_rootfs_driver
support configure vm_rootfs_driver in toml config

Fixes: #7119
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2023-07-27 20:12:53 +08:00
Zhongtao Hu
5d6199f9bc runtime-rs: use device manager to handle vm rootfs
use device manager to handle vm rootfs, after attach the block device of
vm rootfs, we need to increase index number

Fixes: #7119
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2023-07-27 20:12:45 +08:00
James O. D. Hunt
20f1f62a2a runtime-rs: change block index to 0
Change block index in SharedInfo to 0 for vda.

Fixes #7119

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2023-07-27 20:11:44 +08:00
Fabiano Fidêncio
8a22b5f075
Merge pull request #7439 from ManaSugi/fix/remove-unused-mut
agent,libs: Remove unused 'mut' keywords
2023-07-26 21:25:41 +02:00
Fabiano Fidêncio
9792ac49fe
Merge pull request #7425 from jongwu/remove_mut
runtime-rs: remove unneeded 'mut' keywords
2023-07-26 21:24:40 +02:00
Alakesh Haloi
314aec73d4 agent: fix typo in constant
It fixes a constant name to have the right spelling

Fixes: #7457
Signed-off-by: Alakesh Haloi <a_haloi@apple.com>
2023-07-26 00:06:34 -05:00
Eric Ernst
5385ddc560
Merge pull request #7365 from alakesh/symlink-fix
agent: exclude symlinks from recursive ownership change
2023-07-25 11:27:48 -07:00
GabyCT
7a3b55ce67
Merge pull request #7432 from ManaSugi/runk/doc-docker
runk: Add Docker guide to README
2023-07-25 09:56:02 -06: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
Manabu Sugimoto
b9f100b391 agent,libs: Remove unused 'mut' keywords
Remove unused `mut` because the agent compilation fails
when the rust compiler is >= 1.71. This is related to #7425

Fixes: #7438

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2023-07-25 17:41:08 +09:00
Fabiano Fidêncio
5ce0b4743f
Merge pull request #7382 from zvonkok/vfio-ap-debug
s390x: Fixing device.Bus assignment
2023-07-25 08:26:25 +02:00
Jianyong Wu
2c8f83424d runtime-rs: remove unneeded 'mut' keywords
These unneeded 'mut' keywords blocks built by rust 1.71.0. Remove them.

Fixes: #7424
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2023-07-24 08:47:15 +00:00
Zvonko Kaiser
1fc715bc65 s390x: Add AP Attach/Detach test
Now that we have propper AP device support add a
unit test for testing the correct Attach/Detach of AP devices.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-07-23 13:44:19 +00:00
Zvonko Kaiser
545de5042a vfio: Fix tests
Now with more elaborate checking of cold|hot plug ports
we needed to update some of the tests.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-07-20 13:42:44 +00:00
Zvonko Kaiser
62aa6750ec vfio: Added better handling of VFIO Control Devices
Depending on the vfio_mode we need to mount the
VFIO control device additionally into the container.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-07-20 13:42:42 +00:00
Zvonko Kaiser
dd422ccb69 vfio: Remove obsolete HotplugVFIOonRootBus
Removing HotplugVFIOonRootBus which is obsolete with the latest PCI
topology changes, users can set cold_plug_vfio or hot_plug_vfio either
in the configuration.toml or via annotations.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-07-20 07:25:40 +00:00
Zvonko Kaiser
114542e2ba s390x: Fixing device.Bus assignment
The device.Bus was reset if a specific combination of
configuration parameters were not met. With the new
PCIe topology this should not happen anymore

Fixes: #7381

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-07-20 07:24:26 +00:00
Alakesh Haloi
371a118ad0 agent: exclude symlinks from recursive ownership change
currently when fsGroup is used with direct-assign, kata agent
recursively changes ownership and permission for each file including
symlinks. However the problem with symlinks is, the permission of
the symlink itself may not be same as the underlying file. So while
doing recursive ownership and permission changes we should skip
symlinks.

Fixes: #7364
Signed-off-by: Alakesh Haloi <a_haloi@apple.com>
2023-07-19 20:42:55 -07:00
Chao Wu
bbd3c1b6ab Dragonball: migrate dragonball-sandbox crates to Kata
In order to make it easier for developers to contribute to Dragonball,
we decide to migrate all dragonball-sandbox crates to Kata.

fixes: #7262

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2023-07-19 19:41:57 +08:00
Chao Wu
935432c36d
Merge pull request #7352 from justxuewei/exec-hang
agent: Fix exec hang issues with a backgroud process
2023-07-18 23:02:18 +08:00
Fabiano Fidêncio
25d80fcec2
Merge pull request #6993 from zvonkok/kata-agent-init-mount
agent: Ignore already mounted dev/fs/pseudo-fs
2023-07-18 14:11:44 +02:00
Zhongtao Hu
d50f3888af
Merge pull request #7219 from Apokleos/network-refactor
runtime-rs: enhancement of Device Manager for network endpoints.
2023-07-17 14:13:51 +08:00
QuanweiZhou
ce14f26d82
Merge pull request #5450 from openanolis/trace_rs
feat(Tracing): tracing in Rust runtime
2023-07-17 09:27:13 +08:00
Manabu Sugimoto
f1d8de9be6 runk: Allow runk to launch a container without pid namespace
Allow runk to launch a container even though users don't specify the
pid namespace in `config.json` because general container runtimes
such as runc also can launch a container without the namespace.
On the other hand, Kata Containers doesn't allow it due to security issue
so this feature should be enabled in only runk.

Fixes: #7168

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2023-07-16 23:31:14 +05:30
Zhongtao Hu
419f8a5db7
Merge pull request #7021 from cheriL/7020/ignore-unconfigured-netinterface
runtime-rs: ignore unconfigured network interfaces
2023-07-16 10:11:15 +08:00
Xuewei Niu
6c91af0a26 agent: Fix exec hang issues with a backgroud process
Issue #4747 and pull request #4748 fix exec hang issues where the exec
command hangs when a process's stdout is not closed. However, the PR might
cause the exec command not to work as expected, leading to CI failure. The
PR was reverted in #7042. This PR resolves the exec hang issues and has
undergone 1000 rounds of testing to verify that it would not cause any CI
failures.

Fixes: #4747

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2023-07-16 08:32:45 +08:00
Chao Wu
9b3dc572ae
Merge pull request #7018 from nubificus/feat_bindmount_propagation
runtime-rs: add parameter for propagation of (u)mount events
2023-07-14 15:21:41 +08:00
Archana Shinde
b9b8ccca0c
Merge pull request #7236 from amshinde/move-guestprotection
kata-ctl: Move GuestProtection code to kata-sys-util
2023-07-13 23:50:17 -07:00
soup
150e54d02b runtime-rs: ignore unconfigured network interfaces
Fixes: #7020

Signed-off-by: soup <lqh348659137@outlook.com>
2023-07-14 14:16:03 +08:00
Anastassios Nanos
6787c63900 runtime-rs: add parameter for propagation of (u)mount events
Add an extra parameter in `bind_mount_unchecked` to specify
the propagation type: "shared" or "slave".

Fixes: #7017

Signed-off-by: Anastassios Nanos <ananos@nubificus.co.uk>
2023-07-13 15:58:22 +00:00
Archana Shinde
62080f83cb kata-sys-util: Fix compilation errors
Fix compilation errors for aarch64 and s390x

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-07-13 20:09:43 +05:30
Archana Shinde
02d99caf6d static-checks: Make cargo clippy pass.
Get rid of cargo clippy warnings.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-07-13 20:08:13 +05:30
Archana Shinde
9824206820 agent: Make the static checks pass for agent
The static checks for the agent require Cargo.lock to be updated.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-07-13 20:08:13 +05:30
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
a24dbdc781 kata-sys-util: Move utilities to get platform protection
Add utilities to get platform protection to 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
f5d1957174 kata-sys-util: Move additional functionality to cpu.rs
Make certain imports architecture specific as these are not used on all
architectures.
Move additional constants and functionality to cpu.rs.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-07-13 20:08:13 +05:30
Nathan Whyte
304b9d9146 kata-sys-util: Move CPU info functions
Move get_single_cpu_info and get_cpu_flags into kata-sys-util.
Add new functions that get a list of flags and check if a flag
exists in that list.

Fixes #6383

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
Zhongtao Hu
b69cdb5c21
Merge pull request #7286 from xuejun-xj/xuejun/up-fix
dragonball/agent: Add some optimization for Makefile and bugfixes of unit tests on aarch64
2023-07-13 09:39:23 +08:00
alex.lyn
283f809dda runtime-rs: Enhancing Device Manager for network endpoints.
Currently, network endpoints are separate from the device manager
and need to be included for proper management. In order to do so,
we need to refactor the implementation of the network endpoints.

The first step is to restructure the NetworkConfig and NetworkDevice
structures.
Next, we will implement the virtio-net driver and add the Network
device to the Device Manager.
Finally, we'll unify entries with do_handle_device for each endpoint.

Fixes: #7215

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-07-12 11:27:12 +08:00
xuejun-xj
a65291ad72 agent: rustjail: update test_mknod_dev
When running cargo test in container, test_mknod_dev may fail sometimes
because of "Operation not permitted". Change the device path to
"/dev/fifo-test" to avoid this case.

Fixes: #7284

Signed-off-by: xuejun-xj <jiyunxue@linux.alibaba.com>
2023-07-12 11:22:32 +08:00
xuejun-xj
46b81dd7d2 agent: clippy: fix cargo clippy warnings
Replace "if let Ok(_) = ..." with ".is_ok()" method.

Fixes: #7284

Signed-off-by: xuejun-xj <jiyunxue@linux.alibaba.com>
2023-07-12 11:22:32 +08:00
xuejun-xj
c4771d9e89 agent: Makefile: enable set SECCOMP dynamically
Change ":=" to "?:".

Fixes: #7284

Signed-off-by: xuejun-xj <jiyunxue@linux.alibaba.com>
2023-07-12 11:22:32 +08:00
xuejun-xj
883b4db380 dragonball: fix cargo test on aarch64
1. Update memory end assert because address space layout differs between
x86 and arm.
2. Set guest_addr for aarch64 in test_handler_insert_region case.

Fixes: #7284
TODO: #7290

Signed-off-by: xuejun-xj <jiyunxue@linux.alibaba.com>
2023-07-12 11:22:31 +08:00
Xuewei Niu
6822029c81 runtime-rs: Do not scan network if network model is "none"
Skip to scan network from netns if the network model is specified to
"none".

Fixes: #7305

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2023-07-12 10:00:50 +08:00
xuejun-xj
aedc586e14 dragonball: Makefile: add coverage target
Add "coverage" target to compute code coverage for dragonball.

Fixes: #7284

Signed-off-by: xuejun-xj <jiyunxue@linux.alibaba.com>
2023-07-11 14:36:25 +08:00
Yushuo
28c29b248d bugfix: plus default_memory when calculating mem size
We've noticed this caused regressions with the k8s-oom tests, and then
decided to take a step back and do this in the same way it was done
before 67972ec48a.

Moreover, this step back is also more reasonable in terms of the
controlling logic.

And by doing this we can re-enable the k8s-oom.bats tests, which is done
as part of this PR.

Fixes: #7271
Depends-on: github.com/kata-containers/tests#5705

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
2023-07-10 15:53:04 +08:00
Ji-Xinyou
ed23b47c71 tracing: Add tracing to runtime-rs
Introduce tracing into runtime-rs, only some functions are instrumented.

Fixes: #5239

Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
2023-07-09 22:09:43 +08:00
Fabiano Fidêncio
96e9374d4b dragonball: Don't fail if a request asks for more CPUs than allowed
Let's take the same approach of the go runtime, instead, and allocate
the maximum allowed number of vcpus instead.

Fixes: #7270

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-07-08 15:50:23 +02:00
Fabiano Fidêncio
275c84e7b5 Revert "agent: fix the issue of exec hang with a backgroud process"
This reverts commit 25d2fb0fde.

The reason we're reverting the commit is because it to check whether
it's the cause for the regression on devmapper tests.

Fixes: #7253
Depends-on: github.com/kata-containers/tests#5705

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-07-08 14:27:40 +02:00
Zvonko Kaiser
f72cb2fc12 agent: Remove shadowed function, add slog-term
Remove shadowed get_mounts(), added slog-term as a new crate,
slog can directly log to stdout and we can capture output
in the test-cases that are created in the function to be tested.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-07-07 11:28:14 +00:00
Zvonko Kaiser
07810bf71f agent: Ignore already mounted dev/fs/pseudo-fs
Using an initrd and setting KATA_INIT=yes meaning we're using the kata-agent
as the init process we need to make sure that the agent is not segfaulting
if mounts are already happened. Some workloads need to configure several
things in the initrd before the kata-agent starts which involves having
/proc or /sys already mounted.

Fixes: #6992

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-07-07 07:36:04 +00:00
Bin Liu
f214058b07
Merge pull request #7202 from wedsonaf/macros
Convert `is_allowed`, `ttrpc_error` and `sl` to functions
2023-07-04 14:23:08 +08:00
Peng Tao
581be92b25
Merge pull request #4492 from zvonkok/pcie-topology
runtime: fix PCIe topology for GPUDirect use-case
2023-07-03 09:17:12 +08:00
Fabiano Fidêncio
6a21e20c63 runtime: Add "none" as a shared_fs option
Currently, even when using devmapper, if the VMM supports virtio-fs /
virtio-9p, that's used to share a few files between the host and the
guest.

This *needed*, as we need to share with the guest contents like secrets,
certificates, and configurations, via Kubernetes objects like configMaps
or secrets, and those are rotated and must be updated into the guest
whenever the rotation happens.

However, there are still use-cases users can live with just copying
those files into the guest at the pod creation time, and for those
there's absolutely no need to have a shared filesystem process running
with no extra obvious benefit, consuming memory and even increasing the
attack surface used by Kata Containers.

For the case mentioned above, we should allow users, making it very
clear which limitations it'll bring, to run Kata Containers with
devmapper without actually having to use a shared file system, which is
already the approach taken when using Firecracker as the VMM.

Fixes: #7207

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-06-30 20:45:00 +02:00
Zvonko Kaiser
0f454d0c04 gpu: Fixing typos for PCIe topology changes
Some comments and functions had typos and wrong capitalization.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-06-30 08:42:55 +00:00
Fupan Li
4288b935e1
Merge pull request #7104 from openanolis/physical/endpoint
runtime-rs:  support physical endpoint using device manager
2023-06-29 14:43:44 +08:00
GabyCT
19890133e9
Merge pull request #7189 from Apokleos/direct-vol-bugfix
runtime-rs: bugfix for direct volume path's validation.
2023-06-28 12:26:22 -06:00
Wedson Almeida Filho
0504bd7254 agent: convert the sl macros to functions
There is nothing in them that requires them to be macros. Converting
them to functions allows for better error messages.

Fixes: #7201

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
2023-06-28 14:05:32 -03:00
Wedson Almeida Filho
0860fbd410 agent: convert the ttrpc_error macro to a function
There is nothing in it that requires it to be a macro. Converting it to
a function allows for better error messages.

Fixes: #7201

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
2023-06-28 14:05:32 -03:00
Wedson Almeida Filho
0e5d6ce6d7 agent: convert the is_allowed macro to a function
Having a function allows for better error messages from the type checker
and it makes it clearer to callers what can happen. For example:

is_allowed!(req);

Gives no indication that it may result in an early return, and no simple
way for callers to modify the behaviour. It also makes it look like
ownership of `req` is being transferred.

On the other hand,

is_allowed(&req)?;

Indicates that `req` is being borrowed (immutably) and may fail. The
question mark indicates that the caller wants an early return on
failure.

Fixes: #7201

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
2023-06-28 14:05:32 -03:00
Wedson Almeida Filho
f680fc52be agent: change AGENT_CONFIG's lazy type to just AgentConfig
Since it is never modified, it doesn't really need a lock of any kind.
Removing the `RwLock` wrapper allows us to remove all `.read().await`
calls when accessing it.

Additionally, `AGENT_CONFIG` already has a static lifetime, so there is
no need to wrap it in a ref-counted heap allocation.

Fixes: #5409

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
2023-06-28 14:05:27 -03:00
Jianyong Wu
1f3e837e4b runtime-rs: fix build error on AArch64
Vfio support introduce build error on AArch64. Remove arch related
annotation can avoid this error.

Fixes: #7187
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2023-06-28 07:10:43 +00:00
alex.lyn
6fd25968c6 runtime-rs: bugfix for direct volume path's validation.
The failure mainly caused by the encoded volume path and
the mount/src. As the src will be validated with stat,but
it's not a full path and encoded, which causes the stat
mount source failed.

Fixes: #7186

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-06-28 10:07:07 +08:00
Zhongtao Hu
bff4672f7d runtime-rs: support physical endpoint using device manager
use device manager to attach physical endpoint

Fixes: #7103
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2023-06-27 10:25:51 +08:00
alex.lyn
0df2fc2702 runtime-rs: add support spdk/vhost-user based volume.
Unlike the previous usage which requires creating
/dev/xxx by mknod on the host, the new approach will
fully utilize the DirectVolume-related usage method,
and pass the spdk controller to vmm.

And a user guide about using the spdk volume when run
a kata-containers. it can be found in docs/how-to.

Fixes: #6526

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-06-25 16:23:19 +08:00
GabyCT
388b55175e
Merge pull request #7056 from FuuuOverclocking/fuu/fix-console_manager
dragonball: avoid obtaining lock twice in create_stdio_console
2023-06-23 16:47:00 -06:00
Zvonko Kaiser
8330fb8ee7 gpu: Update unit tests
Some tests are now failing due to the changes how PCIe is
handled. Update the test accordingly.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-06-23 11:16:25 +00:00
Fupan Li
469c678425
Merge pull request #7058 from Apokleos/vfio-dev
add support vfio device manager
2023-06-22 17:51:22 -06:00
Archana Shinde
2d329125fd
Merge pull request #6800 from amshinde/check-vm-capability
kata-ctl: Check for vm capability
2023-06-21 23:52:46 -07:00
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
soup
09720babc3 docs: fix spelling of "crate"
Fixes: #7153

Signed-off-by: soup <lqh348659137@outlook.com>
2023-06-21 16:10:54 +08:00
alex.lyn
59510cfee0 runtime-rs: add support vfio device based volume
A new choice of using vfio devic based volume for kata-containers.
With the help of kata-ctl direct-volume, users are able to add a
specified device which is BDF or IOMMU group ID.

To help users to use it smoothly, A doc about howto added in
docs/how-to/how-to-run-kata-containers-with-kinds-of-Block-Volumes.

Fixes: #6525

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-06-18 14:07:05 +08:00
alex.lyn
1e3b372bbb runtime-rs: add support vfio device manager
Limitations:
As no ready rust vmm's vfio manager is ready, it only supports
part of vfio in runtime-rs. And the left part is to call vmm
interfaces related to vfio add/remove.

So when vmm/vfio manager ready, a new PR will be pushed to
narrow the gap.

Fixes: #6525

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-06-18 14:05:59 +08:00
Greg Kurz
a43ea24dfc virtiofsd: Convert legacy -o sub-options to their -- replacement
The `-o` option is the legacy way to configure virtiofsd, inherited
from the C implementation. The rust implementation honours it for
compatibility but it logs deprecation warnings.

Let's use the replacement options in the go shim code. Also drop
references to `-o` from the configuration TOML file.

Fixes #7111

Signed-off-by: Greg Kurz <groug@kaod.org>
2023-06-16 11:42:54 +02:00
Greg Kurz
8e00dc6944 virtiofsd: Drop -o no_posix_lock
The C implementation of virtiofsd had some kind of limited support
for remote POSIX locks that was causing some workflows to fail with
kata. Commit 432f9bea6e hard coded `-o no_posix_lock` in order
to enforce guest local POSIX locks and avoid the issues.

We've switched to the rust implementation of virtiofsd since then,
but it emits a warning about `-o` being deprecated.

According to https://gitlab.com/virtio-fs/virtiofsd/-/issues/53 :

   The C implementation of the daemon has limited support for
   remote POSIX locks, restricted exclusively to non-blocking
   operations. We tried to implement the same level of
   functionality in #2, but we finally decided against it because,
   in practice most applications will fail if non-blocking
   operations aren't supported.

   Implementing support for non-blocking isn't trivial and will
   probably require extending the kernel interface before we can
   even start working on the daemon side.

There is thus no justification to pass `-o no_posix_lock` anymore.

Signed-off-by: Greg Kurz <groug@kaod.org>
2023-06-16 11:42:39 +02:00
Greg Kurz
2a15ad9788 virtiofsd: Stop using deprecated -f option
The rust implementation of virtiofsd always runs foreground and
spits a deprecation warning when `-f` is passed.

Signed-off-by: Greg Kurz <groug@kaod.org>
2023-06-16 10:30:40 +02:00
Zvonko Kaiser
72f2cb84e6 gpu: Reset cold or hot plug after overriding
If we override the cold, hot plug with an annotation
we need to reset the other plugging mechanism to NoPort
otherwise both will be enabled.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-06-15 17:51:01 +00:00
Zvonko Kaiser
fbacc09646 gpu: PCIe topology, consider vhost-user-block in Virt
In Virt the vhost-user-block is an PCIe device so
we need to make sure to consider it as well. We're keeping
track of vhost-user-block devices and deduce the correct
amount of PCIe root ports.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-06-15 17:39:55 +00:00
Zvonko Kaiser
b11246c3aa gpu: Various fixes for virt machine type
The PCI qom path was not deduced correctly added regex for correct
path walking.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-06-14 08:33:57 +00:00
Zvonko Kaiser
40101ea7db vfio: Added annotation for hot(cold) plug
Now it is possible to configure the PCIe topology via annotations
and addded a simple test, checking for Invalid and RootPort

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-06-14 08:20:24 +00:00
Zvonko Kaiser
8f0d4e2612 vfio: Cleanup of Cold and Hot Plug
Removed the configuration of PCIeRootPort and PCIeSwitchPort, those
values can be deduced in createPCIeTopology

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-06-14 08:20:24 +00:00
Zvonko Kaiser
b5c4677e0e vfio: Rearrange the bus assignemnt
Refactor the bus assignment so that the call to GetAllVFIODevicesFromIOMMUGroup
can be used by any module without affecting the topology.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-06-14 08:20:24 +00:00
Zvonko Kaiser
b1aa8c8a24 gpu: Moved the PCIe configs to drivers
The hypervisor_state file was the wrong location for the PCIe Port
settings, moved everything under device umbrella, where it can be
consumed more easily and we do not get into circular deps.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-06-14 08:20:24 +00:00
Zvonko Kaiser
55a66eb7fb gpu: Add config to TOML
Update cold-plug and hot-plug setting to include bridge, root and
switch-port

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-06-14 08:20:24 +00:00
Zvonko Kaiser
da42801c38 gpu: Add config settings tests for hot-plug
Updated all references and config settings for hot-plug to match
cold-plug

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-06-14 08:20:24 +00:00
Zvonko Kaiser
de39fb7d38 runtime: Add support for GPUDirect and GPUDirect RDMA PCIe topology
Fixes: #4491

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-06-14 08:20:24 +00:00
alex.lyn
347385b4ee runtime-rs: Enhance flexibility of virtio-fs config
support more and flexible options for inline virtiofs.

Fixes: #7091

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-06-13 15:12:47 +08:00
Zhongtao Hu
355a24e0e1
Merge pull request #6289 from openanolis/runtime_vcpu_resize
feat(runtime): vcpu resize capability
2023-06-13 10:54:11 +08:00
Yushuo
ae2cfa8263 doc: add vcpu handlint doc for runtime-rs
Kubernetes and Containerd will help calculate the Sandbox Size and pass it to
Kata Containers through annotations.

In order to accommodate this favorable change and be compatible with the past,
we have implemented the handling of the number of vCPUs in runtime-rs. This is
This is slightly different from the original runtime-go design.

This doc introduce how we handle vCPU size in runtime-rs.

Fixes: #5030

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2023-06-12 19:23:11 +08:00
Yushuo
7b1e67819c fix(clippy): fix clippy error
Fixes: #5030

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2023-06-12 17:53:16 +08:00
Yushuo
67972ec48a feat(runtime-rs): calculate initial size
In this commit, we refactored the logic of static resource management.

We defined the sandbox size calculated from PodSandbox's annotation and
SingleContainer's spec as initial size, which will always be the sandbox
size when booting the VM.

The configuration static_sandbox_resource_mgmt controls whether we will
modify the sandbox size in  the following container operation.

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2023-06-12 17:53:16 +08:00
Yushuo
aaa96c749b feat(runtime-rs): modify onlineCpuMemRequest
Some vmms, such as dragonball, will actively help us
perform online cpu operations when doing cpu hotplug.
Under the old onlineCpuMem interface, it is difficult
to adapt to this situation.

So we modify the semantics of nb_cpus in onlineCpuMemRequest.
In the original semantics, nb_cpus represents the number of
newly added CPUs that need to be online. The modified
semantics become that the number of online CPUs in the guest
needs to be guaranteed.

Fixes: #5030

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2023-06-12 17:53:16 +08:00
Yushuo
d66f7572dd feat(runtime-rs): clear cpuset in runtime side
The declaration of the cpu number in the cpuset is greater
than the actual number of vcpus, which will cause an error when
updating the cgroup in the guest.

This problem is difficult to solve, so we temporarily clean up
the cpuset in the container spec before passing in the agent.

Fixes: #5030

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2023-06-12 17:53:16 +08:00
Yushuo
a0385e1383 feat(runtime-rs): update linux resource when stop_process
Update the resource when delete container, which is in
stop_process in runtime-rs.

Fixes: #5030

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2023-06-12 17:53:16 +08:00
Yushuo
a39e1e6cd1 feat(runtime-rs): merge the update_cgroups in update_linux_resources
Updating vCPU resources and memory resources of the sandbox and
updating cgroups on the host will always happening together, and
they are all updated based on the linux resources declarations of
all the containers.

So we merge update_cgroups into the update_linux_resources, so we
can better manage the resources allocated to one pod in the host.

Fixes: #5030

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2023-06-12 17:53:16 +08:00
Ji-Xinyou
fa6dff9f70 feat(runtime-rs): support vcpu resizing on runtime side
Support vcpu resizing on runtime side:
1. Calculate vcpu numbers in resource_manager using all the containers'
   linux_resources in the spec.
2. Call the hypervisor(vmm) to do the vcpu resize.
3. Call the agent to online vcpus.

Fixes: #5030
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
2023-06-12 17:53:16 +08:00
James O. D. Hunt
8cb4238b46 packaging: Remove snap package
Nobody has volunteered to maintain the (currently broken) snap build, so
remove it.

Fixes: #6769.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2023-06-12 09:24:09 +01:00
Chao Wu
2988553305
Merge pull request #6998 from HerlinCoder/herlincoder/vpa
Dragonball: support resize memory
2023-06-11 17:21:12 +08: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
Fabiano Fidêncio
b50f62ce48
Merge pull request #6756 from arronwy/measured_rootfs
Port Measured rootfs feature from CCv0 branch to main
2023-06-09 12:35:05 +02:00
Helin Guo
8fb7ab7518 dragonball: introduce virtio-balloon device
We introduce virtio-balloon device to support memory resize.
virtio-balloon device could reclaim memory from guest to host.

Fixes: #6719

Signed-off-by: Helin Guo <helinguo@linux.alibaba.com>
2023-06-09 17:47:27 +08:00
Helin Guo
7ed9494973 dragonball: introduce virtio-mem device
We introduce virtio-mem device to support memory resize. virtio-mem
device could hot-plug more memory blocks to guest and could also
hot-unplug them from guest.

Fixes: #6719

Signed-off-by: Helin Guo <helinguo@linux.alibaba.com>
2023-06-09 17:47:21 +08:00
alex.lyn
776a15e092 runtime-rs: add support direct volume.
As block/direct volume use similar steps of device adding,
so making full use of block volume code is a better way to
handle direct volume.

the only different point is that direct volume will use
DirectVolume and get_volume_mount_info to parse mountinfo.json
from the direct volume path. That's to say, direct volume needs
the help of `kata-ctl direct-volume ...`.

Details seen at Advanced Topics:
[How to run Kata Containers with kinds of Block Volumes]
docs/how-to/how-to-run-kata-containers-with-kinds-of-Block-Volumes.md

Fixes: #5656

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-06-09 08:16:26 +08:00
Helin Guo
a8e0f51c52 dragonball: extend DeviceOpContext
In order to support virtio-mem and virtio-balloon devices, we need to
extend DeviceOpContext with VmConfigInfo and InstanceInfo.

Fixes: #6719

Signed-off-by: Helin Guo <helinguo@linux.alibaba.com>
2023-06-08 22:04:31 +08:00
alex.lyn
abae114046 runtime-rs: refactor device manager implementation
The key aspects of the DM implementation refactoring as below:

1. reduce duplicated code
 Many scenarios have similar steps when adding devices. so to reduce
 duplicated code, we should create a common method abstracted and use
 it in various scenarios.
do_handle_device:
(1) new_device with DeviceConfig and return device_id;
(2) try_add_device with device_id and do really add device;
(3) return device info of device's info;

2. return full info of Device Trait get_device_info
 replace the original type DeviceConfig with full info DeviceType.

3. refactor find_device method.

Fixes: #5656

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-06-08 08:47:08 +08: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
Fuu
210a15794c dragonball: avoid obtaining lock twice in create_stdio_console
Fixes #7055

Signed-off-by: Fuu <fuu-open@linux.alibaba.com>
2023-06-07 16:12:22 +08: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
Wang, Arron
f62b2670c0 config: Add root hash value and measure config to kernel params
After we have a guest kernel with builtin initramfs which
provide the rootfs measurement capability and Kata rootfs
image with hash device, we need set related root hash value
and measure config to the kernel params in kata configuration file.

Fixes: #6674

Signed-off-by: Wang, Arron <arron.wang@intel.com>
2023-06-06 12:34:13 +02:00
Fabiano Fidêncio
eb1bfa922b
Merge pull request #6980 from nubificus/feat_sharefs_files
runtime-rs: handle copy files when share_fs is not available
2023-06-06 12:26:55 +02: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
Fupan Li
465f5a5ced
Merge pull request #4748 from lifupan/main_fix
agent: fix the issue of exec hang with a backgroud process
2023-06-02 10:46:43 +08:00
Anastassios Nanos
ed37715e05 runtime-rs: handle copy files when share_fs is not available
In hypervisors that do not support virtiofs we have to copy files in
the VM sandbox to properly setup the network (resolv.conf, hosts, and hostname).

To do that, we construct the volume as before, with the addition of an extra
variable that designates the path where the file will reside in the sandbox.

In this case, we issue a `copy_file` agent request *and* we patch the spec
to account for this change.

Fixes: #6978

Signed-off-by: Anastassios Nanos <ananos@nubificus.co.uk>
Signed-off-by: George Pyrros <gpyrros@nubificus.co.uk>
2023-06-01 21:40:56 +00:00
xuejun-xj
5f6fc3ed76 runtime-rs: bugfix: update Cargo.lock
When dragonball update dbs-boot crate in commit
64c764c147, the Cargo.lock in runtime-rs
should also be updated.

Fixes: #6969

Signed-off-by: xuejun-xj <jiyunxue@linux.alibaba.com>
2023-06-01 20:25:35 +08:00
xuejun-xj
560442e6ed dragonball: add vcpu_boot_onlined vector
This commit implements the vcpu_boot_onlined vector in get_fdt_vm_info.

"boot_enabled" means whether this vcpu should be onlined at first boot.
It will be used by fdt, which write an attribute called boot_enabled,
and will be handled by guest kernel to pass the correct cpu number to
function "bringup_nonboot_cpus".

Fixes: #6010

Signed-off-by: xuejun-xj <jiyunxue@linux.alibaba.com>
2023-05-30 15:51:08 +08:00
xuejun-xj
e31772cfea dragonball: add support resize_vcpu on aarch64
This commit add support of resize_vcpu on aarch64. As kvm will check
whether vgic is initialized when calling KVM_CREATE_VCPU ioctl, all the
vcpu fds should be created before vm is booted.

To support resizing vcpu scenario, we use max_vcpu_count for
create_vcpus and setup_interrupt_controller interfaces. The
SetVmConfiguration API will ensure max_vcpu_count >= boot_vcpu_count.

Fixes: #6010

Signed-off-by: xuejun-xj <jiyunxue@linux.alibaba.com>
2023-05-30 15:51:08 +08:00
xuejun-xj
64c764c147 dragonball: update dbs-boot to v0.4.0
dbs-boot-v0.4.0 refectors the create_fdt interface. It simplifies the
parameters needed to be passed and abstracts them into three structs.

By the way, it also reserves some interfaces for future feature: numa
passthrough and cache passthrough.

Fixes: #6969

Signed-off-by: xuejun-xj <jiyunxue@linux.alibaba.com>
2023-05-30 15:51:08 +08:00
xuejun-xj
fd9b414646 dragonball: update comment for init_microvm
Rewrite the comment of Vm::init_microvm method for aarch64.

Fixes cargo test warnings on aarch64.

Fixes: #6969

Signed-off-by: xuejun-xj <jiyunxue@linux.alibaba.com>
2023-05-30 15:51:08 +08:00
Zhongtao Hu
099b4b0d0e
Merge pull request #6598 from Apokleos/sandbox_bind_mounts
runtime-rs/sandbox_bindmounts: add support for sandbox bindmounts
2023-05-28 12:00:39 +08:00
Zhongtao Hu
cb962b0dc9
Merge pull request #6702 from Apokleos/directvol-common
runtime-rs/kata-ctl: Enhancement of DirectVolumeMount.
2023-05-28 12:00:12 +08: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
Fupan Li
25d2fb0fde agent: fix the issue of exec hang with a backgroud process
When run a exec process in backgroud without tty, the
exec will hang and didn't terminated.

For example:

crictl -i <container id> sh -c 'nohup tail -f /dev/null &'

Fixes: #4747

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2023-05-26 10:56:46 +08:00
Tim Zhang
5231aff90f
Merge pull request #6860 from lifupan/main
netlink: Fix the issue of update_interface
2023-05-26 10:54:07 +08:00
Greg Kurz
837f7a2fe6
Merge pull request #6959 from beraldoleal/issues/6757
runtime: sending SIGKILL to qemu
2023-05-25 16:24:37 +02:00
alex.lyn
eee7aae71d runtime-rs/sandbox_bindmounts: add support for sandbox bindmounts
sandbox_bind_mounts supports kinds of mount patterns, for example:

(1) "/path/to", default readonly mode.
(2) "/path/to:ro", same as (1).
(3) "/path/to:rw", readwrite mode.

Both support configuration and annotation:
(1)[runtime]
sandbox_bind_mounts=["/path/to", "/path/to:rw", "/mnt/to:ro"]
(2) annotation will alse be supported, restricted as below:
io.katacontainers.config.runtime.sandbox_bind_mounts
                         = "/path/to /path/to:rw /mnt/to:ro"

Fixes: #6597

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-05-25 20:00:25 +08:00
Fupan Li
62b2838962
Merge pull request #6846 from ZhangShuaiyi/DeviceMgrMethod
dragonball: convert BlockDeviceMgr and VirtioNetDeviceMgr functions to methods
2023-05-25 18:11:44 +08:00
QuanweiZhou
377b7735f5
Merge pull request #6872 from justxuewei/rm-virtio-devices
dragonball: Remove virtio-net and vsock devices gracefully
2023-05-25 17:08:36 +08:00
Beraldo Leal
0e47cfc4c7 runtime: sending SIGKILL to qemu
There is a race condition when virtiofsd is killed without finishing all
the clients. Because of that, when a pod is stopped, QEMU detects
virtiofsd is gone, which is legitimate.

Sending a SIGTERM first before killing could introduce some latency
during the shutdown.

Fixes #6757.

Signed-off-by: Beraldo Leal <bleal@redhat.com>
2023-05-24 11:31:28 -04:00
Fabiano Fidêncio
9aae333343
Merge pull request #6871 from kmjohansen/bugfix/ptmx
runtime: make debug console work with sandbox_cgroup_only
2023-05-23 22:24:51 +02:00
Fupan Li
170336517f
Merge pull request #5441 from openanolis/device_manager_dev
runtime-rs: device manager for runtime-rs
2023-05-23 16:50:07 +08:00
Zhongtao Hu
4719802c8d runtime-rs: add virtio-blk-mmio
add virtio-blk-mmio option for dragonball

Fixes:#5375
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-05-23 00:58:10 +08:00
Zhongtao Hu
f9bded4484 runtime-rs: add devicetype enum
use device type to store the config information for different kind of
devices

Fixes:#5375
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-05-23 00:55:35 +08:00
Zhongtao Hu
6800d30fdb runtime-rs: remove device
Support remove device after container stop

Fixes:#5375
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-05-23 00:54:22 +08:00
Zhongtao Hu
f16012a1eb runtime-rs: support linux device
support linux device in runtime-rs

Fixes:#5375
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-05-23 00:54:13 +08:00
Zhongtao Hu
fe9ec67644 runtime-rs: block volume
support block volume in runtime-rs

Fixes: #5375
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-05-23 00:54:04 +08:00
Zhongtao Hu
a8bfac90b1 runtime-rs: support block rootfs
support devmapper for block rootfs

Fixes: #5375

Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-05-23 00:53:30 +08:00
Zhongtao Hu
b076d46db3 agent: handle hotplug virtio-mmio device
As dragonball support hotplug virtio-mmio device, we should handle it in agent

Fixes:#5375
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-05-23 00:53:22 +08:00
Zhongtao Hu
6e273d6ccc runtime-rs: implement trait for vhost-user device
add the trait implementation for vhost-user device

Fixes:#5375
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2023-05-23 00:53:16 +08:00
Zhongtao Hu
cc9c915384 runtime-rs: implement trait for vfio device
add the trait implementation for vfio device,

Fixes:#5375
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-05-23 00:53:10 +08:00
Archana Shinde
2c9efbe04c
Merge pull request #6907 from likebreath/0519/clh_v32.0
Upgrade to Cloud Hypervisor v32.0
2023-05-22 09:53:05 -07:00
Zhongtao Hu
e4c5c74a75 runtime-rs: device manager
Support device manager for runtime-rs, add block device handler for
device manager

Fixes:#5375
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-05-23 00:53:04 +08:00
GabyCT
6796af511b
Merge pull request #6890 from GabyCT/topic/fixurlvirt
docs: Update container network model url
2023-05-19 15:10:26 -06:00
Bo Chen
35c3d7b4bc runtime: clh: Re-generate the client code
This patch re-generates the client code for Cloud Hypervisor v32.0.
Note: The client code of cloud-hypervisor's OpenAPI is automatically
generated by openapi-generator.

Fixes: #6632

Signed-off-by: Bo Chen <chen.bo@intel.com>
2023-05-19 12:49:45 -07:00
Fabiano Fidêncio
0364620844
Merge pull request #6819 from fidencio/topic/use-static-sandbox-resource-mgmt-for-TEEs
runtime: Use static_sandbox_resource_mgmt=true for TEEs
2023-05-18 22:38:31 +02:00
Fabiano Fidêncio
2ea8acaaa5
Merge pull request #6882 from bergwolf/github/tokio
update tokio dependency
2023-05-18 20:35:16 +02:00
Krister Johansen
eff6ed2d5f runtime: make debug console work with sandbox_cgroup_only
If a hypervisor debug console is enabled and sandbox_cgroup_only is set,
the hypervisor can fail to open /dev/ptmx, which prevents the sandbox
from launching.

This is caused by the absence of a device cgroup entry to allow access
to /dev/ptmx.  When sandbox_cgroup_only is not set, the hypervisor
inherits the default unrestrcited device cgroup, but with it enabled it
runs into allow / deny list restrictions.

Fix by adding an allowlist entry for /dev/ptmx when debug is enabled,
sandbox_cgroup_only is true, and no /dev/ptmx is already in the list of
devices.

Fixes: #6870

Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
2023-05-18 10:36:24 -07:00
Gabriela Cervantes
11a34a72e2 docs: Update container network model url
This PR updates the container network model url that is part of the
virtcontainers documentation.

Fixes #6889

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
2023-05-18 15:08:08 +00:00
Peng Tao
f6e1b1152c agent: update tokio dependency
To 1.28.1 to bring in the latest fixes.

Fixes: #6881
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2023-05-18 09:36:06 +00:00
Shuaiyi Zhang
c477ac551f dragonball: Convert VirtioNetDeviceMgr function to method
Convert VirtioNetDeviceMgr::insert_device and
VirtioNetDeviceMgr::update_device_ratelimiters to method.

Fixes: #6880

Signed-off-by: Shuaiyi Zhang <zhang_syi@qq.com>
2023-05-18 16:57:01 +08:00
Shuaiyi Zhang
4659facb74 dragonball: Convert BlockDeviceMgr function to method
Convert BlockDeviceMgr::insert_device, BlockDeviceMgr::remove_device
and BlockDeviceMgr::update_device_ratelimiters to method.

Fixes: #6880

Signed-off-by: Shuaiyi Zhang <zhang_syi@qq.com>
2023-05-18 16:56:49 +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
Peng Tao
ca6892ddb1 runtime-rs: update tokio dependency
Unify it to the latest 1.28.1 version.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2023-05-18 08:18:22 +00:00
Fabiano Fidêncio
3a4b924226
Merge pull request #6833 from rye-stripe/bugfix/vcpu-pinning
resource-control: fix setting CPU affinities on Linux
2023-05-18 08:12:39 +02:00
Xuewei Niu
ee6deef09d dragonball: Remove virtio-net and vsock devices gracefully
This MR implements removing virtio-net and virtio-vsock devices gracefully when
shutting down VMM.

Fixes: #6684

Signed-off-by: Zizheng Bian <zizheng.bian@linux.alibaba.com>
Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2023-05-18 12:11:20 +08:00
Fabiano Fidêncio
e762f70920
Merge pull request #6838 from rye-stripe/bugfix/use-enable-vcpus-pinning-from-toml
runtime: use enable_vcpus_pinning from toml
2023-05-17 21:30:44 +02:00
Fabiano Fidêncio
ca1531fe9d runtime: Use static_sandbox_resource_mgmt=true for TEEs
When this option is enabled the runtime will attempt to determine the
appropriate sandbox size (memory, CPU) before booting the virtual
machine.

As TEEs do not support memory and CPU hotplug, this approach must be
used.

Fixes: #6818

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-05-17 19:21:52 +02:00
Fabiano Fidêncio
8ce14e709a
Merge pull request #6810 from fitzthum/snp-enable
gha: Enable SEV-SNP tests on main
2023-05-17 15:29:54 +02:00
Wainer Moschetta
259158f1c3
Merge pull request #6789 from dubek/add-sev-package
runtime: Port sev package to main
2023-05-17 10:02:19 -03:00
Tobin Feldman-Fitzthum
cbb9fe8b81 config: Use standard OVMF with SEV
The AmdSev firmware package should be used with
measured direct boot. If the expected hashes are not
injected into the firmware binary by the VMM, the
guest will not boot. This is required for security.

Currently the main branch does not have the extended
shim support for SEV, which tells the VMM to inject
the expected hashes.

We ship the standard OVMF package to use with SNP,
so let's switch SEV to that for now. This will need
to be changed back when shim support for SEV(-ES)
is added to main.

Signed-off-by: Tobin Feldman-Fitzthum <tobin@ibm.com>
2023-05-17 11:36:04 +02:00
fupan
2bda92face netlink: Fix the issue of update_interface
When updating an interface, there's maybe an existed
interface whose name would be the same with the updated
required name, thus it would update failed with interface
name existed error. Thus we should rename the existed interface
with an temporary name and swap it with the previouse interface
name last.

Fixes: #6842

Signed-off-by: fupan <fupan.lfp@antgroup.com>
2023-05-17 16:45:49 +08:00
Fabiano Fidêncio
9630c13ac0
Merge pull request #6845 from fidencio/topic/yet-more-nvidia-gpu-naming-fixes
gpu: Rename the last bits from `gpu` to `nvidia-gpu`
2023-05-17 09:05:12 +02:00
Amulya Meka
3ccc29030d
Merge pull request #6780 from Amulyam24/rust-virtfs
ppc64le: switch virtiofsd from C to rust version
2023-05-17 09:36:28 +05:30
Salvador Fuentes
b76058c979
Merge pull request #6721 from nedsouza/virtcontainers-qemu-go-coverage
virtcontainers/qemu_test.go: Improve coverage
2023-05-16 11:11:43 -06:00
Feng Wang
ebc8e8e2fd
Merge pull request #6773 from jepio/agent-config-error-context
agent: Add context to errors that may occur when AgentConfig file is …
2023-05-16 09:21:34 -07:00
James O. D. Hunt
a96fcfd5be
Merge pull request #6735 from nedsouza/258/tests-coverage-compatoci
virtcontainers/pkg/compatoci/: Improved coverage for  for Kata 2.0
2023-05-16 15:36:35 +01:00
Amulyam24
c5a59caca1 ppc64le: switch virtiofsd from C to rust version
We have been using the C version of virtiofsd on ppc64le. Now that the issue with
rust virtiofsd have been fixed, let's switch to it.

Fixes: #4259

Signed-off-by: Amulyam24 <amulmek1@in.ibm.com>
2023-05-16 14:46:19 +02:00
Dov Murik
dd7562522a runtime: pkg/sev: Add kbs utility package for SEV pre-attestation
Supports both online and offline modes of interaction with simple-kbs
for SEV/SEV-ES confidential guests.

Fixes: #6795

Signed-off-by: Dov Murik <dovmurik@linux.ibm.com>
2023-05-16 15:27:32 +03:00
Dov Murik
05de7b2607 runtime: Add sev package
The sev package provides utilities for launching AMD SEV and SEV-ES
confidential guests.

Fixes: #6795

Signed-off-by: Dov Murik <dovmurik@linux.ibm.com>
2023-05-16 15:27:32 +03:00
Fabiano Fidêncio
3a9d3c72aa gpu: Rename the last bits from gpu to nvidia-gpu
Let's specifically name the `gpu` runtime class as `nvidia-gpu`.  By
doing this we keep the door open and ease the life of the next vendor
adding GPU support for Kata Containers.

Fixes: #6553

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-05-16 13:47:52 +02:00
Bin Liu
47a02dcc7f
Merge pull request #6767 from ngpatel6/Issue-5403
kata-ctl:  Add the option to install kata-ctl to a user specified directory
2023-05-16 10:43:40 +08:00
Bin Liu
2cd2d02d1f
Merge pull request #6812 from ZhangShuaiyi/dev/write_bootparams
Dragonball: use LinuxBootConfigurator::write_bootparams
2023-05-16 09:54:41 +08: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
Peteris Rudzusiks
bdb75fb21e runtime: use enable_vcpus_pinning from toml
Set the default value of runtime's EnableVCPUsPinning to value read from .toml.

Fixes: #6836

Signed-off-by: Peteris Rudzusiks <rye@stripe.com>
2023-05-15 21:41:20 +02:00
Tamas K Lengyel
20cb875087 virtcontainers/qemu_test.go: Improve test coverage
Rework TestQemuCreateVM routine to be a table driven test with
various config variations passed to it. After CreateVM a handful
of additional functions are exercised to improve code-coverage.
Also add partial coverage for StartVM routine.

Currently improving from 19.7% to 35.7%

Credit PR to Hackathon Team3

Fixes: #267

Signed-off-by: Tamas K Lengyel <tamas.lengyel@intel.com>
2023-05-15 15:26:35 -04:00
Peteris Rudzusiks
3e85bf5b17 resource-control: fix setting CPU affinities on Linux
With this fix the vCPU pinning feature chooses the correct
physical cores to pin the vCPU threads on rather than always using core 0.

Fixes #6831

Signed-off-by: Peteris Rudzusiks <rye@stripe.com>
2023-05-15 16:46:36 +02:00
LiuWeijie
50cc9c582f tests: Improve coverage for virtcontainers/pkg/compatoci/ for Kata 2.0
Add test cases for ParseConfigJson function and GetContainerSpec function

Fixes: #258

Signed-off-by: LiuWeijie <weijie.liu@intel.com>
2023-05-15 11:58:17 +08:00
Archana Shinde
32b39ee347
Merge pull request #6763 from nedsouza/266/tests_coverage_virtcontainers_fc
virtcontainers: Improved test coverage for fc.go from 4.6% to 18.5%
2023-05-12 11:53:27 -07:00
Shuaiyi Zhang
197c336516 Dragonball: use LinuxBootConfigurator::write_bootparams to writes
the boot parameters into guest memory.

Fixes: #6813

Signed-off-by: Shuaiyi Zhang <zhang_syi@qq.com>
2023-05-12 16:07:44 +08: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
Fabiano Fidêncio
edfaae85cb
Merge pull request #6700 from fitzthum/snp-artifacts
packaging: Add SEV-SNP artifacts to main
2023-05-11 10:47:10 +02:00
Fabiano Fidêncio
c937d0a5d4
Merge pull request #6591 from UnmeshDeodhar/add-sev-artifacts-to-main
packaging: Add sev artifacts to main
2023-05-11 09:09:36 +02:00
Tobin Feldman-Fitzthum
0bb37bff78 config: Add SNP configuration
SNP requires many specific configurations, so let's make
a new SNP configuration file that we can use with the
kata-qemu-snp runtime class.

Signed-off-by: Tobin Feldman-Fitzthum <tobin@ibm.com>
Signed-off-by: Alex Carter <Alex.Carter@ibm.com>
2023-05-10 20:55:36 +00:00
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
Unmesh Deodhar
fb9c1fc36e runtime: Add qemu-sev config
Adding config file that can be used with qemu-sev runtime class.
Since SEV has limited hotplug support, increase
the pod overhead to account for fixed resource usage.

Fixes: #6572

Signed-off-by: Unmesh Deodhar <udeodhar@amd.com>
2023-05-10 12:19:56 -05:00
Unmesh Deodhar
12c5ef9020 packaging: add support to build OVMF for SEV
SEV requires special OVMF to work with kernel hashes.
Thus, adding changes that builds this custom OVMF for SEV.

Fixes: #6572

Signed-Off-By: Unmesh Deodhar <udeodhar@amd.com>
2023-05-10 12:19:55 -05:00
Jeremi Piotrowski
022a33de92 agent: Add context to errors when AgentConfig file is missing
When the agent config file is missing, the panic message says "no such file or
directory" but doesn't inform the user about which file was missing. Add
context to the parsing (with filename) and to the from_config_file() calls
(with information where the path is coming from).

Fixes: #6771
Depends-on: github.com/kata-containers/tests#5627
Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2023-05-10 08:43:16 +02: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
Feng Wang
4e0dce6802
Merge pull request #6738 from fengwang666/oss-fix-fd-leak
runtime: Fix virtiofs fd leak
2023-05-08 10:52:36 -07:00
Eduardo Berrocal
a4c0303d89 virtcontainers: Fixed static checks for improved test coverage for fc.go
Expanded tests on fc_test.go to cover more lines of code. Coverage went from 4.6% to 18.5%.
Fixed very simple static check fail on line 202.

Fixes: #266

Signed-off-by: Eduardo Berrocal <eduardo.berrocal@intel.com>
2023-05-07 00:17:36 -07:00
Peng Tao
65670e6b0a
Merge pull request #6699 from zvonkok/cold-plug-vfio
gpu: cold plug VFIO devices
2023-05-05 10:04:29 +08:00
Archana Shinde
b86d32aba9
Merge pull request #6728 from nedsouza/256/tests_coverage_pkg_signals
pkg/signals: Improved test coverage 60% to 100%
2023-05-04 16:19:12 -07:00
Archana Shinde
9443c4aea7
Merge pull request #6729 from nedsouza/259/tests_coverage_virtcontainers_persist
virtcontainers/persist: Improved test coverage 65% to 87.5%
2023-05-04 16:18:55 -07:00
Archana Shinde
09134c30de
Merge pull request #6737 from nedsouza/265/virtcontainers-clh-go-coverage
virtcontainers/clh_test.go: improve unit test coverage
2023-05-04 16:15:43 -07: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
Bin Liu
e57ac2ae18
Merge pull request #6749 from nedsouza/260/tests_coverage_virtcontainers_factory
virtcontainers/factory: Improved test coverage
2023-05-04 10:54:40 +08:00
Zvonko Kaiser
13d7f39c71 gpu: Check for VFIO port assignments
Bailing out early if the port is wrong, allowed port settings are
no-port, root-port, switch-port

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-05-03 12:32:33 +00: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
Eduardo Berrocal
03a8cd69c2 virtcontainers: Improved test coverage for fc.go from 4.6% to 18.5%
Expanded tests on fc_test.go to cover more lines of code. Coverage went from 4.6% to 18.5%.

Fixes: #266

Signed-off-by: Eduardo Berrocal <eduardo.berrocal@intel.com>
2023-04-28 15:40:45 -07: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
Eduardo Berrocal
6bf1fc6051 virtcontainers/factory: Improved test coverage
Expanded tests on factory_test.go to cover more lines of code. Coverage went from 34% to 41.5% in the case of user-mode run tests,
and from 77.7% to 84% in the case of priviledge-mode run tests.

Fixes: #260

Signed-off-by: Eduardo Berrocal <eduardo.berrocal@intel.com>
2023-04-27 13:08:35 -07:00
Zvonko Kaiser
138ada049c gpu: Cold Plug VFIO toml setting
Added the cold_plug_vfio setting to the qemu-toml.in with some
epxlanation

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-04-27 11:04:45 +00: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
Zvonko Kaiser
f7ad75cb12 gpu: Cold-plug extend the api.md
Make the hypervisorconfig consistent in code and api.md

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-04-27 09:35:05 +00:00
Zvonko Kaiser
0fec2e6986 gpu: Add cold-plug test
Cold plug setting is now correctly decoded in toml

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-04-27 09:30:24 +00:00
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
2f81f48dae config: Add file under /opt as another location to look for the config
Most of kata installation tools use this path for installation, so
add this to the paths to look for the configuration.toml file.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-04-26 22:12:30 -07:00
Archana Shinde
07f7d17db5 config: Make the pipe_size field optional
Add the serde default attribute to the field so that parsing
can continue if this field is not present.
The agent assumes a default value for this, so it is not required
by the user to provide a value here.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2023-04-26 22:12:30 -07:00
Archana Shinde
68f6357731 config: Make function to get the default conf file public
This will be used by the kata-env command.

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
Feng Wang
205909fbed runtime: Fix virtiofs fd leak
The kata runtime invokes removeStaleVirtiofsShareMounts after
a container is stopped to clean up the stale virtiofs file caches.

Fixes: #6455
Signed-off-by: Feng Wang <fwang@confluent.io>
2023-04-26 15:53:39 -07:00
Tamas K Lengyel
0f45b0faa9 virtcontainers/clh_test.go: improve unit test coverage
Credit PR to Hackathon Team3

Fixes: #265

Signed-off-by: Tamas K Lengyel <tamas.lengyel@intel.com>
2023-04-26 19:12:51 +00:00
Zvonko Kaiser
dded731db3 gpu: Add OVMF setting for MMIO aperture
The default size of OVMFs aperture is too low to
initialized PCIe devices with huge BARs

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-04-26 09:47:37 +00:00
Zvonko Kaiser
2a830177ca gpu: Add fwcfg helper function
Added driver util function for easier handling of VFIO
devices outside of the VFIO module. At the sandbox level
we may need to set options depending if we have a VFIO/PCIe
device, like the fwCfg for confiential guests.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-04-26 09:47:37 +00:00
Zvonko Kaiser
131f056a12 gpu: Extract VFIO Functions to drivers
Some functions may be used in other modules then only in
the VFIO module, extract them and make them available to
other layers like sandbox.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-04-26 09:47:37 +00:00
Zvonko Kaiser
c8cf7ed3bc gpu: Add ColdPlug of VFIO devices with devManager
If we have a VFIO device and cold-plug is enabled
we mark each device as ColdPlug=true and let the VFIO
module do the attaching.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-04-26 09:47:37 +00:00
Zvonko Kaiser
e2b5e7f73b gpu: Add Rawdevices to hypervisor
RawDevics are used to get PCIe device info early before the sandbox
is started to make better PCIe topology decisions

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-04-26 09:47:37 +00:00
Zvonko Kaiser
6107c32d70 gpu: Assign default value to cold-plug
Make sure the configuration is propagated to the right structs
and the default value is assigned.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-04-26 09:47:37 +00:00
Zvonko Kaiser
377ebc2ad1 gpu: Add configuration option for cold-plug VFIO
Users can set cold-plug="root-port" to cold plug a VFIO device in QEMU

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-04-26 09:47:37 +00:00
Zvonko Kaiser
c18ceae109 gpu: Add new struct PCIePort
For the hypervisor to distinguish between PCIe components, adding
a new enum that can be used for hot-plug and cold-plug of PCIe devices

Fixes: #6687

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-04-26 09:47:37 +00:00
Bin Liu
509bc8b6c8
Merge pull request #6718 from openanolis/mengze/keep_abnormal
runtime-rs: support keep_abnormal in toml config
2023-04-26 12:36:52 +08:00
Eduardo Berrocal
9c38204f13 virtcontainers/persist: Improved test coverage 65% to 87.5%
Expanded tests on manager_test.go to cover more lines of code.

Fixes: #259

Signed-off-by: Eduardo Berrocal <eduardo.berrocal@intel.com>
2023-04-25 23:53:46 +00:00
Eduardo Berrocal
1c1ee8057c pkg/signals: Improved test coverage 60% to 100%
Expanded tests on signals_test.go to cover more lines of code. 'go test' won't show 100% coverage (only 66.7%), because one test need to spawn a new
process (since it is testing a function that calls os.Exit(1)).

Fixes: #256

Signed-off-by: Eduardo Berrocal <eduardo.berrocal@intel.com>
2023-04-25 23:34:13 +00:00
mengze
cc8ea3232e runtime-rs: support keep_abnormal in toml config
This patch adds keep_abnormal in runtime config. If keep_abnormal =
true, it means that 1) if the runtime exits abnormally, the cleanup
process will be skipped, and 2) the runtime will not exit even if the
health check fails.

This option is typically used to retain abnormal information for
debugging and should NOT be enabled by default.

Fixes: #6717

Signed-off-by: mengze <mengze@linux.alibaba.com>
Signed-off-by: quanweiZhou <quanweiZhou@linux.alibaba.com>
2023-04-25 13:47:44 +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
Fupan Li
ceefd50bd0
Merge pull request #6680 from Tim-Zhang/fix-ut-bad-fd
agent: Fix ut issue caused by fd double closed
2023-04-20 11:18:27 +08:00
Fupan Li
a7b4b69230
Merge pull request #6673 from Tim-Zhang/upgrade-ttrpc-protobuf
Bump ttrpc to 0.7.2 and protobuf to 3.2.0
2023-04-20 10:13:43 +08:00
Fupan Li
a1568cd2f5
Merge pull request #6676 from zvonkok/gpu-runtime
gpu: Add GPU enabled confguration and runtime
2023-04-19 13:01:49 +08:00
Tim Zhang
53c749a9de agent: Fix ut issue caused by fd double closed
Never ever try to close the same fd double times, even in a unit test.

A file descriptor is a number which will be reused, so when you close
the same number twice you may close another file descriptor in the second
time and then there will be an error 'Bad file descriptor (os error 9)'
while the wrongly closed fd is being used.

Fixes: #6679

Signed-off-by: Tim Zhang <tim@hyper.sh>
2023-04-18 23:19:10 +08:00
Tim Zhang
2e3f19af92 agent: fix clippy warnings caused by protobuf3
Fix warnings introduced by protobuf upgrade.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2023-04-17 20:15:49 +08:00
Tim Zhang
4849c56faa agent: Fix unit test issue cuased by protobuf upgrade
Fixes: #6646

Signed-off-by: Tim Zhang <tim@hyper.sh>
2023-04-17 19:49:21 +08: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
Tim Zhang
eb3d20dccb protocols: Add ut for Serde
Fixes: #6646

Signed-off-by: Tim Zhang <tim@hyper.sh>
2023-04-17 19:49:21 +08:00
Tim Zhang
59568c79dd protocols: add support for Serde
rust-protobuf@3 does not support Serde natively anymore.
So we need to do it by ourselves.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2023-04-17 19:49:21 +08:00
Tim Zhang
a6b4d92c84 runtime-rs: 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:20 +08:00
Zvonko Kaiser
a81fff706f gpu: Adding a GPU enabled configuration
We need to set hotplug on pci root port and enable at least one
root port. Also set the guest-hooks-dir to the correct path

Fixes: #6675

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-04-17 10:40:09 +00:00
Tim Zhang
8af6fc77cd agent: Bump ttrpc from 0.6.0 to 0.7.1
Fixes: #6646

Signed-off-by: Tim Zhang <tim@hyper.sh>
2023-04-17 18:31:41 +08:00
Tim Zhang
009b42dbff protocols: Fix unit test
Fixes: #6646

Signed-off-by: Tim Zhang <tim@hyper.sh>
2023-04-17 18:31:41 +08:00
Tim Zhang
392732e213 protocols: Bump ttrpc from 0.6.0 to 0.7.1
Fixes: #6646

Signed-off-by: Tim Zhang <tim@hyper.sh>
2023-04-17 18:31:35 +08:00
Zvonko Kaiser
f4f958d53c gpu: Do not pass-through PCI (Host) Bridges
On some systems a GPU is in a IOMMU group with a PCI Bridge and
PCI Host Bridge. Per default no PCI Bridge needs to be passed-through.
When scanning the IOMMU group, ignore devices with a 0x60 class ID prefix.

Fixes: #6663

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2023-04-17 10:08:23 +00:00
Fabiano Fidêncio
fffe2c6082
Merge pull request #6648 from fidencio/topic/gha-tdx-improvements-and-fixes
gha: tdx: Ensure kata-deploy is removed after the tests run
2023-04-15 00:21:31 +02:00
Fabiano Fidêncio
dc662333df runtime: Increase the dial_timeout
When testing on AKS, we've been hitting the dial_timeout every now and
then.  Let's increase it to 45 seconds (instead of 30) for all the VMMs,
and to 60 seconfs in case of TEEs.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-04-13 22:42:52 +02:00
Fabiano Fidêncio
f478b9115e clh: tdx: Update timeouts for confidential guest
Booting up TDX takes more time than booting up a normal VM.  Those
values are being already used as part of the CCv0 branch, and we're just
bringing them to the `main` branch as well.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-04-13 10:18:07 +02:00
Alexandru Matei
db2cac34d8 runtime: Don't create socket file in /run/kata
The socket file for shim management is created in /run/kata
and it isn't deleted after the container is stopped. After
running and stopping thousands of containers /run folder
will run out of space.

Fixes #6622
Signed-off-by: Alexandru Matei <alexandru.matei@uipath.com>
Co-authored-by: Greg Kurz <groug@kaod.org>
2023-04-13 10:21:29 +03:00
Zhongtao Hu
328793bb27
Merge pull request #6585 from Apokleos/nydus_prefetch_files
nydus_rootfs/prefetch_files: add prefetch_files for RAFS
2023-04-12 19:58:36 +08:00
Zhongtao Hu
fef531f565
Merge pull request #6618 from Apokleos/virtiofs_extra_cache_mode
runtime-rs/virtio-fs: add support extra handler for cache mode.
2023-04-12 14:40:05 +08:00
Bin Liu
9327bb0912
Merge pull request #6639 from openanolis/nerdctl
runtime-rs: enable nerdctl to setup cni plugin
2023-04-12 12:04:37 +08:00
Zhongtao Hu
69ba2098f8 runtime-rs: remove network entities and netns
remove network entities and netns

Fixes:#4693
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2023-04-12 10:21:06 +08:00
Zhongtao Hu
b31f103d12 runtime-rs: enable nerdctl cni plugin
1. when we use nerdctl to setup network for kata, no netns is created by
nerdctl, kata need to create netns by its own

2. after start VM, nerdctl will call cni plugin via oci hook, we need to
rescan the netns after the interfaces have been created, and hotplug
the network device into the VM

Fixes:#4693
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2023-04-12 10:21:04 +08:00
Fabiano Fidêncio
3b3656d96d
Merge pull request #6522 from fidencio/topic/add-tdx-artefacts-from-2023ww01-to-main
tdx: Add artefacts from the latest TDX tools release into main
2023-04-11 20:43:02 +02:00
Fabiano Fidêncio
50ce33b02d
Merge pull request #6205 from fengwang666/non-root-clh
runtime: support non-root for clh
2023-04-11 19:34:00 +02:00
Fabiano Fidêncio
98682805be config: Add configuration for QEMU TDX
As the QEMU configuration for TDX differs quite a lot from the normal
QEMU configuration, let's add a new configuration file for the QEMU TDX.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-04-11 16:10:35 +02:00
Fabiano Fidêncio
3e15800199 govmm: Directly pass the firmware using -bios with TDX
Since TDX doesn't support readonly memslot, TDVF cannot be mapped as
pflash device and it actually works as RAM. "-bios" option is chosen to
load TDVF.

OVMF is the opensource firmware that implements the TDVF support. Thus
the command line to specify and load TDVF is ``-bios OVMF.fd``

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-04-11 15:23:42 +02:00
Fabiano Fidêncio
3c5ffb0c85 govmm: Set "sept-ve-disable=on"
This is needed since 22ww49.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-04-11 15:23:42 +02:00
Fabiano Fidêncio
ed145365ec runtime/qemu: Drop "kvm-type=tdx"
This is not supported since 22ww49.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-04-11 15:23:42 +02:00
Fabiano Fidêncio
25b3cdd38c virtcontainers: Drop check for the tdx CPU flag
In the recent kernels provided by Intel the `tdx` CPU flag is not
present anymore.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-04-11 15:23:42 +02:00
Fabiano Fidêncio
01bdacb4e4 virtcontainers: Also check /sys/firmwares/tdx for TDX
Let's make sure we also check /sys/firmwares/tdx for TDX guest
protection, as the location may depend on whether TDX Seam is being used
or not.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-04-11 15:23:42 +02:00
alex.lyn
f3595e48b0 nydus_rootfs/prefetch_files: add prefetch_files for RAFS
A sandbox annotation used to specify prefetch_files.list
path the container image being used, and runtime will pass
it to Hypervisor to search for corresponding prefetch file:
format looks like:
"io.katacontainers.config.hypervisor.prefetch_files.list"
      = /path/to/<uid>/xyz.com/fedora:36/prefetch_file.list

Fixes: #6582

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-04-10 10:05:52 +08:00
Zhongtao Hu
3bfaafbf44 fix: oci hook
1. when do the deserialization for the oci hook, we should use camel
case for createRuntime

2. we should pass the dir of bundle path instead of the path of
config.json

Fixes:#4693
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2023-04-10 09:53:43 +08:00
Greg Kurz
c1fbaae8d6 rustjail: Use CPUWeight with systemd and CgroupsV2
The CPU shares property belongs to CgroupsV1. CgroupsV2 uses CPU weight
instead. The correct value is computed in the latter case but it is passed
to systemd using the legacy property. Systemd rejects the request and the
agent exists with the following error :

        Value specified in CPUShares is out of range: unknown

Replace the "shares" wording with "weight" in the CgroupsV2 code to
avoid confusions. Use the "CPUWeight" property since this is what
systemd expects in this case.

Fixes #6636

References:

https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html#CPUWeight=weight
https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html#systemd%20252
https://github.com/containers/crun/blob/main/crun.1.md#cpu-controller

Signed-off-by: Greg Kurz <groug@kaod.org>
2023-04-07 17:57:26 +02:00
alex.lyn
dc6569dbbc runtime-rs/virtio-fs: add support extra handler for cache mode.
Add support for virtiofsd when virtio_fs_extra_args with
"-o cache auto, ..." users specified.

Fixes: #6615

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2023-04-06 16:31:02 +08:00
Greg Kurz
a3e3b0591f
Merge pull request #6562 from c3d/issue/6561-unwrap-panic
rustjail: Fix panic when cgroup manager fails
2023-04-05 16:58:13 +02:00
James O. D. Hunt
cbe6f04194
Merge pull request #6501 from shippomx/dev_metrics
runtime: add filter metrics with specific names
2023-04-05 15:15:09 +01:00
Christophe de Dinechin
b661e0cf3f rustjail: Add anyhow context for D-Bus connections
In cases where the D-Bus connection fails, add a little additional context about
the origin of the error.

Fixes: 6561

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
Suggested-by: Archana Shinde <archana.m.shinde@intel.com>
Spell-checked-by: Greg Kurz <gkurz@redhat.com>
2023-04-03 14:09:34 +02:00
Christophe de Dinechin
7796e6ccc6 rustjail: Fix minor grammatical error in function name
Rename `unit_exist` function to `unit_exists` to match English grammar rule.

Fixes: #6561

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
2023-03-30 16:13:37 +02:00
Christophe de Dinechin
41fdda1d84 rustjail: Do not unwrap potential error with cgroup manager
There can be an error while connecting to the cgroups managager, for
example a `ENOENT` if a file is not found. Make sure that this is
reported through the proper channels instead of causing a `panic()`
that does not provide much information.

Fixes: #6561

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
Reported-by: Greg Kurz <gkurz@redhat.com>
2023-03-30 16:09:13 +02: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
Miao Xia
0f73515561 runtime: add filter metrics with specific names
The kata monitor metrics API returns a huge size response,
if containers or sandboxs are a large number,
focus on what we need will be harder.

Fixes: #6500

Signed-off-by: Miao Xia <xia.miao1@zte.com.cn>
2023-03-28 14:56:13 +08:00
Bin Liu
75987aae72
Merge pull request #6408 from jongwu/nydus_rm_hybrid
nydus: upgrad to v2.2.0
2023-03-28 11:07:56 +08:00
James O. D. Hunt
ac58588682 runtime-rs: ch: Generate Cloud Hypervisor config for confidential guests
This change provides a preliminary implementation for the Cloud Hypervisor (CH) feature ([currently
disabled](https://github.com/kata-containers/kata-containers/pull/6201))
to allow it to generate the CH configuration for handling confidential guests.

This change also introduces concrete errors using the `thiserror` crate
(see `src/runtime-rs/crates/hypervisor/ch-config/src/errors.rs`) and a
lot of unit tests for the conversion code that generates the CH
configuration from the generic Hypervisor configuration.

Fixes: #6430.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2023-03-22 14:38:38 +00:00
James O. D. Hunt
96555186b3 runtime-rs: ch: Honour debug setting
Enable Cloud Hypervisor debug based on the specified configuration
rather than hard-coding debug to be disabled.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2023-03-22 14:38:38 +00:00
James O. D. Hunt
e3c2d727ba runtime-rs: ch: clippy fix
Simplify the code to keep rust's `clippy` happy.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2023-03-22 14:38:38 +00:00
James O. D. Hunt
f06f72b5e9
Merge pull request #6467 from jongwu/qemu-uefi-path
qemu/arm64: disable image nvdimm once no firmware offered
2023-03-22 08:43:01 +00:00
Fabiano Fidêncio
2fe0733dcb
Merge pull request #4582 from BbolroC/vfio-ap
agent: Bring in VFIO-AP device handling again
2023-03-20 11:43:13 +01:00
Jianyong Wu
ece5edc641 qemu/arm64: disable image nvdimm if no firmware offered
For now, image nvdimm on qemu/arm64 depends on UEFI/ACPI, so if there
is no firmware offered, it should be disabled.

Fixes: #6468
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2023-03-20 18:03:05 +08:00
Yushuo
f4938c0d90 bugfix: set hostname
Setting hostname according to the spec.

Fixes: #6247

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
2023-03-16 17:16:06 +08:00
Hyounggyu Choi
96baa83895 agent: Bring in VFIO-AP device handling again
This PR is a continuing work for (kata-containers#3679).

This generalizes the previous VFIO device handling which only
focuses on PCI to include AP (IBM Z specific).

Fixes: kata-containers#3678
Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2023-03-16 18:14:12 +09:00
Greg Kurz
e6e719699f
Merge pull request #6471 from etrunko/main
dependency: update cgroups-rs
2023-03-16 08:01:07 +01:00
QuanweiZhou
56c63a9b1c
Merge pull request #6186 from wllenyj/dragonball-ut-6
Built-in Sandbox: add more unit tests for dragonball. Part 6
2023-03-16 11:02:05 +08:00
Jakob Naucke
f666f8e2df agent: Add VFIO-AP device handling
Initial VFIO-AP support (#578) was simple, but somewhat hacky; a
different code path would be chosen for performing the hotplug, and
agent-side device handling was bound to knowing the assigned queue
numbers (APQNs) through some other means; plus the code for awaiting
them was written for the Go agent and never released. This code also
artificially increased the hotplug timeout to wait for the (relatively
expensive, thus limited to 5 seconds at the quickest) AP rescan, which
is impractical for e.g. common k8s timeouts.

Since then, the general handling logic was improved (#1190), but it
assumed PCI in several places.

In the runtime, introduce and parse AP devices. Annotate them as such
when passing to the agent, and include information about the associated
APQNs.

The agent awaits the passed APQNs through uevents and triggers a
rescan directly.

Fixes: #3678
Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2023-03-16 10:07:48 +09:00
Jakob Naucke
b546eca26f runtime: Generalize VFIO devices
Generalize VFIO devices to allow for adding AP in the next patch.
The logic for VFIOPciDeviceMediatedType() has been changed and IsAPVFIOMediatedDevice() has been removed.

The rationale for the revomal is:

- VFIODeviceMediatedType is divided into 2 subtypes for AP and PCI
- Logic of checking a subtype of mediated device is included in GetVFIODeviceType()
- VFIOPciDeviceMediatedType() can simply fulfill the device addition based
on a type categorized by GetVFIODeviceType()

Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2023-03-16 10:06:37 +09:00
Jakob Naucke
4c527d00c7 agent: Rename VFIO handling to VFIO PCI handling
e.g., split_vfio_option is PCI-specific and should instead be named
split_vfio_pci_option. This mutually affects the runtime, most notably
how the labels are named for the agent.

Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2023-03-16 07:43:39 +09:00
Jakob Naucke
db89c88f4f agent: Use cfg-if for s390x CCW
Uses fewer lines in upcoming VFIO-AP support.

Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2023-03-16 07:43:39 +09:00
Jakob Naucke
68a586e52c agent: Use a constant for CCW root bus path
used a function like PCI does, but this is not necessary

Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2023-03-16 07:43:39 +09:00
Fabiano Fidêncio
814d07af58
Merge pull request #6463 from sprt/sprt/mshv-compat
runtime: add support for Hyper-V
2023-03-15 18:03:25 +01: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
Chao Wu
97cdba97ea runtime-rs: update load_config comment
Since shimv2 create task option is already implemented, we need to update the
corresponding comments.

Also, the ordering is also updated to fit with the code.

fixes: #3961

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2023-03-15 14:44:47 +08:00
Eric Ernst
dc42f0a33b
Merge pull request #6411 from wlan0/empty-dir
Add support for ephemeral mounts to occupy entire sandbox's memory
2023-03-13 20:07:27 -07:00
Henry Beberman
974a5c22f0 runtime: add support for Hyper-V
This adds /dev/mshv to the list of sandbox devices so that VMMs can
create Hyper-V VMs.

In our testing, this also doesn't error out in case /dev/mshv isn't
present.

Fixes #6454.

Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
2023-03-13 17:13:51 -07:00
Fabiano Fidêncio
40f4eef535 build: Use the correct kernel name
When calling `MAKE_KERNEL_NAME` we're considering the default kernel
name will be `vmlinux.container` or `vmlinuz.container`, which is not
the case as the runtime-rs, when used with dragonball, relies on the
`vmlinu[zx]-dragonball-experimental.container` kernel.

Other hypervisors will have to introduce a similar
`MAKE_KERNEL_NAME_${HYPERVISOR}` to adapt this to the kernel they want
to use, similarly to what's already done for the go runtime.

By doing this we also ensure that no changes in the configuration file
will be required to run runtime-rs, with dragonball, as part of our CI
or as part of kata-deploy.

Fixes: #6290

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-03-13 13:47:20 +01:00
James O. D. Hunt
ae9be1d94b
Merge pull request #5840 from tzY15368/feat-runtimers-direct-vol
Implement direct-volume commands handler for shim-mgmt
2023-03-13 07:58:40 +00:00
Chelsea Mafrica
4b877b0a3e
Merge pull request #6426 from openanolis/runtime-rs-resize-pty
bugfix: modify tty_win info in runtime when handling ResizePtyRequest
2023-03-10 14:08:41 -08:00
Sidhartha Mani
a6c67a161e
runtime: add support for ephemeral mounts to occupy entire sandbox memory
On hotplug of memory as containers are started, remount all ephemeral mounts with size option set to the total sandbox memory

Fixes: #6417

Signed-off-by: Sidhartha Mani <sidhartha_mani@apple.com>
2023-03-10 13:36:02 -08:00
James O. D. Hunt
99a4eaa898
Merge pull request #6443 from openanolis/runtime-rs-get-netns
bugfix: add get_ns_path API for Hypervisor
2023-03-10 20:16:22 +00:00
Li Hongyu
844bf053b2 runtime-rs: add the missing default trait
Some structs in the runtime-rs don't implement Default trait.
This commit adds the missing Default.

Fixes: #5463

Signed-off-by: Li Hongyu <lihongyu1999@bupt.edu.cn>
2023-03-10 08:19:56 +00:00
Yushuo
e7bca62c32 bugfix: modify tty_win info in runtime when handling ResizePtyRequest
Currently, we only create the new exec process in runtime, this will cause error
when the following requests needing to be handled:

- Task: exec process
- Task: resize process pty
- ...

The agent do not do_exec_process when we handle ExecProcess, thus we can not find
any process information in the guest when we handle ResizeProcessPty. This will
report an error.

In this commit, the handling process is modified to the:
* Modify process tty_win information in runtime
* If the exec process is not running, we just return. And the truly pty_resize will
happen when start_process

Fixes: #6248

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
2023-03-10 14:33:51 +08:00
Tingzhou Yuan
30e235f0a1 runtime-rs: impl volume-resize trait for sandbox
Implements resize-volume handlers in shim-mgmt,
trait for sandbox and add RPC calls to agent.
Note the actual rpc handler for the resize request is currently not
implemented, refer to issue #3694.

Fixes #5369

Signed-off-by: Tingzhou Yuan <tzyuan15@bu.edu>
2023-03-10 01:27:06 -05:00
Yushuo
e029988bc2 bugfix: add get_ns_path API for Hypervisor
For external hypervisors(qemu, cloud-hypervisor, ...), the ns they launch vm in
is different from internal hypervisor(dragonball). And when we doing CreateContainer
hook, we will rely on the netns path. So we add a get_ns_path API.

Fixes: #6442

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
2023-03-10 13:57:00 +08:00
Tingzhou Yuan
42b8867148 runtime-rs: impl volume-stats trait for sandbox
Implements get-volume-stats trait for sandbox,
handler for shim-mgmt and add RPC calls to
agent. Also added type conversions in trans.rs

Fixes #5369

Signed-off-by: Tingzhou Yuan <tzyuan15@bu.edu>
2023-03-10 00:48:02 -05:00
Sidhartha Mani
16e2c3cc55
agent: implement update_ephemeral_mounts api
- implement update_ephemeral_mounts rpc
- for each mountpoint passed in, remount it with new options

Signed-off-by: Sidhartha Mani <sidhartha_mani@apple.com>
2023-03-06 13:44:14 -08:00
Sidhartha Mani
3896c7a22b
protocol: add updateEphemeralMounts proto
- adds a new rpc call to the agent service named `updateEphemeralMounts`
- this call takes a list of grpc.Storage objects

Signed-off-by: Sidhartha Mani <sidhartha_mani@apple.com>
2023-03-06 13:43:47 -08:00
xuejun-xj
760f78137d dragonball: support pmu on aarch64
This commit adds support for pmu virtualization on aarch64. The
initialization of pmu is in the following order:
1. Receive pmu parameter(vpmu_feature) from runtime-rs to determine the
VpmuFeatureLevel.
2. Judge whether to initialize pmu devices and add pmu device node into
fdt on aarch64, according to VpmuFeatureLevel.

Fixes: #6168

Signed-off-by: xuejun-xj <jiyunxue@linux.alibaba.com>
2023-03-06 18:55:13 +08:00
Fabiano Fidêncio
df35f8f885
Merge pull request #6331 from jepio/jepio/fix-agent-init-cgroups
rustjail: fix cgroup handling in agent-init mode
2023-03-05 20:29:40 +01:00
Fabiano Fidêncio
98d611623f
Merge pull request #6361 from etrunko/main
runtime/Makefile: Fix install-containerd-shim-v2 dependency
2023-03-04 13:47:11 +01:00
Jianyong Wu
395645e1ce runtime: hybrid-mode cause error in the latest nydusd
When update the nydusd to 2.2, the argument "--hybrid-mode" cause
the following error:

thread 'main' panicked at 'ArgAction::SetTrue / ArgAction::SetFalse is defaulted'

Maybe we should remove it to upgrad nydusd

Fixes: #6407
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2023-03-04 12:58:48 +08:00
Chelsea Mafrica
ebe916b372
Merge pull request #6355 from yanggangtony/fix-wrong-notes
fix wrong notes for func GetSandboxesStoragePathRust()
2023-03-03 07:55:54 -08:00
Zhongtao Hu
60bb9d114a
Merge pull request #6399 from yipengyin/fix-cleanup
fix(runtime-rs): add exited state to ensure cleanup
2023-03-03 17:41:16 +08:00
Chao Wu
6fc4c8b099
Merge pull request #5788 from openanolis/runtime-rs-ocihook
runtime-rs: add oci hook support
2023-03-03 01:06:21 +08:00
Yipeng Yin
8030e469b2 fix(runtime-rs): add exited state to ensure cleanup
Set process status to exited at end of io wait, which indicate process
exited only, but stop process has not been finished. Otherwise, the
cleanup_container will be skipped.

Fixes: #6393

Signed-off-by: Yipeng Yin <yinyipeng@bytedance.com>
2023-03-02 18:14:20 +08:00
Chao Wu
572c385774
Merge pull request #6269 from openanolis/chao/update_dragonball_version
Dragonball: update dependencies
2023-03-02 17:15:39 +08:00
Chao Wu
dd2713521e Dragonball: update dependencies
Since rust-vmm and dragonball-sandbox has introduced several updates
such as vPMU support for aarch64, we also need to update Dragonball
dependencies to include those changes.

Update:
virtio-queue to v0.6.0
kvm-ioctls to v0.12.0
dbs-upcall to v0.2.0
dbs-virtio-devices to v0.2.0
kvm-bindings to v0.6.0

Also, several aarch64 features are updated because of dependencies
changes:
1. update vcpu hotplug API.
2. update vpmu related API.
3. adjust unit test cases for aarch64 Dragonball.

fixes: #6268

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2023-03-02 14:53:04 +08:00
Chao Wu
2934ab4a3c
Merge pull request #6380 from Christopher-C-Robinson/#6256-typo-fix
src: Fixed typo mod.rs
2023-03-02 14:31:33 +08:00
Domesticcadiz
fea7e8816f runtime-rs: Fixed typo mod.rs
Fixed the typo in comment in the delete method located in mod.rs file.

Fixes: #6256.

Signed-off-by: Domesticcadiz <christopher.cadiz.robinson@gmail.com>
2023-03-01 18:03:41 -06:00
Eduardo Lima (Etrunko)
a9e2fc8678 runtime/Makefile: Fix install-containerd-shim-v2 dependency
$ make install
make: *** No rule to make target 'containerd-shim-kata-v2', needed by 'install-containerd-shim-v2'.  Stop.

Spotted when building kata-runtime with a different name for
SHIMV2_OUTPUT. For instance, trying to keep different runtime binaries
installed at the same time, one from master and another from lets say,
the CCv0 branch, with the following small change applied.

diff --git a/src/runtime/Makefile b/src/runtime/Makefile
index 95efaff78..2bab9eb75 100644
--- a/src/runtime/Makefile
+++ b/src/runtime/Makefile
@@ -231,7 +231,7 @@ SED = sed

 CLI_DIR = cmd
 SHIMV2 = containerd-shim-kata-v2
-SHIMV2_OUTPUT = $(bCURDIR)/$(SHIMV2)
+SHIMV2_OUTPUT = $(CURDIR)/$(SHIMV2)-ccv0
 SHIMV2_DIR = $(CLI_DIR)/$(SHIMV2)

 MONITOR = kata-monitor

Fixes: #6398

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2023-03-01 15:57:30 -03:00
yanggang
b6880c60d3
logging: Correct the code notes
Fix wrong notes for func GetSandboxesStoragePathRust()

Fixes: #6394

Signed-off-by: yanggang <gang.yang@daocloud.io>
2023-03-01 19:20:25 +08:00
Yushuo
12cfad4858 runtime-rs: modify the transfer to oci::Hooks
In this commit, we have done:
    * modify the tranfer process from grpc::Hooks to oci::Hooks, so the code
      can be more clean
    * add more tests for create_runtime, create_container, start_container hooks

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
2023-03-01 10:35:10 +08:00
Steve Horsman
785310fe18
Merge pull request #6368 from yoheiueda/dir-perm
agent: don't set permission of existing directory in copy_file
2023-02-28 14:48:10 +00:00
Chelsea Mafrica
703589c279
Merge pull request #6369 from XDTG/6082/Fix-path-check-bypassed
runtime: use filepath.Clean() to clean the mount path
2023-02-27 17:24:50 -08:00
Bo Chen
ba9227184e
Merge pull request #6376 from likebreath/0224/clh_v30.0
Upgrade to Cloud Hypervisor v30.0
2023-02-27 11:48:52 -08:00
Yushuo
2c4428ee02 runtime-rs: move pre-start hooks to sandbox_start
In some cases, network endpoints will be configured through Prestart
Hook. So network endpoints may need to be added(hotpluged) after vm
is started and also Prestart Hook is executed.

We move pre-start hook functions' execution to sandbox_start to allow
hooks running between vm_start and netns_scan easily, so that the
lifecycle API can be cleaner.

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
2023-02-27 21:56:43 +08:00
Yushuo
e80c9f7b74 runtime-rs: add StartContainer hook
StartContainer will be execute in guest container namespace in Kata.
The Hook Path of this kind of hook is also in guest container namespace.

StartContainer is executed after start operation is called, and it
should be executed before user-specific command is executed.

Fixes: #5787

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
2023-02-27 21:56:43 +08:00
Yushuo
977f281c5c runtime-rs: add CreateContainer hook support
CreateContainer hook is one kind of OCI hook. In kata, it will be
executed after VM is started, before container is created, and after
CreateRuntime is executed.

The hook path of CreateContainer hook is in host runtime namespace, but
it will be executed in host vmm namespace.

Fixes: #5787

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
2023-02-27 21:56:43 +08:00
Yushuo
875f2db528 runtime-rs: add oci hook support
According to the runtime OCI Spec, there can be some hook
operations in the lifecycle of the container. In these hook
operations, the runtime can execute some commands. There are different
points in time in the container lifecycle  and different hook types
can be executed.

In this commit, we are now supporting 4 types of hooks(same in
runtime-go): Prestart hook, CreateRuntime hook, Poststart hook and
Poststop hook.

Fixes: #5787

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
2023-02-27 21:56:43 +08:00
Bin Liu
e90989b16b
Merge pull request #6314 from openanolis/static_doc
feat(runtime): make static resource management consistent with 2.0
2023-02-27 16:43:27 +08:00
Bo Chen
3ac6f29e95 runtime: clh: Re-generate the client code
This patch re-generates the client code for Cloud Hypervisor v30.0.
Note: The client code of cloud-hypervisor's OpenAPI is automatically
generated by openapi-generator.

Fixes: #6375

Signed-off-by: Bo Chen <chen.bo@intel.com>
2023-02-24 10:20:29 -08:00
Jeremi Piotrowski
192df84588 agent: always use cgroupfs when running as init
The logic to decide which cgroup driver is used is currently based on the
cgroup path that the host provides. This requires host and guest to use the
same cgroup driver. If the guest uses kata-agent as init, then systemd can't be
used as the cgroup driver. If the host requests a systemd cgroup, this
currently results in a rustjail panic:

  thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: I/O error: No such file or directory (os error 2)

  Caused by:
      No such file or directory (os error 2)', rustjail/src/cgroups/systemd/manager.rs:44:51
  stack backtrace:
     0:     0x7ff0fe77a793 - std::backtrace_rs::backtrace::libunwind::trace::h8c197fa9a679d134
                                 at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
     1:     0x7ff0fe77a793 - std::backtrace_rs::backtrace::trace_unsynchronized::h9ee19d58b6d5934a
                                 at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
     2:     0x7ff0fe77a793 - std::sys_common::backtrace::_print_fmt::h4badc450600fc417
                                 at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:65:5
     3:     0x7ff0fe77a793 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::had334ddb529a2169
                                 at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:44:22
     4:     0x7ff0fdce815e - core::fmt::write::h1aa7694f03e44db2
                                 at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/fmt/mod.rs:1209:17
     5:     0x7ff0fe74e0c4 - std::io::Write::write_fmt::h61b2bdc565be41b5
                                 at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/io/mod.rs:1682:15
     6:     0x7ff0fe77cd3f - std::sys_common::backtrace::_print::h4ec69798b72ff254
                                 at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:47:5
     7:     0x7ff0fe77cd3f - std::sys_common::backtrace::print::h0e6c02048dec3c77
                                 at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:34:9
     8:     0x7ff0fe77c93f - std::panicking::default_hook::{{closure}}::hcdb7e705dc37ea6e
                                 at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:267:22
     9:     0x7ff0fe77d9b8 - std::panicking::default_hook::he03a933a0f01790f
                                 at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:286:9
    10:     0x7ff0fe77d9b8 - std::panicking::rust_panic_with_hook::he26b680bfd953008
                                 at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:688:13
    11:     0x7ff0fe77d482 - std::panicking::begin_panic_handler::{{closure}}::h559120d2dd1c6180
                                 at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:579:13
    12:     0x7ff0fe77d3ec - std::sys_common::backtrace::__rust_end_short_backtrace::h36db621fc93b005a
                                 at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:137:18
    13:     0x7ff0fe77d3c1 - rust_begin_unwind
                                 at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:575:5
    14:     0x7ff0fda52ee2 - core::panicking::panic_fmt::he7679b415d25c5f4
                                 at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/panicking.rs:65:14
    15:     0x7ff0fda53182 - core::result::unwrap_failed::hb71caff146724b6b
                                 at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/result.rs:1791:5
    16:     0x7ff0fe5bd738 - <rustjail::cgroups::systemd::manager::Manager as rustjail::cgroups::Manager>::apply::hd46958d9d807d2ca
    17:     0x7ff0fe606d80 - <rustjail::container::LinuxContainer as rustjail::container::BaseContainer>::start::{{closure}}::h1de806d91fcb878f
    18:     0x7ff0fe604a76 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h1749c148adcc235f
    19:     0x7ff0fdc0c992 - kata_agent::rpc::AgentService::do_create_container::{{closure}}::{{closure}}::hc1b87a15dfdf2f64
    20:     0x7ff0fdb80ae4 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h846a8c9e4fb67707
    21:     0x7ff0fe3bb816 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h53de16ff66ed3972
    22:     0x7ff0fdb519cb - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h1cbece980286c0f4
    23:     0x7ff0fdf4019c - <tokio::future::poll_fn::PollFn<F> as core::future::future::Future>::poll::hc8e72d155feb8d1f
    24:     0x7ff0fdfa5fd8 - tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut::h0a407ffe2559449a
    25:     0x7ff0fdf033a1 - tokio::runtime::task::raw::poll::h1045d9f1db9742de
    26:     0x7ff0fe7a8ce2 - tokio::runtime::scheduler::multi_thread::worker::Context::run_task::h4924ae3464af7fbd
    27:     0x7ff0fe7afb85 - tokio::runtime::task::raw::poll::h5c843be39646b833
    28:     0x7ff0fe7a05ee - std::sys_common::backtrace::__rust_begin_short_backtrace::ha7777c55b98a9bd1
    29:     0x7ff0fe7a9bdb - core::ops::function::FnOnce::call_once{{vtable.shim}}::h27ec83c953360cdd
    30:     0x7ff0fe7801d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hed812350c5aef7a8
                                 at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/alloc/src/boxed.rs:1987:9
    31:     0x7ff0fe7801d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc7df8e435a658960
                                 at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/alloc/src/boxed.rs:1987:9
    32:     0x7ff0fe7801d5 - std::sys::unix:🧵:Thread:🆕:thread_start::h575491a8a17dbb33
                                 at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys/unix/thread.rs:108:17

Forward the value of "init_mode" to AgentService, so that we can force cgroupfs
when systemd is unavailable.

Fixes: #5779
Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2023-02-24 14:02:11 +01:00
Jeremi Piotrowski
b0691806f1 agent: determine value of use_systemd_cgroup before LinuxContainer::new()
Right now LinuxContainer::new() gets passed a CreateOpts struct, but then
modifies the use_systemd_cgroup field inside that struct. Pull the cgroups path
parsing logic into do_create_container, so that CreateOpts can be immutable in
LinuxContainer::new. This is just moving things around, there should be no
functional changes.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2023-02-24 13:46:37 +01:00
XDTG
dc86d6dac3 runtime: use filepath.Clean() to clean the mount path
Fix path check bypassed issuse introduced by #6082,
use filepath.Clean() to clean path before check

Fixes: #6082

Signed-off-by: XDTG <click1799@163.com>
2023-02-24 15:48:09 +08:00
Yohei Ueda
c4ef5fd325
agent: don't set permission of existing directory
This patch fixes the issue that do_copy_file changes
the directory permission of the parent directory of
a target file, even when the parent directory already
exists.

Fixes #6367

Signed-off-by: Yohei Ueda <yohei@jp.ibm.com>
2023-02-24 16:43:59 +09:00
Feng Wang
cbe6ad9034 runtime: support non-root for clh
This change enables to run cloud-hypervisor VMM using a non-root user
when rootless flag is set true in the configuration

Fixes: #2567

Signed-off-by: Feng Wang <fwang@confluent.io>
2023-02-22 13:57:09 -08:00
GabyCT
a0b1f81867
Merge pull request #5958 from Apokleos/kata-ctl-exec
kata-ctl/exec: add new command exec to enter guest VM.
2023-02-22 12:07:44 -06:00
David Esparza
5e2fe5f932
Merge pull request #6332 from jodh-intel/runtime-rs-ch-config-convert
runtime-rs: Improve Cloud Hypervisor config handling
2023-02-22 10:15:50 -06:00
GabyCT
5c6e56931f
Merge pull request #6312 from Amulyam24/virtiofsd-fix
virtiofsd: update to a valid path on ppc64le
2023-02-22 08:57:51 -06:00
James O. D. Hunt
3483272bbd runtime-rs: ch: Enable initrd usage
Allow an initrd/initramfs image to be used with Cloud Hypervisor, which
is handled differently to the default rootfs image type.

Fixes: #6335.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2023-02-22 10:55:01 +00:00
James O. D. Hunt
fbee6c820e runtime-rs: Improve Cloud Hypervisor config handling
Replace `cloud_hypervisor_vm_create_cfg()` with a set of `TryFrom` trait
implementations in the new CH specific `convert.rs` to allow the generic
`Hypervisor` configuration to be converted into the CH specific
`VmConfig` type.

Note that device configuration is not currently handled in `convert.rs`
(it's handled in `inner_device.rs`).

This change removes the old hard-coded CH specific configuration.

Fixes: #6203.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2023-02-22 10:48:05 +00:00
Chao Wu
578f2e7c2e
Merge pull request #6080 from openanolis/rem
runtime-rs: cleanup kata host share path
2023-02-22 17:45:24 +08:00
Zhongtao Hu
4f20cb7ced
Merge pull request #6325 from HerlinCoder/herlincoder/config-manager
dragonball: config_manager: preserve device when update
2023-02-21 17:51:41 +08:00
Jeremi Piotrowski
ad8968c8d9 rustjail: print type of cgroup manager
Since the cgroup manager is wrapped in a dyn now, the print in
LinuxContainer::new has been useless and just says "CgroupManager". Extend the
Debug trait for 'dyn Manager' to print the type of the cgroup manager so that
it's easier to debug issues.

Fixes: #5779
Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2023-02-21 10:07:03 +01:00
Helin Guo
ced3c99895 dragonball: config_manager: preserve device when update
DeviceConfigInfo contains config and device, so when we want to do
update we could simply update config part of the info, and device would
not be changed during update.

Fixes: #6324

Signed-off-by: Helin Guo <helinguo@linux.alibaba.com>
2023-02-20 14:34:09 +08:00
Tim Zhang
da8a6417aa runtime-rs: remove all remaining unsafe impl
Fixes: #6307

Signed-off-by: Tim Zhang <tim@hyper.sh>
2023-02-20 14:29:59 +08:00
Tim Zhang
0301194851 dragonball: use crossbeam_channel in VmmService instead of mpsc::channel
Because crossbeam_channel has more features and better performance than
mpsc::channel and finally rust replace its channel implementation with
crossbeam_channel on version 1.67

Signed-off-by: Tim Zhang <tim@hyper.sh>
2023-02-20 14:29:57 +08:00
Ji-Xinyou
919d19f415 feat(runtime): make static resource management consistent with 2.0
* add doc in the configuration
* make entry consistent with 2.0

Fixes: #6313
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2023-02-17 21:36:56 +08:00
Bin Liu
b7fe29f033
Merge pull request #6308 from Tim-Zhang/remove-unnecessary-send-and-sync
runtime-rs: remove unnecessary Send/Sync trait implement
2023-02-17 19:53:54 +08:00
Amulyam24
e84af6a620 virtiofsd: update to a valid path on ppc64le
Currently the symbolic link for virtiofsd which is used as
a valid path is not updated on every CI run. Fix it by
using the actual path of installation.

Fixes: #6311

Signed-off-by: Amulyam24 <amulmek1@in.ibm.com>
2023-02-17 16:22:39 +05:30
Tim Zhang
95e3364493 runtime-rs: remove unnecessary Send/Sync trait implement
Send and Sync are automatically derived traits,
if a type is composed entirely of Send or Sync types, then it is Send or Sync.
Almost all primitives are Send and Sync,
so we don't need to implement them manually most of the time.

Fixes: #6307

Signed-off-by: Tim Zhang <tim@hyper.sh>
2023-02-17 11:51:13 +08:00
Fabiano Fidêncio
be40683bc5 runtime-rs: Add a generic powerpc64le-options.mk
There's a check in the runtime-rs Makefile that basically checks whether
the `arch/$arch-options.mk` exists or not and, if it doesn't, the build
is just aborted.

With this in mind, let's create a generic powerpc64le-options.mk file
and not bail when building for this architecture.

Fixes: #6142

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-02-16 16:29:24 +01:00
Fabiano Fidêncio
c1602c848a
Merge pull request #6300 from openanolis/footloose
runtime-rs: handle sys_dir bind volume
2023-02-16 12:53:15 +01: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
Yushuo
07802a19dc runtime-rs: handle sys_dir bind volume
For some cases, users will mount system directories as bind volume.
We should not bind mount these kind of directories in the host as it does
not make sense.

Fixes: #6299

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
2023-02-16 15:45:33 +08:00
Fupan Li
04e930073c sandbox: set the dns for the sandbox
The rust agent had supported to set the guest dns
server in start sandbox request, thus add the dns
in the runtime side.

Fixes:#6286

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2023-02-16 11:25:02 +08:00
Fupan Li
32ebe1895b agent: fix the issue of creating the dns file
We should make sure the dns's source file's parent
directory exist, otherwise, it would failed to create
the file directly.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2023-02-16 11:24:54 +08:00
Peng Tao
139ad8e95f
Merge pull request #6201 from jodh-intel/runtime-rs-add-cloud-hypervisor
runtime-rs: Add basic CH implementation
2023-02-16 11:23:04 +08:00
James O. D. Hunt
bbc733d6c8 docs: runtime-rs: Add CH status details
Add a few details about the current state of the Cloud Hypervisor (CH)
runtime-rs external hypervisor implementation with pointers to the
appropriate issues.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2023-02-14 15:38:46 +00:00
James O. D. Hunt
37b594c0d2 runtime-rs: Add basic CH implementation
Add a basic runtime-rs `Hypervisor` trait implementation for Cloud
Hypervisor (CH).

> **Notes:**
>
> - This only supports a default Kata configuration for CH currently.
>
> - Since this feature is still under development, `cargo` features have
>   been added to enable the feature optionally. The default is to not enable
>   currently since the code is not ready for general use.
>
>   To enable the feature for testing and development, enable the
>   `cloud-hypervisor` feature in the `virt_container` crate and enable the
>   `cloud-hypervisor` feature for its `hypervisor` dependency.

Fixes: #5242.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2023-02-14 15:38:39 +00:00
James O. D. Hunt
5f6d747e6d
Merge pull request #6272 from cmaf/tracing-clh-returnctx-startVM
runtime: tracing: Fix missing ctx return
2023-02-14 08:17:45 +00:00
Bin Liu
e812c5ce66
Merge pull request #6076 from zhaojizhuang/reconnect
runtime: add reconnect timeout for vhost user block
2023-02-14 10:39:20 +08:00
Archana Shinde
7b4e5751ca
Merge pull request #5007 from larrydewey/update-rpb-main
SEV: Update ReducedPhysBits
2023-02-13 14:56:38 -08:00
Hyounggyu Choi
87d197ef20
Merge pull request #6143 from fidencio/topic/only-build-runtime-rs-for-x86_64-and-arm
shim-v2/build.sh: Only build runtime-rs for the supported arches
2023-02-13 23:43:10 +01:00
Chelsea Mafrica
c453919911 runtime: tracing: Fix missing ctx return
Normally we return the context when creating a trace span so that the
ordering of spans w.r.t. calls is maintained in tracing output. Add
missing context for StartVM() for Cloud Hypervisor.

Fixes #6271

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
2023-02-13 12:37:52 -08:00
Chelsea Mafrica
036d3a4088
Merge pull request #5920 from cmaf/kata-ctl-check-cpu-unit-tests-1
kata-ctl: Expand unit tests for CPU check
2023-02-13 12:21:58 -08:00
Hyounggyu Choi
4139d68d51 runtime-rs: Include target install in conditional branch
A Makefile target `install` should be included in the conditional branch
as default and test.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2023-02-13 21:13:32 +01:00
James O. D. Hunt
545151829d kata-types: Add Cloud Hypervisor (CH) definitions
Implement `ConfigPlugin` trait for Cloud Hypervisor (CH).

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2023-02-13 10:25:29 +00:00
zhaojizhuang
ca02c9f512 runtime: add reconnect timeout for vhost user block
Fixes: #6075
Signed-off-by: zhaojizhuang <571130360@qq.com>
2023-02-13 14:33:46 +08:00
Zhongtao Hu
2dd2421ad0 runtime-rs: cleanup kata host share path
cleanup the /run/kata-containers/shared/sandboxes/pid path

Fixes:#5975
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2023-02-13 13:07:07 +08:00
Bin Liu
95602c8c08
Merge pull request #5999 from yaoyinnan/5998/feat/cgroup-metrics
runtime: support cgroup v2 metrics marshal guest metrics
2023-02-11 19:26:24 +08:00
Bin Liu
8a9392fd9d
Merge pull request #6188 from yahaa/Typo-fix
Typo: change tabs in comment to spaces
2023-02-11 11:19:11 +08:00
Bin Liu
ecbd94d80c
Merge pull request #6064 from yaoyinnan/6063/feat/rootfs-erofs
rootfs: support EROFS filesystem
2023-02-11 11:10:23 +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
Larry Dewey
67b8f0773f SEV: Update ReducedPhysBits
Updating this field, as `cpuid` provides host level data, which is not
what a guest would expect for Reduced Phsycial Bits. In almost all
cases, we should be using `1` for the value here.

Amend: Adding unit test change.

Fixes: #5006

Signed-off-by: Larry Dewey <larry.dewey@amd.com>
2023-02-10 13:19:33 -06:00
yaoyinnan
bdf20b5d26 rootfs: support EROFS filesystem
For kata containers, rootfs is used in the read-only way.
EROFS can noticably decrease metadata overhead.

On the basis of supporting the EROFS file system, it supports using the config parameter to switch the file system used by rootfs.

Fixes: #6063

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
2023-02-11 00:44:13 +08:00
GabyCT
86501d5f6f
Merge pull request #6200 from gkurz/improve-appendFDs-doc
runtime: Improve documentation of appendFDs
2023-02-09 15:50:37 -06:00
yaoyinnan
01765e1734 runtime: support cgroup v2 metrics marshal guest metrics
Support to use cgroup v2 metrics marshal guest metrics.

Fixes: #5998

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
2023-02-09 19:14:09 +08:00
yaoyinnan
49326fe4e1 fix(clippy): fix hypervisor clippy checks
Fix hypervisor clippy checks.

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
2023-02-09 14:32:27 +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
Bin Liu
407d3146e6
Merge pull request #6234 from UiPath/fix-clh-timeout
clh: Enforce API timeout only for vm.boot request
2023-02-08 21:33:56 +08:00
Alexandru Matei
ac64b021a6 clh: Enforce API timeout only for vm.boot request
launchClh already has a timeout of 10seconds for launching clh, e.g.
if launchClh or setupVirtiofsDaemon takes a few seconds the context's
deadline will already be expired by the time it reaches bootVM

Fixes #6240
Signed-off-by: Alexandru Matei <alexandru.matei@uipath.com>
2023-02-08 11:14:51 +02:00
Bin Liu
56071c6e7b virtiofsd: change cache mod to const
Change cache mod from literal to const and place them in one place.

Also set default cache mode from `none` to `never` in
`pkg/katautils/config-settings.go.in`.

Fixes: #6151

Signed-off-by: Bin Liu <bin@hyper.sh>
2023-02-08 15:06:52 +08:00
Zhongtao Hu
2752225360
Merge pull request #6193 from jongwu/cgroup_del_err
runtime-rs: ignor "no such process" error when delete cgroup for a thread to let it go
2023-02-08 10:30:12 +08:00
Bin Liu
71a3b73cb0
Merge pull request #6223 from d3c3mber/rm-unused-shim-config
runtime: remove not used shim configurations
2023-02-08 10:00:52 +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
Jianyong Wu
ab59a65c92 runtime-rs: neglect a certain error when delete cgroup
Delete cgroup for a thread which may exit can lead to panic. Just
neglect that error is harmless also avoid this failure.

Fixes: #6192
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2023-02-07 18:09:31 +08:00
wllenyj
9a01d4e446 dragonball: add more unit test for virtio-blk device.
Added more unit tests for virtio-blk device.

Fixes: #4899

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2023-02-07 17:16:11 +08:00
d3c3mber
390916b33c runtime: remove not used shim configurations
ShimPath and ShimDebug are not needed anymore.

Fixes: #6147

Signed-off-by: d3c3mber <tangbo_gl_2022@163.com>
2023-02-07 14:06:12 +08:00
joannejchen
9794c52c65 improvement: Fix naming conventions for span name and log subsystem
Normally, the span name should be the same as the function name, and the log subsystem should not contain spaces.

Fixes #6153

Signed-off-by: joannejchen <chenjjoanne@gmail.com>
2023-02-06 08:25:49 -06:00
Bin Liu
df93439c3b
Merge pull request #6009 from openanolis/dragonball/add_cpu_resize
Dragonball: add cpu resize ability
2023-02-05 19:54:08 +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
GabyCT
7fc35f19eb
Merge pull request #6056 from jongwu/perm_deny
arm64/CI: fix unit test failure on arm64
2023-02-03 10:53:38 -06:00
Jianyong Wu
59f104c022 runtime: skip unit test that fail regularly on aarch64
There are lots of unit test cases fails regularly on aarch64, including
TestIOCopy, create_tmpfs. Temporarily skip it for now and enable it
after them get fixed.

Fixes: #6194
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2023-02-03 11:34:39 +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
Chao Wu
57c5e5629b Dragonball: add cpu resize ability
Add cpu resize ability upon upcall communication channel. Runtime could
use ResizeVcpu VmmAction and pass the desired vCPU number to the
Dragonball hypervisor.
Dragonball will trigger the device manager service in guest kernel's
upcall server to do cpu resize.

Fixes: #6008
Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2023-02-03 00:26:33 +08:00
Greg Kurz
3c48f2202c runtime: Improve documentation of appendFDs
The cmd.ExtraFiles feature that is used to implement appendFDs takes an
array of arbitray file descriptors and internally renumbers them to be
consecutive starting from 3, using dup2().

This isn't especially obvious : document it for the sake of clarity.

Fixes #6199

Signed-off-by: Greg Kurz <groug@kaod.org>
2023-02-02 12:52:10 +01:00
yahaa
e071d9251f Typo: change tabs in comment to spaces
Fixes: #6150

Signed-off-by: yahaa <1477765176@qq.com>
2023-02-02 12:08:33 +08:00
Peng Tao
a34f36f8f4
Merge pull request #6149 from openanolis/fix_kata_runtime
runtime:fix stat uds path
2023-02-02 11:00:07 +08:00
Chao Wu
c282a1c709
Merge pull request #5616 from wllenyj/dragonball-ut-5
Built-in Sandbox: add more unit tests for dragonball. Part 5
2023-01-31 21:12:05 +08:00
Greg Kurz
334c4b8bdc runtime: Drop QEMU log file support
The QEMU log file is essentially about fine grain tracing of QEMU
internals and mostly useful for developpers, not production. Notably,
the log file isn't limited in size, nor rotated in any way. It means
that a container running in the VM could possibly flood the log file
with a guest triggerable trace. For example, on openshift, the log
file is supposed to reside on a per-VM 14 GiB tmpfs mount. This means
that each pod running with the kata runtime could potentially consume
this amount of host RAM which is not acceptable.

Error messages are best collected from QEMU's stderr as kata is doing
now since PR #5736 was merged. Drop support for the QEMU log file
because it doesn't bring any value but can certainly do harm.

Fixes #6173

Signed-off-by: Greg Kurz <groug@kaod.org>
2023-01-31 09:20:29 +01:00
wllenyj
510798155d dragonball: Improve test cases
The same EpollManager should be used instead of creating two.

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2023-01-31 10:51:51 +08:00
wllenyj
dc90c6e30b dragonball: add more unit test for vm
Added more unit tests for vm module.

Fixes: #4899

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2023-01-31 10:51:51 +08:00
Fabiano Fidêncio
c071355359 runtime-rs: Improve s390x error message
Nothing much to add, let's just make the message more clear.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-01-30 20:32:07 +01:00
Fabiano Fidêncio
4e2db96ef7 runtime-rs: Don't try to build on Power
As done for s390x, let's just skip the runtime-rs build for Power.

Fixes: #6142

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-01-30 20:32:07 +01:00
Zhongtao Hu
c1dd9b9777
Merge pull request #6023 from openanolis/missing_config
runtime-rs: add missing config section for share-fs
2023-01-30 15:45:22 +08:00
Bin Liu
653e00dff8
Merge pull request #6146 from zhaojizhuang/add-hmp
runtime: Add hmp for qemu
2023-01-30 15:43:53 +08:00
Peng Tao
de45f62096
Merge pull request #6081 from openanolis/chao/update_upcall_doc
upcall: add document for upcall
2023-01-30 12:03:11 +08:00
Zhongtao Hu
1e531b44dc runtime:fix stat uds path
os.Stat("unix:///run/vc/sbs/sid/shim-monitor.sock") will fail,
should be os.Stat("/run/vc/sbs/sid/shim-monitor.sock")

Fixes:#6148
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2023-01-29 15:08:13 +08:00
zhaojizhuang
9092c23a2e runtime: Add hmp for qemu
Fixes: #6092
Signed-off-by: zhaojizhuang <571130360@qq.com>
2023-01-29 14:22:04 +08:00
Greg Kurz
af125b1498
Merge pull request #5736 from gkurz/no-qemu-daemonize
runtime: Start QEMU undaemonized and get logs
2023-01-27 16:33:48 +01:00
Greg Kurz
39fe4a4b6f runtime: Collect QEMU's stderr
LaunchQemu now connects a pipe to QEMU's stderr and makes it
usable by callers through a Go io.ReadCloser object. As
explained in [0], all messages should be read from the pipe
before calling cmd.Wait : introduce a LogAndWait helper to handle
that.

Fixes #5780

Signed-off-by: Greg Kurz <groug@kaod.org>
2023-01-24 23:09:17 +01:00
Greg Kurz
a5319c6be6 runtime: Start QEMU undaemonized
QEMU has always been started daemonized since the beginning. I
could not find any justification for that though, but it certainly
introduces a problem : QEMU stops logging errors when started this
way, which isn't accaptable from a support standpoint. The QEMU
community discourages the use of -daemonize ; mostly because
libvirt, QEMU's primary consummer, doesn't use this option and
prefers getting errors from QEMU's stderr through a pipe in order
to enforce rollover.

Now that virtcontainers knows how to start QEMU with a pre-
established QMP connection, let's start QEMU without -daemonize.
This requires to handle the reaping of QEMU when it terminates.
Since cmd.Wait() is blocking, call it from a goroutine.

Signed-off-by: Greg Kurz <groug@kaod.org>
2023-01-24 23:09:11 +01:00
Greg Kurz
bf4e3a618f runtime: Launch QEMU with cmd.Start()
LaunchCustomQemu() currently starts QEMU with cmd.Run() which is
supposed to block until the child process terminates. This assumes
that QEMU daemonizes itself, otherwise LaunchCustomQemu() would
block forever. The virtcontainers package indeed enables the
Daemonize knob in the configuration but having such an implicit
dependency on a supposedly configurable setting is ugly and fragile.

cmd.Run() is :

func (c *Cmd) Run() error {
	if err := c.Start(); err != nil {
		return err
	}
	return c.Wait()
}

Let's open-code this : govmm calls cmd.Start() and returns the
cmd to virtcontainers which calls cmd.Wait().

If QEMU doesn't start, e.g. missing binary, there won't be any
errors to collect from QEMU output. Just drop these lines in govmm.
Similarily there won't be any log file to read from in virtcontainers.
Drop that as well.

Signed-off-by: Greg Kurz <groug@kaod.org>
2023-01-24 23:09:11 +01:00
Greg Kurz
8a1723a5cb runtime: Pre-establish the QMP connection
Running QEMU daemonized ensures that the QMP socket is ready to
accept connections when LaunchQemu() returns. In order to be
able to run QEMU undaemonized, let's handle that part upfront.
Create a listener socket and connect to it. Pass the listener
to QEMU and pass the connected socket to QMP : this ensures
that we cannot fail to establish QMP connection and that we
can detect if QEMU exits before accepting the connection.
This is basically what libvirt does.

Signed-off-by: Greg Kurz <groug@kaod.org>
2023-01-24 23:09:11 +01:00
Greg Kurz
8a4f08cb0f govmm: Optionally pass QMP listener to QEMU
QEMU's -qmp option can be passed the file descriptor of a socket that
is already in listening mode. This is done with by passing `fd=XXX`
to `-qmp` instead of a path. Note that these two options are mutually
exclusive : QEMU errors out if both are passed, so we check that as
well in the validation function.

While here add the `path=` stanza in the path based case for clarity.

Signed-off-by: Greg Kurz <groug@kaod.org>
2023-01-24 23:08:48 +01:00
Greg Kurz
219bb8e7d0 govmm: Optionally start QMP with a pre-configured connection
When QEMU is launched daemonized, we have the guarantee that the
QMP socket is available. In order to launch a non-daemonized QEMU,
the QMP connection should be created before QEMU is started in order
to avoid a race. Introduce a variant of QMPStart() that can use such
an existing connection.

Signed-off-by: Greg Kurz <groug@kaod.org>
2023-01-24 19:16:47 +01:00
GabyCT
421a33f846
Merge pull request #6096 from dcantah/kataruntime-use_hyp_consts
runtime: Use consts in `kata-runtime check`
2023-01-18 10:54:42 -06:00
Bin Liu
083facd5ae
Merge pull request #5256 from Yuan-Zhuo/fix-agent-metrics
agent: Eliminate unnecessary metrics
2023-01-18 11:43:37 +08:00
Peng Tao
7d1a604bad
Merge pull request #6060 from ls-ggg/6055/service.mu-deadlock
runtime:all APIs are hang in the service.mu
2023-01-18 10:50:00 +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
Danny Canter
ba87e0afea runtime: Use consts in kata-runtime check
Fixes: #6095

We're already importing the virtcontainers package so might as well
use the constants for the hypervisor types we're checking against instead
of typing the names out in the switch cases.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-01-17 06:55:36 -08:00
Chao Wu
9f490d16fe upcall: add document for upcall
In order for users to get better understand of upcall features, we add
this document for upcall to illustrate what is upcall and how to enable
upcall.

fixes: #6054
Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2023-01-17 14:53:47 +08:00
Bin Liu
790f45190b
Merge pull request #6074 from zhaojizhuang/enablevhostuserstore
runtime: paas enablevhostuserstore annotation to hypervisor config
2023-01-17 11:43:43 +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
Tim Zhang
20196048bf
Merge pull request #6030 from liubin/fix/6029-use-system-hugepagesize
runtime: use system pagesize for hugepage test
2023-01-16 16:57:55 +08:00
Fupan Li
a1a7ed98df
Merge pull request #6040 from liubin/fix/6039-update-cgroup-rs
dependency: update cgroups-rs
2023-01-16 16:51:41 +08:00
ls
69fc8de712 runtime:all APIs are hang in the service.mu
When the vmm process exits abnormally, a goroutine sets s.monitor
to null in the 'watchSandbox' function without getting service.mu,
This will cause another goroutine to block when sending a message
to s.monitor, and it holds service.mu, which leads to a deadlock.
For example, the wait function in the file
.../pkg/containerd-shim-v2/wait.go will send a message to s.monitor
after obtaining service.mu, but s.monitor may be null at this time

Fixes: #6059

Signed-off-by: ls <335814617@qq.com>
2023-01-16 14:45:37 +08: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
Eric Ernst
807eeaafd0
Merge pull request #6047 from egernst/build-kata-monitor-on-darwin
runtime: Use git rev-parse for the kata-monitor tag
2023-01-13 15:29:00 -08:00
Eric Ernst
3d573ba579
Merge pull request #6050 from egernst/goos-the-vc
virtcontainers: split out linux-specific bits for mount, factory
2023-01-13 15:28:42 -08:00
Eric Ernst
458fe865ea
Merge pull request #6052 from egernst/add-darwin-skeletons
Add darwin skeletons
2023-01-13 13:14:16 -08:00
Eric Ernst
923cd3fda1 virtcontainers: split out Linux parts from mount
Mount handling is often unique in Linux. Let's ensure that the common
parts remain in mount.go, while Linux speific parts are within a linux
file.

Fixes: #6049

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2023-01-13 11:14:56 -08:00
Eric Ernst
54f2b296e3
Merge pull request #6048 from egernst/revendor-netlink
vendor: revendor netlink to get latest
2023-01-13 11:08:47 -08:00
Eric Ernst
f82918f872
Merge pull request #6045 from egernst/fix-6044
Address issues with the initial vCPU pinning functionality
2023-01-13 11:06:42 -08:00
GabyCT
9c6e90fd55
Merge pull request #6043 from GabyCT/topic/fixerrormsg
virtcontainers: Fix misspelling in error message
2023-01-13 09:16:34 -06:00
zhaojizhuang
cf1bae3521 runtime: paas enablevhostuserstore annotation to hypervisor config
Fixes: #6073
Signed-off-by: zhaojizhuang <571130360@qq.com>
2023-01-13 17:07:38 +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
Eric Ernst
60ff230d80 virtcontainers: Split the factory package into Linux and Darwin bits
- split template
- split factory
- add stubs for darwin

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2023-01-12 16:51:28 -08:00
Samuel Ortiz
76437a9721 runtime: Use git rev-parse for the kata-monitor tag
The .git-commit can be a multiple line file, potentially confusing
the Darwin linker for example.

Fixes: #6046

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2023-01-12 16:01:58 -08:00
Samuel Ortiz
a9626682af virtcontainers: resourcecontrol: Add skeleton for Darwin
Cgroups do not exist on Darwin, so use an empty implementation for
resourcecontrol for the time being. In the process, ensure that the
utilized cgroup handling (ie, isSystemdCgroup) is kept in general file,
since we use this to help assess/constrain the container spec we pass to
the guest.

Fixes: #6051

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2023-01-12 15:53:28 -08:00
Samuel Ortiz
ea06fe3afc virtcontainers: Add a Network API skeleton for Darwin
Empty for now.

Fixes: #6051

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2023-01-12 15:53:28 -08:00
Eric Ernst
6ee550e9a5 runtime: vCPUs pinning is sandbox specific, not hypervisor
While at it, make sure we persist this and fix a misc typo.

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2023-01-12 15:44:25 -08:00
Zhongtao Hu
6199b69178 runtime-rs: change cache mode
use never as the cache mode if none is configured

Fixes:#6020
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2023-01-12 18:13:50 +08:00
Zhongtao Hu
a33a22ccd1 runtime-rs: add missing config section for share-fs
add missing config sections for share-fs

Fixes:#6020
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2023-01-12 18:12:37 +08:00
Peng Tao
2b4b825228
Merge pull request #6032 from liubin/fix/6031-add-test-file-to-gitignore
runtime: add test generated file to .gitignore
2023-01-12 15:38:46 +08:00
Peng Tao
4a4232b851
Merge pull request #6037 from bergwolf/github/no-netns
runtime: fix up disable_netns handling
2023-01-12 09:58:24 +08:00
Eric Ernst
e3d3b72fa2 virtcontainers: use resource control for setting CPU affinity
Let's abstract the CPU affinity, instead of calling linux only code from
sandbox.

Fixes: #6044

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2023-01-11 17:55:53 -08:00
Eric Ernst
f137048be3 resource-control: add helper function for setting CPU affinity
Let's abstract the CPU affinity

Fixes: #6044

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2023-01-11 17:55:53 -08:00
Eric Ernst
73216a8104 vendor: revendor netlink to get latest
This'll address issue where netlink couldn't build on Darwin hosts.

Fixes: #6026

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2023-01-11 17:23:15 -08:00
Gabriela Cervantes
fc17d7cc41 virtcontainers: Fix misspelling in error message
This PR fixes a misspelling in the error message when it tries to run
a system without Confidential computing support.

Fixes #6042

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
2023-01-11 21:58:07 +00:00
Peng Tao
12fd6ffc1f runtime: fix up disable_netns handling
With `disable_netns=true`, we should never scan the sandbox netns which
is the host netns in such case.

Fixes: #6021
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2023-01-11 12:25:24 +00: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
Bin Liu
7eb43cec15 runtime: add test generated file to .gitignore
Add test generated file to .gitignore to avoid making the
working directory dirty.

Fixes: #6031

Signed-off-by: Bin Liu <bin@hyper.sh>
2023-01-11 17:16:06 +08:00
Bin Liu
8551853cfe runtime: use system pagesize for hugepage test
In TestHandleHugepages it will do a mount operation with different pagesizes,
but some systems only support 2M pagesize, test for a 1g pagesize will fail.

This commit try to fix by only mount pagesizes under `/sys/kernel/mm/hugepages`, which are
supported to mount by the OS.

Fixes: #6029

Signed-off-by: Bin Liu <bin@hyper.sh>
2023-01-11 17:02:58 +08:00
Bin Liu
0ec4aa1a86
Merge pull request #6007 from jongwu/single_container
runtime-rs: add Single Container support
2023-01-11 10:55:50 +08:00
Eric Ernst
07e77f5be7
Merge pull request #5994 from dcantah/virtcontainers_tests_darwin
virtcontainers: tests: Ensure Linux specific tests are just run on Linux
2023-01-10 17:13:28 -08:00
Fabiano Fidêncio
147c56bb8d
Merge pull request #6019 from liubin/fix/6018-virtiofsd-cache-mod
Change cache mode from none to never
2023-01-10 23:12:13 +01:00
Bin Liu
8225d8044e
Merge pull request #6003 from dcantah/fs-skeleton
virtcontainers: fs_share: Add Darwin skeleton
2023-01-10 17:48:45 +08:00
Bin Liu
86a82cace9 runtime: change cache mode from none to never
New Rust virtiofsd's `cache` mode doesn't support `none` mode,
we should use `never` to replace it.

Fixes: #6018

Signed-off-by: Bin Liu <bin@hyper.sh>
2023-01-10 17:29:48 +08:00
Bin Liu
82c59efd65 runtime-rs: change cache mode from none to never
New Rust virtiofsd's `cache` mode doesn't support `none` mode,
we should use `never` to replace it.

Fixes: #6018

Signed-off-by: Bin Liu <bin@hyper.sh>
2023-01-10 16:14:59 +08:00
Bin Liu
7b309b578d kata-types: change cache mode from none to never
New Rust virtiofsd's `cache` mode doesn't support `none` mode,
we should use `never` to replace it.

Fixes: #6018

Signed-off-by: Bin Liu <bin@hyper.sh>
2023-01-10 14:21:30 +08:00
Eric Ernst
4d53303a7d
Merge pull request #6005 from dcantah/vfw-skeleton
virtcontainers: Add a Virtualization.framework skeleton
2023-01-09 15:50:04 -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
Bin Liu
1bae41a4d4
Merge pull request #5996 from dcantah/vfw-initial
virtcontainers: Introduce hypervisor_darwin
2023-01-09 11:37:02 +08:00
Jianyong Wu
464d4c94de runtime-rs: process single_container
Process single_container like pod_sandbox when create container but like
pod_container when get the size info of memory/cpu from oci/spec.

Fixes: #6006
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2023-01-09 10:29:01 +08:00
Jianyong Wu
5f9c892e48 kata-types: add single_container support
For now, only pod_sandbox and pod_container are supported. It doesn't cover
the case that container started by ctr which is a single_container defined
in kata 2.0. port the single_container kata type from kata 2.0 to kata 3.0.

Fixes: #6006
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2023-01-09 10:29:01 +08:00
Samuel Ortiz
fa9ae9362c virtcontainers: Add a Virtualization.framework skeleton
Fixes: #6004

A Virtualization.framework based Hypervisor implementation.
This is just stubs for now to eventually get this building.

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-01-08 07:40:21 -08:00
Eric Ernst
d48b22bb13 virtcontainers: fs_share: add Darwin skeleton
Fixes: #6002

As a first pass for testing, let's add a skeleton for filesystem
sharing support on Darwin..

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-01-07 19:56:47 -08:00
Bin Liu
2c10b37172
Merge pull request #5991 from dcantah/darwin-sigs
runtime: Define Darwin handled signals list
2023-01-07 11:19:48 +08:00
Bin Liu
bc8a6423e0
Merge pull request #5986 from dcantah/nydus-nonetns
nydus: net-ns handling needs to be only executed on Linux hosts
2023-01-07 11:19:07 +08:00
Eric Ernst
fafc7a8b1a virtcontainers: tests: Ensure Linux specific tests are just run on Linux
Fixes: #5993

Several tests utilize linux'isms like Mounts, bindmounts, vsock etc.

Let's ensure that these are still tested on Linux, but that we also skip
these tests when on other operating systems (Darwin). This commit just
moves tests; there shouldn't be any functional test changes. While the
tests still won't be runnable on Darwin/other hosts yet, this is a necessary
step forward.

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-01-06 11:09:11 -08:00
Fabiano Fidêncio
efa4fc0b25 clh: Add hotplug support for network devices
This is needed in order to have Moby / Docker working properly with
Cloud Hypervisor, as Moby / Docker relies on hotplugging a network
device to the VM as a preStartHook.

Fixes: #5997

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-01-06 18:59:47 +01:00
Fabiano Fidêncio
1074d2c1d3 clh: Make vmAddNetPutRequest capable of doing hotplugs
THe only bit needed for having the vmAddNetPutRequest() capable of
dealing with hotplugs, instead of only coldplugs, is making sure it
doesn't error out in case a `200` response is returned.

The 200 response means:
"""
The new device was successfully added to the VM instance.
"""

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-01-06 18:55:55 +01: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
Fabiano Fidêncio
175794458f
Merge pull request #5972 from bergwolf/github/hook
fix moby prestart hook handling
2023-01-06 14:54:39 +01:00
Eric Ernst
9ec8a13985 virtcontainers: introduce hypervisor_darwin
Fixes: #5995

Placeholder skeleton at this point - implementation will be added after
basic build refactoring lands.

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-01-06 02:03:34 -08:00
Peng Tao
8bb68a9f28 vc/network: skip existing endpoints when scanning for new ones
So that addAllEndpoints() becomes re-entrant and we can use it to scan
netns changes.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2023-01-06 10:01:19 +00: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
Samuel Ortiz
3b4420eb8e runtime: Define Darwin handled signals list
Fixes: #5990

Some signals may not be defined on non Linux host OSes, like
SIGSTKFLT for example. It's also not defined on certain architectures,
but irrelevant for this.

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-01-05 17:50:47 -08:00
Danny Canter
24b05a99b6 schedcore: Make buildable on !linux
Fixes: #5983

sched-core only makes sense on Linux hosts. Let's add stub/error for
other platforms.

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-01-05 11:51:04 -08:00
Danny Canter
3886aad199 nydus: net-ns handling needs to be only executed on Linux hosts
Fixes: #5985

With nydus not being its own pkg, it is challenging to implement cleanly
in a virtcontainers package that isn't necesarily Linux-only. The
existing code utilizes network namespace code in order to ensure nydus
is launched in the host netns. This is very Linux specific - so let's
make sure we only carry this out in a linux specific file.

In the Darwin case, to allow for compilation at least, let's add a stub
for doNetNS. Ideally the nydus and vc code can be refactored /
decoupled.

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-01-05 11:48:43 -08:00
Bin Liu
1b46d4fb50
Merge pull request #5611 from wllenyj/dragonball-ut-4
Built-in Sandbox: add more unit tests for dragonball. Part 4
2023-01-05 15:21:36 +08:00
Bin Liu
a40fca1f57
Merge pull request #5976 from yaoyinnan/5825/fix/cleanup-hypervisor
runtime-rs: cleanup the run dir of hypervisor when shut down
2023-01-05 15:14:21 +08:00
Zhongtao Hu
8c4c0d2715
Merge pull request #5467 from tzY15368/feat-katactl-direct-vol
Feat: implementation of kata-ctl direct-volume operations
2023-01-05 14:06:18 +08:00
Bin Liu
4ab9364aa6
Merge pull request #5946 from dcantah/clarify-var
Runtime: Clarify mutability of global var
2023-01-05 13:08:45 +08:00
Bin Liu
649d2d4b8d
Merge pull request #5964 from openanolis/kata-runtime
kata-runtime: add rust runtime path for kata-runtime exec
2023-01-05 09:35:21 +08:00
yaoyinnan
e256903af2 runtime-rs: cleanup the run dir of hypervisor when shut down
Cleanup the run dir of hypervisor when shut down.

Fixes: #5825

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
2023-01-04 22:36:39 +08:00
Bin Liu
e2c7e5f172
Merge pull request #5950 from openanolis/upcall_fea
runtime-rs: add dbs-upcall feature
2023-01-04 16:20:40 +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
2d4b2cf72c runtime-rs: add POST method to shim-client
partly refactored shim-client to reuse code, added POST method
support, and made path string constants public for client imports.

Fixes #5341

Signed-off-by: Tingzhou Yuan <tzyuan15@bu.edu>
2023-01-04 01:33:53 -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
Bin Liu
38a6bc570d
Merge pull request #5947 from dcantah/yq-darwin
runtime/Makefile: Get some bits happy on darwin
2023-01-04 14:24:43 +08: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
5f5f6ce7a7
Merge pull request #5951 from liubin/fix/5948-check_latest_version
kata-ctl: skip test if access GitHub.com fail
2023-01-03 18:49:57 +01:00
Peng Tao
d085389127 vc: fix up UT for CreateSandbox API change
Need to adapt the UT as well.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2023-01-03 22:30:42 +08:00
Peng Tao
578a9c25f0 vc: rescan network endpoints after running prestart hooks
Moby relies on the prestart hooks to configure network endpoints. We
should rescan the netns after running them so that the newly added
endpoints can be found and plugged to the guest.

Fixes: #5941
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2023-01-03 22:30:41 +08:00
Peng Tao
cb84b0fb02 katautils: run prestart hooks after starting VM
So that we can pass the hypervisor pid to the hook instead of the
runtime process's.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2023-01-03 10:52:32 +00: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
Fabiano Fidêncio
2c24fcf34c runtime-rs: Fix clippy::bool-to-int-with-if warnings
As we bumped the rust toolchain to 1.66.0, some new warnings have been
raised due to boolean to int conversion using if.

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#bool_to_int_with_if

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-01-02 17:14:13 +01:00
Fabiano Fidêncio
025e78341e runtime-rs: Fix needless_borrow warnings
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
Fabiano Fidêncio
4fb163d570 runtime-rs: Allow clippy:box_default warnings
As the rust toolchain version bump to its 1.66.0 release raised a
warning about using Box::default() instead of specifying a type.

For now that's something we don't need to change, so let's ignore such
warning in this very specific case.

See:
https://rust-lang.github.io/rust-clippy/master/index.html#box_default

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-01-02 17:14:01 +01:00
Fabiano Fidêncio
20121fcda7 runtime-rs: Fix unnecessary_cast warnings
As we bumped the rust toolchain to 1.66.0, some new warnings have been
 raised due to unnecessary_cast.

 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#unnecessary_cast

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-01-02 16:16:39 +01:00
Fabiano Fidêncio
b95364a140 dragonball: Allow question_mark warning in allocate_device_resources()
As the rust toolchain version bump to its 1.66.0 release raised a
warning about the code being able to be refactored to use `?`.

For now that's something we don't need to change, so let's ignore such
warning in this very specific case.

See:
https://rust-lang.github.io/rust-clippy/master/index.html#question_mark

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-01-02 15:55:49 +01:00
Fabiano Fidêncio
0b2f060bf3 dragonball: Fix unnecessary_cast warnings
As we bumped the rust toolchain to 1.66.0, some new warnings have been
raised due to unnecessary_cast.

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#unnecessary_cast

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-01-02 15:55:42 +01:00
Fabiano Fidêncio
a545a65934 agent: Allow clippy::question_mark warning in Namespace{}
As the rust toolchain version bump to its 1.66.0 release raised a
warning about the code being able to be refactored to use `?`.

For now that's something we don't need to change, so let's ignore such
warning in this very specific case.

See:
https://rust-lang.github.io/rust-clippy/master/index.html#question_mark

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-01-02 15:22:20 +01:00
Fabiano Fidêncio
9ced34dd22 agent: Fix explicit_auto_deref warnings
As we bumped the rust toolchain to 1.66.0, some new warnings have been
raised due to explicit_auto_deref.

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#explicit_auto_deref

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-01-02 14:59:50 +01:00
Fabiano Fidêncio
f77220490e agent: Fix needless_borrow warnings
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 14:58:13 +01:00
Fabiano Fidêncio
7bcdc9049a rustjail: Fix unnecessary_cast warnings
As we bumped the rust toolchain to 1.66.0, some new warnings have been
raised due to unnecessary_cast.

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#unnecessary_cast

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-01-02 14:42:58 +01:00
Fabiano Fidêncio
41d7dbaaea rustjail: Fix needless_borrow warnings
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 14:42:25 +01:00
Fabiano Fidêncio
2a73e057db kata-types: Fix unnecessary_cast warnings
As we bumped the rust toolchain to 1.66.0, some new warnings have been
raised due to unnecessary_cast.

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#unnecessary_cast

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-01-02 14:28:07 +01:00
Fabiano Fidêncio
cf9ef1833c kata-types: Fix needless_borrow warnings
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 14:28:07 +01:00
Fabiano Fidêncio
126187e814 safe-path: Fix needless_borrow warnings
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 14:28:07 +01:00
Fabiano Fidêncio
bb78d35db8 kata-sys-util: Fix "match-like-matches-macro" warning
As we bumped the rust toolchain to 1.66.0, some new warnings have been
raised due to "match-like-matches-macro".

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#match_like_matches_macro

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-01-02 14:28:07 +01:00
Fabiano Fidêncio
668e652401 kata-sys-util: Fix unnecessary_cast warnings
As we bumped the rust toolchain to 1.66.0, some new warnings have been
raised due to unnecessary_cast.

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#unnecessary_cast

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-01-02 14:28:07 +01:00
Fabiano Fidêncio
c1a8d89a72 kata-sys-util: Fix needless_borrow warnings
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 14:28:07 +01:00
Fabiano Fidêncio
c9c38e6d01 logging: Allow clippy::type-complexity warning
As the rust toolchain version bump to its 1.66.0 release raised a
warning about the type complexity used for the closure, and that's
something we don't want to change, let's ignore such warning in this
very specific case.

See:
https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-01-02 14:28:07 +01:00
Fabiano Fidêncio
ffd6fbb6b6 logging: Fix needless_borrow warnings
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 14:18:14 +01:00
Fabiano Fidêncio
60df30015b protocols: Fix unnecessary_cast warnings
As we bumped the rust toolchain to 1.66.0, some new warnings have been
raised due to unnecessary_cast.

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#unnecessary_cast

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2023-01-02 14:18:14 +01:00
Danny Canter
56e7b5d0fd runtime/Makefile: Get some bits happy on darwin
Substitution in the yq install script doesn't like zsh, and additionally
the version of yq we're using doesn't have a darwin/arm64 build so grab
the amd64 version and let rosetta work its magic.

Additionally swap to abspath from readlink -m for the printing of what binaries
to install, as the -m flag doesn't exist on the BSD variant, and this
should be the same behavior.

Fixes: #5970

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-01-02 04:19:58 -08:00
Fabiano Fidêncio
0bbeb34b4c protocols: Fix needless_borrow warnings
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 12:41:29 +01:00
Danny Canter
86ee24b33c Runtime: Clarify mutability of global var
Was about to change `urandomdev` to a constant when I realized it's
intentionally mutable so it can be mocked in tests. There's other
comments to the same effect so clarify here as well.

Fixes: #5965

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-01-02 01:13:34 -08:00
Zhongtao Hu
dae6670628 kata-runtime: add rust runtime path for kata-runtime exec
add rust runtime path for kata-runtime exec

Fixes:#5963
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-12-30 13:34:34 +08:00
Chao Wu
a2e3715e01 upcall: remove upcall client when stopping vm
In order to avoid resource leak, we need to remove upcall client in vm
and vcpu manager when stopping vm.

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-12-28 20:23:39 +08:00
wllenyj
31591d7915 dragonball: fix unit test failure case about Kvm.
Due to the wrong use of as_raw_fd, Kvm was dropped twice.

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-12-26 11:32:31 +08:00
wllenyj
2b02e0a9bf dragonball: add more unit test for vcpu manager
Added more unit tests for Vcpu Manager.

Fixes: #4899

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-12-26 11:31:42 +08: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
Chao Wu
1511587a9a
Merge pull request #5601 from openanolis/hugepage
runtime-rs: enable hugepage
2022-12-25 22:35:06 +08:00
Zhongtao Hu
3605062258 runtime-rs: add dbs-upcall feature
add dbs-upcall feature to dragonball

Fixes:#5949

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

Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-12-25 19:02:42 +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
Fupan Li
dc9c8d3357
Merge pull request #5901 from justxuewei/fix/mpleak
runtime-rs: Clean up mount points shared to guest
2022-12-21 09:59:25 +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
Bin Liu
0cf443a612
Merge pull request #5915 from openanolis/legacy_device
dragonball: refactor legacy device initialization
2022-12-19 13:31:45 +08:00
Xuewei Niu
fd77eebd4d runtime-rs: fix the issues mentioned in the code review
In order to avoid cloning, changed the signature of
`ShareFsMount::share_rootfs`, `ShareFsMount::share_volume`, and
`ShareFsMount::umount_rootfs` to receive a reference to a config.

Fixes: #5898

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2022-12-19 11:46:50 +08:00
Xuewei Niu
0e69207909 runtime-rs: Clean up mount points shared to guest
Fixed issues where shared volumes couldn't umount correctly.

The rootfs of each container is cleaned up after the container is killed, except
for `NydusRootfs`. `ShareFsRootfs::cleanup()` calls
`VirtiofsShareMount::umount_rootfs()` to umount mount points shared to the
guest, and umounts the bundle rootfs.

Fixes: #5898

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2022-12-19 11:46:14 +08:00
Bin Liu
e4645642d0
Merge pull request #5877 from openanolis/fix_start_bundle
runtime-rs: enable start container from bundle
2022-12-17 08:10:08 +08:00
Yushuo
d14c3af35c dragonball: refactor legacy device initialization
If the serial path is given, legacy_manager should create socket console
based on that path. Or the console should be created based on stdio.

Fixes: #5914

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
2022-12-15 20:55:01 +08:00
Zhongtao Hu
ca39a07a14 runtime-rs: enable start container from bundle
enable start container from bundle in this way

$ ls ./bundle
config.json  rootfs
$ sudo ctr run -d --runtime io.containerd.kata.v2 --config bundle/config.json test_kata

Fixes:#5872
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-12-15 17:28:13 +08:00
Peng Tao
ebb73df6bc
Merge pull request #5899 from Bevisy/fix-outdated-comments
shim: return hypervisor's pid not shim's pid
2022-12-15 14:55:54 +08:00
Chao Wu
fad229b853
Merge pull request #5875 from Ji-Xinyou/xyji/refactor-shim-mgmt
refactor(shim-mgmt): move client side to libs
2022-12-15 10:59:45 +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
Ji-Xinyou
fbf294da3f refactor(shim-mgmt): move client side to libs
The client side is moved to libs. This is to solve the problem
that including clients will bring about messy dependencies.

Fixes: #5874
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-12-14 17:42:25 +08:00
Peng Tao
856d4b7361
Merge pull request #5798 from pmores/qemu-support
basic framework for QEMU support in runtime-rs
2022-12-14 15:05:33 +08:00
Binbin Zhang
99485d871c shim: return hypervisor's pid not shim's pid
update outdated code comments

Fixes: #3234

Signed-off-by: Binbin Zhang <binbin36520@gmail.com>
2022-12-14 11:16:11 +08:00
Chao Wu
bb4be2a666
Merge pull request #5690 from yipengyin/fix-virtiofsd
runtime-rs: fix standalone share fs
2022-12-14 00:16:10 +08:00
Pavel Mores
1f28ff6838 runtime-rs: add binary to exercise shim proper w/o containerd dependencies
After building the binary as usual with `cargo build` run it as follows.

It needs a configuration.toml in which only qemu keys `path`, `kernel`
and `initrd` will initially need to be set.  Point them to respective
files e.g. from a kata distribution tarball.

It also needs to be launched from an exported container bundle
directory.  One can be created by running

mkdir rootfs
podman export $(podman create busybox) | tar -C ./rootfs -xvf -
runc spec -b .

in a suitable directory.

Then launch the program like this:

KATA_CONF_FILE=/path/to/configuration-qemu.toml /path/to/shim-ctl

Fixes: #5817

Signed-off-by: Pavel Mores <pmores@redhat.com>
2022-12-13 14:55:21 +01:00
Pavel Mores
eb8c9d38ff runtime-rs: add launch of a simple qemu process to start_vm()
The point here is just to get a simplest Kata VM running.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2022-12-13 14:54:26 +01:00
Pavel Mores
2f6d0d408b runtime-rs: support qemu in VirtContainer
Added registration of qemu config plugin and support for creating Qemu
Hypervisor instance.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2022-12-13 14:54:26 +01:00
Pavel Mores
1413dfe91c runtime-rs: add basic empty boilerplate for qemu driver
This does almost literally nothing so far apart from getting and setting
HypervisorConfig.  It's mostly copied from/inspired by dragonball.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2022-12-13 14:53:45 +01:00
Bin Liu
3952fedcd0
Merge pull request #5882 from bergwolf/github/oci-namespaces
runtime-rs: fix sandbox_pidns calculation and oci spec amending
2022-12-13 18:32:02 +08:00
Fabiano Fidêncio
f1381eb361
Merge pull request #4813 from ManaSugi/fix/add-selinux-agent
runtime,agent: Add SELinux support for containers inside the guest
2022-12-13 11:24:53 +01:00
Yuan-Zhuo
bf8848f926 agent: Eliminate unnecessary metrics
DEFAULT_REGISTRY pre-registers many metrics that we don't need or have duplicated.
This PR uses a custom register for metrics without interference and ensures that
the registration process is executed only once when the program is running.

Fixes: #5255

Signed-off-by: Yuan-Zhuo <yuanzhuo0118@outlook.com>
2022-12-13 16:18:33 +08:00
Fupan Li
015674df16
Merge pull request #5873 from justxuewei/fix/umount2
kata-sys-util: fix issues where umount2 couldn't get the correct path
2022-12-13 15:52:32 +08:00
Bin Liu
03b6124fc6
Merge pull request #5848 from Yuan-Zhuo/drop-cgmr-option
agent: Drop the Option for LinuxContainer.cgroup_manager
2022-12-13 12:09:39 +08: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
Peng Tao
79cf38e6ea runtime-rs: clear OCI spec namespace path
None of the host namespace paths make sense in the guest. Let's clear
them all before sending the spec to the agent.

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

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

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

Fixes: #5881
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-12-12 09:54:48 +00:00
Zhongtao Hu
afaf17f423 runtime-rs: enable container hugepage
enable the functionality of using hugepages in container

Fixes: #5560
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-12-12 17:49:31 +08:00
Xuewei Niu
8079a9732d kata-sys-util: fix issues where umount2 couldn't get the correct path
Strings in Rust don't have \0 at the end, but C does, which leads to `umount2`
in the libc can't get the correct path. Besides, calling `nix::mount::umount2`
to avoid using an unsafe block is a robust solution.

Fixes: #5871

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

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

Fixes: #5655

Signed-off-by: Yipeng Yin <yinyipeng@bytedance.com>
2022-12-12 10:58:09 +08:00
Zhongtao Hu
fc4a67eec3 runtime-rs: enable vm hugepage
support vm hugepage,set the hugetlbfs mount point as vm  memory path

Fixes:#5560
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-12-09 00:01:16 +08:00
Greg Kurz
5ef7ed72ae
Merge pull request #5610 from UiPath/fix-process-wait
runtime: prevent waiting 50 ms minimum for a process exit
2022-12-08 11:02:39 +01:00
Peng Tao
0a1d1ec2fa
Merge pull request #5830 from openanolis/fix-high-cpu
runtime-rs: fix high cpu
2022-12-08 12:16:06 +08:00
Steve Horsman
39394fa2a8
Merge pull request #5844 from jtumber-ibm/patch-1
agent: remove `sysinfo` dependency
2022-12-07 16:35:05 +00:00
Fupan Li
cce316b5e9
Merge pull request #5607 from justxuewei/feat/sandbox-level-volume
runtime-rs: bind mount volumes in sandbox level
2022-12-07 19:23:38 +08:00
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
Alexandru Matei
d04d45ea05 runtime: use pidfd to wait for processes on Linux
Use pidfd_open and poll on newer versions of Linux to wait
for the process to exit. For older versions use existing wait logic

Fixes: #5617

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

Signed-off-by: Alexandru Matei <alexandru.matei@uipath.com>
2022-12-06 16:30:58 +02:00
James Tumber
748f22e7d0 agent: remove sysinfo dependency
Removes the redundant dependency `sysinfo`.

Fixes: #5843

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

Fixes: #5740
Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com>
2022-12-06 14:25:33 +08:00
Chao Wu
326d589ff5
Merge pull request #5822 from liubin/fix/5820-var-name-and-typo
runtime-rs: fix some variable names and typos
2022-12-06 14:24:11 +08:00
Zhongtao Hu
c12bb5008d
Merge pull request #5769 from jongwu/check_host_arm
kata-ctl: add host check for aarch64
2022-12-06 14:05:52 +08:00
Chao Wu
538bddf4ee
Merge pull request #5811 from tzY15368/fix-katactl-conflict-dependency
kata-ctl: fix dependency version conflict
2022-12-06 10:44:48 +08:00
Alexandru Matei
71491a69c3 runtime: move process wait logic to another function
extract process wait logic to another function

Signed-off-by: Alexandru Matei <alexandru.matei@uipath.com>
2022-12-05 13:32:04 +02:00
Alexandru Matei
92ebe61fea runtime: reap force killed processes
reap child processes after sending SIGKILL

Fixes #5739

Signed-off-by: Alexandru Matei <alexandru.matei@uipath.com>
2022-12-05 13:31:58 +02:00
Xuewei Niu
fdf0a7bb14 runtime-rs: fix the issues mentioned in the code review
Removed the `Debug` trait for the `ShareFs` and etc. Renamed
`ShareFsMount::upgrade()` and `ShareFsMount::downgrade()` to
`upgrade_to_rw()` and `downgrade_to_ro()`. Protected `mounted_info_set`
with a mutex to avoid race conditions.

Fixes: #5588

Signed-off-by: Xuewei Niu <justxuewei@apache.org>
2022-12-05 11:18:26 +08:00
Xuewei Niu
1d823c4f65 runtime-rs: umount and permission controls in sandbox level
This commit implemented umonut controls and permission controls. When a volume
is no longer referenced, it will be umounted immediately. When a volume mounted
with readonly permission and a new coming container needs readwrite permission,
the volume should be upgraded to readwrite permission. On the contrary, if a
volume with readwrite permission and no container needs readwrite, then the
volume should be downgraded.

Fixes: #5588

Signed-off-by: Xuewei Niu <justxuewei@apache.org>
2022-12-05 10:58:13 +08:00
Xuewei Niu
527b871414 runtime-rs: bind mount volumes in sandbox level
Implemented bind mount related managment on the sandbox side, involving bind
mount a volume if it's not mounted before, upgrade permission to readwrite if
there is a new container needs.

Fixes: #5588

Signed-off-by: Xuewei Niu <justxuewei@apache.org>
2022-12-05 10:58:13 +08:00
Bin Liu
9ccf2ebe8a agent: add signal value to log
For signal_process call, log the signal value in logs.

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-12-02 14:53:58 +08:00
Bin Liu
fb2c142f18 runtime-rs: fix some variable names and typos
Fix some not perfect variable names, and some typos in logs.

Fixes: #5820

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-12-02 14:52:34 +08:00
Bin Liu
514b7778a2
Merge pull request #5807 from liubin/fix/5806-add-shim-lanuage
runtime: Add identification in version for runtime-rs
2022-12-02 11:36:55 +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
Bin Liu
d4321ab489 runtime: Add identification in version for runtime-rs
Now we are supporting two runtime/shim, the go version,
and the rust version, for debug purposes, we can
add an identification in the version info
to tell us which runtime/shim is used.

Fixes: #5806

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-12-01 15:14:08 +08:00
Bin Liu
7fabfb2cf0
Merge pull request #5756 from chentt10/remove-version-number-from-commit-message
runtime-rs: remove the version number from the commit display message
2022-12-01 13:11:47 +08: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
Manabu Sugimoto
c617bbe70d runtime: Pass SELinux policy for containers to the agent
Pass SELinux policy for containers to the agent if `disable_guest_selinux`
is set to `false` in the runtime configuration. The `container_t` type
is applied to the container process inside the guest by default.
Users can also set a custom SELinux policy to the container process using
`guest_selinux_label` in the runtime configuration. This will be an
alternative configuration of Kubernetes' security context for SELinux
because users cannot specify the policy in Kata through Kubernetes's security
context. To apply SELinux policy to the container, the guest rootfs must
be CentOS that is created and built with `SELINUX=yes`.

Fixes: #4812

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2022-11-29 19:07:56 +09:00
Manabu Sugimoto
9354769286 agent: Add SELinux support for containers
The kata-agent supports SELinux for containers inside the guest
to comply with the OCI runtime specification.

Fixes: #4812

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2022-11-29 19:07:56 +09:00
Bin Liu
588f81a23c
Merge pull request #5612 from openanolis/fix-iptables
fix(agent): fix iptables binary path in guest
2022-11-29 16:57:06 +08:00
Bin Liu
1da2d0603c
Merge pull request #5761 from gaohuatao-1/ght_overhead
runtime-rs: moving only vCPU threads into sandbox controller
2022-11-29 13:53:01 +08: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
Bin Liu
a55eb78c32
Merge pull request #5752 from liubin/fix/5750-go-fix-1.19
runtime: go fix code for 1.19
2022-11-26 02:09:02 +08:00
Bin Liu
57c80ad65c
Merge pull request #5758 from chentt10/update-runtime-rs-build-and-install
doc: update runtime-rs "Build and Install"
2022-11-26 02:08:48 +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
gaohuatao
2edbe389d8 runtime-rs: moving only vCPU threads into sandbox controller
when overhead controller exists, just contrain vCPU threads
in sandbox controller

Fixes:#5760

Signed-off-by: gaohuatao <gaohuatao@bytedance.com>
2022-11-25 17:53:21 +08:00
Peng Tao
e32c023d96
Merge pull request #5714 from UiPath/fix-mkdir
runtime: don't fail mkdir if the folder is already created by another process
2022-11-25 17:52:56 +08:00
Chen Taotao
2426ea9bdc doc: update runtime-rs "Build and Install"
When using source code to compile runtime-rs,make the
documentation point out the detailed environment build
and compilation methods to avoid errors caused by related
dependent packages.

Fixes:#5757

Signed-off-by: Chen Taotao <chentt10@chinatelecom.cn>
2022-11-25 13:13:00 +08:00
Chen Taotao
67fe703ff5 runtime-rs: remove the version number from the commit display message
The displayed commit message and version message are partially duplicated.
Remove the version number from the commit display message.

Fixes:#5735

Signed-off-by: Chen Taotao <chentt10@chinatelecom.cn>
2022-11-25 13:00:01 +08:00
Ji-Xinyou
1d93a93468 fix(agent): fix iptables binary path in guest
Some rootfs put iptables-save and iptables-restore
under /usr/sbin instead of /sbin. This pr checks both
and returns the one exist.

Fixes: #5608
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-11-25 11:57:34 +08:00
Bin Liu
1dfd845f51 runtime: go fix code for 1.19
We have starting to use golang 1.19, some features are
not supported later, so run `go fix` to fix them.

Fixes: #5750

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-11-25 11:29:18 +08:00
Zhongtao Hu
f02bb1a9cb
Merge pull request #5729 from openanolis/netnsref
runtime-rs: block on the current thread when setup the network to avoid be take over by other task
2022-11-25 08:09:10 +08:00
Alexandru Matei
4b45e13869 runtime: don't fail mkdir if the folder is already created
Use MkdirAll instead of Mkdir so it doesn't generate an
error when the folder is created by another process

Fixes #5713

Signed-off-by: Alexandru Matei <alexandru.matei@uipath.com>
2022-11-24 11:20:56 +02:00
Chao Wu
9bde32daa1
Merge pull request #5707 from openanolis/ref
Refactor(runtime-rs): add conditional compile for virt-sandbox persist
2022-11-24 15:24:06 +08:00
Zhongtao Hu
b987bbc576 runtime-rs: block on the current thread when setup the network
As the increase of the I/O intensive tasks, two issues could be caused:

 1. When the future is blocked, the current thread (which is in the network namespace)
    might be take over by other tasks. After the future is finished, the thread take over
    the current task might not be in the pod network namespace
 2. When finish setting up the network, the current thread will be set back to the host namsapce.
    But the task which be taken over would still stay in the pod network namespace

 To avoid that, we need to block the future on the current thread.

Fixes:#5728
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-11-24 13:48:05 +08:00
Bin Liu
06a604b753
Merge pull request #5720 from YchauWang/wyc-docs-test-22
runtime: add log record to the qemu config method `appendDevices` for…
2022-11-24 13:15:06 +08:00
Peng Tao
b4d0a39f6d
Merge pull request #5723 from fidencio/topic/runtime-bump-containerd-to-v1.6.8
runtime: Use containerd v1.6.8
2022-11-24 11:28:58 +08:00
Fabiano Fidêncio
5cbf879659
Merge pull request #5693 from jongwu/test_ip_table
agent: check if command exist before do ip_tables test
2022-11-23 08:15:08 +01:00
wangyongchao.bj
30a7ebf430 runtime: Log invalid devices in QEMU config
When the user tried to add new devices to the VM, there is no error info for the invalid
 device. This PR adds a log record to the `appendDevices` for the invalid device of the
 qemu config.

Fixes: #5719

Signed-off-by: wangyongchao.bj <wangyongchao.bj@inspur.com>
2022-11-23 09:09:45 +08:00
Fabiano Fidêncio
df3d9878d5
Merge pull request #5695 from darfux/virtiofs-queue-size
runtime: Support virtiofs queue size for qemu and make it configurable
2022-11-22 20:04:30 +01:00
Fabiano Fidêncio
2539f31862 runtime: Use containerd v1.6.8
Let's follow the binary bump used in the CI and also bump the vendored
version of containerd to v1.6.8.

Fixes: #5722

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-11-22 18:28:30 +01:00
Chao Wu
8b04ba95cb
Merge pull request #5691 from yipengyin/support-vhost-vsock
runtime-rs: support vhost-vsock
2022-11-22 14:59:55 +08:00
Yipeng Yin
d808adef95 runtime-rs: support vhost-vsock
Rename old VsockConfig to HybridVsockConfig. And add VsockConfig to
support vhost-vsock. We follow kata's old way to try random vhost fd
for 50 times to generate uniqe fd.

Fixes: #5654

Signed-off-by: Yipeng Yin <yinyipeng@bytedance.com>
2022-11-22 10:03:52 +08:00
Zhongtao Hu
6b2ef66f0f runtime-rs: add conditional compile for virt-sandbox persist
code refactoring, add conditional compile for virt-sandbox persist

Fixes: #5706
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-11-21 19:51:43 +08:00
Jianyong Wu
b53171b605 agent: check command before do test_ip_tables
test_ip_tables test depends on iptables tools. But we can't
ensure these tools are exist. it's better to skip the test
if there is no such tools.

Fixes: #5697
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2022-11-21 14:56:51 +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
Peng Tao
a636d426d9 versions: update nydusd version
To the latest stable v2.1.1.

Depends-on: github.com/kata-containers/tests#5246
Fixes: #5635
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-11-19 16:33:29 +00:00
liyuxuan.darfux
3bb145c63a runtime: Support virtiofs queue size for qemu and make it configurable
The default vhost-user-fs queue-size of qemu is 128 now. Set it to 1024
by default which is same as clh. Also make this value configurable.

Fixes: #5694

Signed-off-by: liyuxuan.darfux <liyuxuan.darfux@bytedance.com>
2022-11-19 15:38:11 +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
Bin Liu
7506237420
Merge pull request #5144 from openanolis/nydus-dev
runtime-rs: support nydus v5 and v6 rootfs
2022-11-18 14:05:04 +08:00
Bo Chen
36545aa81a runtime: clh: Re-generate the client code
This patch re-generates the client code for Cloud Hypervisor v28.0.
Note: The client code of cloud-hypervisor's OpenAPI is automatically
generated by openapi-generator.

Fixes: #5683

Signed-off-by: Bo Chen <chen.bo@intel.com>
2022-11-17 09:45:27 -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
Chao Wu
e80dbc15d8 runtime-rs: workaround Dragonball compilation problem
Since the upstream rust-vmm is changing its dependency style towards
caret requirements in these days (more information:
rust-vmm/vm-memory#199) and it breaks Dragonball compilation frequently.

rust-vmm is expected to finish the changes this week and in order to not
break Kata CI due to Dragonball's compilation error, we will add
Cargo.lock file into /src/dragonball first and remove it later when
rust-vmm is stable.

fixes: #5657
Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-11-16 12:44:41 +01:00
Ji-Xinyou
c3f1922df6 fix(fmt): fix cargo fmt to pass static check
Fix cargo fmt

Fixes: #5639
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-11-16 12:44:38 +01:00
Greg Kurz
1bbcb413c9
Merge pull request #5597 from UiPath/fix-clh-wait
clh: avoid race condition when stopping clh
2022-11-16 07:39:27 +01:00
Zhongtao Hu
7d91150185
Merge pull request #5536 from chentt10/fix-name-shim-source-ambiguous
runtime-rs : fix the shim source in the documentation test is ambiguous
2022-11-11 14:07:05 +08:00
Zhongtao Hu
c46814b26a runtime-rs:support nydus v5 and v6
add nydus v5 snd v6 upport for container rootfs

Fixes:#5142
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-11-11 10:15:35 +08:00
Alexandru Matei
a04afab74d qemu: early exit from Check if the process was stopped
Fixes: #5625

Signed-off-by: Alexandru Matei <alexandru.matei@uipath.com>
2022-11-10 22:43:32 +02:00
Alexandru Matei
7e481f2179 qemu: set stopped only if StopVM is successful
Fixes: #5624

Signed-off-by: Alexandru Matei <alexandru.matei@uipath.com>
2022-11-10 22:43:32 +02:00
Alexandru Matei
0e3ac66e76 clh: return faster with dead clh process from isClhRunning
Through proactively checking if Cloud Hypervisor process is dead,
this patch provides a faster path for isClhRunning

Fixes: #5623

Signed-off-by: Alexandru Matei <alexandru.matei@uipath.com>
2022-11-10 22:43:32 +02:00
Alexandru Matei
9ef68e0c7a clh: fast exit from isClhRunning if the process was stopped
Use atomic operations instead of acquiring a mutex in isClhRunning.
This stops isClhRunning from generating a deadlock by trying to
reacquire an already-acquired lock when called via StopVM->terminate.

Signed-off-by: Alexandru Matei <alexandru.matei@uipath.com>
2022-11-10 22:43:32 +02:00
Alexandru Matei
2631b08ff1 clh: don't try to stop clh multiple times
Avoid executing StopVM concurrently when virtiofs dies as a result of clh
being stopped in StopVM.

Fixes: #5622

Signed-off-by: Alexandru Matei <alexandru.matei@uipath.com>
2022-11-10 22:43:32 +02:00
Chao Wu
f45fe4f90d versions: update vmm-sys-util and related crates to v0.11.0
Since the upstream of vmm-sys-utils upgraded to 0.11.0, some crates
automatically upgrade to v0.11.0, and some stay at v0.10.0 ( depending
on how they write version dependency in Cargo toml` which causes the
compile error in runtime-rs.

In order to fix this problem, we need to upgrade all vmm-sys-util
dependencies in runtime-rs to v0.11.0.

fixes: #5636

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-11-10 19:13:23 +08:00
quanweiZhou
bbc93260c9
Merge pull request #5615 from openanolis/chao/delete_cargo_patch
runtime-rs: delete all cargo patches
2022-11-10 10:18:19 +08:00
Zhongtao Hu
071ac4693a
Merge pull request #5613 from openanolis/iptables
feat(shim-mgmt): iptables handler
2022-11-09 17:21:45 +08:00
Ji-Xinyou
f8f97c1e22 feat(shim-mgmt): iptables handler
Support the handlers in runtime, which are used by kata-ctl iptables series of commands in runtime.

Fixes: #5370
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-11-09 10:39:50 +08:00
Chao Wu
29c75cf12b runtime-rs: delete all cargo patches
The cargo patch in the cargo.toml seems to cause the whole runtime-rs
building time longer and also makes it harder to build runtime-rs in an
environment without the network

We should delete all patches from the cargo.toml file and publish all
the crates that was once patched.

fixes: #5614 #5527 #5526 #5449

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-11-09 10:02:58 +08:00
Chao Wu
f5f25d9379
Merge pull request #5431 from wllenyj/dragonball-ut-3
Built-in Sandbox: add more unit tests for dragonball. Part 3
2022-11-08 15:48:16 +08:00
Zhongtao Hu
351bdbfacd
Merge pull request #5567 from openanolis/chao/fix_mem_file_path_error
Dragonball: enable mem_file_path config into hugetlbfs process
2022-11-08 09:00:13 +08:00
wllenyj
57336835da dragonball: add more unit test for device manager
Added more unit tests for device manager.

Fixes: #4899

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-11-08 00:45:17 +08:00
wllenyj
2333700237 dragonball: add test utils.
Added some tools for dragonball unit testing.

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-11-08 00:45:17 +08:00
Bin Liu
bfe9157abc
Merge pull request #5570 from openanolis/capability
runtime-rs:add hypervisor interface capabilities
2022-11-07 23:04:55 +08:00
Chao Wu
2adb1c1823 Dragonball: enable mem_file_path config into hugetlbfs process
In the current Dragonball code, mem_file_path config is not used when
hugetlbfs is enabled.
In this commit we add mem_file_path into hugetlbfs enable process.

fixes: #5566
Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-11-07 16:07:57 +08:00
Fabiano Fidêncio
7250be3601
Merge pull request #5584 from fengyehong/clh-thread
cloud-hypervisor: Fix GetThreadIDs function
2022-11-07 08:22:40 +01:00
Bin Liu
824ea83c3c
Merge pull request #5573 from pmores/fill-in-virtiofsd-standalone-impl
runtime-rs: blanks filled & fixes made to virtiofsd launch
2022-11-07 14:19:45 +08:00
Bin Liu
83d052f82b
Merge pull request #4476 from LitFlwr0/vcpu-pinning-frq
vCPUs pinning support for Kata Containers
2022-11-07 10:37:22 +08:00
Guanglu Guo
daeee26a1e cloud-hypervisor: Fix GetThreadIDs function
Get vcpu thread-ids by reading cloud-hypervisor process tasks information.

Fixes: #5568

Signed-off-by: Guanglu Guo <guoguanglu@qiyi.com>
2022-11-05 17:23:19 +08:00
Bin Liu
427b01e298
Merge pull request #5548 from justxuewei/fix/share-fs-permission
runtime-rs: fix shared volume permission issue
2022-11-04 21:21:50 +08:00
LitFlwr0
2508d39b7c runtime: added vcpus pinning logics
Core VCPU threads pinning logics for issue 4476. Also provided docs.

Fixes:#4476
Signed-off-by: LitFlwr0 <861690705@qq.com>
2022-11-04 17:52:42 +08:00
Zhongtao Hu
fef8e92af1 runtime-rs:add hypervisor interface capabilities
1. be able to check does hypervisor support use block device, block
device hotplug, multi-queue, and share file

2. be able to set the hypervisor capability of using block device, block
device hotplug, multi-queue, and share file

Fixes: #5569
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-11-04 09:24:36 +08: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
Pavel Mores
27b1913584 runtime-rs: blanks filled & fixes made to virtiofsd launch
The 'config' argument to ShareVirtioFsStandalone::new() is now actually
used, taking care of an explicit TODO.

If a shared path doesn't exist in ShareVirtioFsStandalone::virtiofsd_args()
it is now created instead of returning an error, thus following
ShareVirtioFsInline's suit.

The '-o vhost_user_socket=...' command line argument doesn't seem to be
supported by newer versions of virtiofsd so we replace it with
'--socket-path' which should be functionally equivalent according to docs.

Fixes #5572

Signed-off-by: Pavel Mores <pmores@redhat.com>
2022-11-03 08:38:59 +01: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
Xuewei Niu
b74c18024a runtime-rs: fix shared volume permission issue
Fix the issue where share volumes always have readwrite permission even if
readonly permission is enough.

Fixes: #5549

Signed-off-by: Xuewei Niu <justxuewei@apache.org>
2022-11-01 18:42:19 +08:00
Chen TaoTao
936fe35acb runtime-rs : fix shim source is ambiguous
In the documentation test, the name shim has multiple potential
sources of import, now give it a clear source.

Fixes: #5535

Signed-off-by: Chen TaoTao <chentt10@chinatelecom.cn>
2022-10-31 19:54:22 -07:00
snir911
288e337a6f
Merge pull request #5434 from Rouzip/remove-doNetNS
add EnterNetNS in virtcontainers
2022-10-30 11:19:07 +02: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
Peng Tao
b015f34aff runtime-rs: generate config files with the default target
Right now it is not generated with a simple `make`.

Fixes: #5509
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-10-26 10:25:29 +08: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
Bo Chen
a151d8ee50
Merge pull request #5493 from fidencio/topic/update-clh
versions: Update Cloud Hypervisor to b4e39427080
2022-10-24 07:54:02 -07:00
Bin Liu
4696eadfeb
Merge pull request #5488 from ManaSugi/fix/update-libseccomp-crate
rustjail: Upgrade libseccomp crate to v0.3.0
2022-10-24 17:03:30 +08:00
Bin Liu
badb2600b3
Merge pull request #5474 from openanolis/makefile
makefile: remove sudo when create symbolic link
2022-10-24 17:03:20 +08:00
Bin Liu
ab5f97759d
Merge pull request #5497 from Rouzip/remove-redundant
agent: remove redundant checks
2022-10-24 16:41:49 +08:00
Fabiano Fidêncio
190e623c40
Merge pull request #5317 from Champ-Goblem/fix-containerd-stats
shim: Ensure pagesize is set when reporting hugetlb stats
2022-10-24 10:24:49 +02:00
Fabiano Fidêncio
7248cf51c5
Merge pull request #5447 from hbrueckner/fix-5438
kata-ctl: Re-enable network tests on s390x (fixes 5438)
2022-10-24 10:23:35 +02:00
James O. D. Hunt
65ef2a0a0b
Merge pull request #5089 from liubin/fix/4895-ignore-exit-error
agent: use NLM_F_REPLACE replace NLM_F_EXCL in rtnetlink
2022-10-24 08:46:54 +01:00
snir911
ee189d2ebe
Merge pull request #5455 from kata-containers/main-validate-hp-size
agent: validate hugepage size is supported
2022-10-23 08:15:05 +03:00
Rouzip
44d8de8923
agent: remove redundant checks
Remove redundant checks for executable files.

FIXes: #3730

Signed-off-by: Rouzip <1226015390@qq.com>
2022-10-22 23:31:18 +08:00
Fabiano Fidêncio
9d286af7b4 versions: Update Cloud Hypervisor to b4e39427080
An API change, done a long time ago, has been exposed on Cloud
Hypervisor and we should update it on the Kata Containers side to ensure
it doesn't affect Cloud Hypervisor CI and because the change is needed
for an upcoming work to get QAT working with Cloud Hypervisor.

Fixes: #5492

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-10-21 20:52:54 +02:00
Bin Liu
081ee48713 agent: use NLM_F_REPLACE replace NLM_F_EXCL in rtnetlink
Sometimes we will face EEXIST error when adding arp neighbour.
Using NLM_F_REPLACE replace NLM_F_EXCL will avoid fail if the
entry exists.

See https://man7.org/linux/man-pages/man7/netlink.7.html

Fixes: #4895

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-10-21 21:19:14 +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
Manabu Sugimoto
cbd84c3f5a rustjail: Upgrade libseccomp crate to v0.3.0
The libseccomp crate v0.3.0 has been released, so use it in the agent.

Fixes: #5487

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2022-10-21 15:40:05 +09:00
Bin Liu
1bf64c9a11
Merge pull request #5453 from openanolis/chao/fix_comment_typo
Makefile: fix an typo in runtime-rs makefile
2022-10-21 14:36:39 +08:00
Zhongtao Hu
748be0fe3d makefile: remove sudo when create symbolic link
when using mock to package rpm, we cannot have sudo permission

Fixes: #5473
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-10-20 22:13:21 +08:00
Bin Liu
cd27ad144e
Merge pull request #5219 from openanolis/krt-modify
Modify agent-url return value in runtime-rs
2022-10-20 11:17:29 +08:00
Bin Liu
faf363db75
Merge pull request #5414 from openanolis/chao/regulate_runtime_rs_makefile_comments
runtime-rs: regulate the comment in runtime-rs makefile
2022-10-19 15:36:00 +08:00
Snir Sheriber
72738dc11f agent: validate hugepage size is supported
before setting a limit, otherwise paths may not be found.
guest supporting different hugepage size is more likely with peer-pods where
podvm may use different flavor.

Fixes: #5191
Signed-off-by: Snir Sheriber <ssheribe@redhat.com>
2022-10-19 09:55:33 +03:00
Chao Wu
f74e328fff Makefile: fix an typo in runtime-rs makefile
There is a typo in runtime-rs makefile.
_dragonball should be _DB

fixes: #5452

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-10-19 14:12:48 +08:00
Chao Wu
f205472b01 Makefile: regulate the comment style for the runtime-rs comments
In runtime-rs makefile, we use
```
```
to let make help print out help information for variables and targets,
but later commits forgot this rule.
So we need to follow the previous rule and change the current comments.

fixes: #5413
Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-10-19 12:12:50 +08: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
Rouzip
39363ffbfb
runtime: remove same function
Add EnterNetNS in virtcontainers to remove same function.

FIXes #5394

Signed-off-by: Rouzip <1226015390@qq.com>
2022-10-17 10:59:13 +08: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
Zhongtao Hu
5d17cbeef7
Merge pull request #5383 from openanolis/chao/update_comments_in_event_manager
Dragonball: remove redundant comments in event manager
2022-10-14 15:50:37 +08:00
Bin Liu
b23a24ab2f
Merge pull request #5417 from liubin/fix/typo-get_contaier_type
runtime-rs: fix typo get_contaier_type to get_container_type
2022-10-13 22:35:23 +08:00
Bin Liu
c7b38532f0
Merge pull request #5412 from tzY15368/improve-cmd-descriptions
kata-ctl: improve command descriptions for consistency
2022-10-13 19:17:42 +08:00
Bin Liu
4d9dd8790d runtime-rs: fix typo get_contaier_type to get_container_type
Change get_contaier_type to get_container_type

Fixes: #5415

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-10-13 17:12:43 +08:00
Bin Liu
2de29b6f69
Merge pull request #5088 from liubin/fix/5087-force-shutdown-shim
runtime-rs: force shutdown shim process in it can't exit
2022-10-13 16:55:05 +08: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
Bin Liu
3b70c72436
Merge pull request #5395 from wllenyj/dragonball-s390
ci: skip s390x for dragonball.
2022-10-13 09:03:08 +08:00
Bin Liu
157d3cdcb1
Merge pull request #5397 from openanolis/chao/delete_redundant_dragonball_comment
Dragonball: delete redundant comments in blk_dev_mgr
2022-10-13 09:01:59 +08:00
James O. D. Hunt
d3ee8d9f1b
Merge pull request #5388 from jodh-intel/kata-ctl
kata-ctl: Move development to main branch
2022-10-12 14:29:35 +01: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
wllenyj
1f1901e059 dragonball: fix clippy warning for aarch64
Added aarch64 check.

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-10-12 18:29:00 +08:00
wllenyj
a343c570e4 dragonball: enhance dragonball ci
Unified use of Makefile instead of calling `cargo test` directly.

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-10-12 17:53:01 +08:00
wllenyj
6a64fb0eb3 ci: skip s390x for dragonball.
Currently, Dragonball only supports x86_64 and aarch64 platforms.

Fixes: #4381

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-10-12 15:27:45 +08:00
Bin Liu
7aacba0abc
Merge pull request #5282 from liubin/fix/4730-rs-emptydir
runtime-rs: support ephemeral storage for emptydir
2022-10-12 09:53:59 +08:00
Chao Wu
a743e37daf Dragonball: delete redundant comments in blk_dev_mgr
delete redundent derive part for BlockDeviceMgr.

fixes: #5396

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-10-11 19:41:47 +08: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
Bin Liu
ffdd7e1ad8
Merge pull request #4961 from wllenyj/dragonball-ut-2
Built-in Sandbox: add more unit tests for dragonball
2022-10-11 14:12:25 +08:00
Bin Liu
39702c19d5
Merge pull request #5276 from bergwolf/github/readme
readme: remove libraries mentioning
2022-10-11 13:19:18 +08:00
wllenyj
26c043dee7 ci: Add dragonball test
Enhanced Static-Check of CI to support nested virtualization.

Fixes: #5378

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-10-11 00:36:20 +08: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
wllenyj
b62b18bf1c dragonball: fix clippy warning
Fixed:
- unnecessary_lazy_evaluations
- derive_partial_eq_without_eq
- redundant_closure
- single_match
- question_mark
- unused-must-use
- redundant_clone
- needless_return

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-10-10 16:41:40 +08:00
wllenyj
2ddc948d30 Makefile: add dragonball components.
Enable ci to run dragonball unit tests.

Fixes: #4899

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-10-10 16:41:40 +08:00
wllenyj
3fe81fe4ab dragonball-ut: use skip_if_not_root to skip root case
Use skip_if_not_root to skip when unit test requires privileges.

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-10-10 16:41:40 +08:00
wllenyj
72259f101a dragonball: add more unit test for vmm actions
Added more unit tests for vmm actions.

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-10-10 16:41:39 +08:00
Chao Wu
9717dc3f75 Dragonball: remove redundant comments in event manager
handle_events for EventManager doesn't take max_events as arguments, so
we need to update the comments for it.

p.s. max_events is defined when initializing the EventManager.

fixes: #5382

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-10-09 14:38:12 +08:00
Fupan Li
2c88e1cd80
Merge pull request #5302 from liubin/fix/5285-SetFsSharingSupport-comment
runtime: fix incorrect comment for SetFsSharingSupport function
2022-10-09 09:40:31 +08:00
Bin Liu
b556c9b986
Merge pull request #5235 from YchauWang/wyc-qmp-log
virtcontainers: add warn log record for qmp hotplug cpu error
2022-10-09 08:29:09 +08:00
Bin Liu
53f209af44 libs/kata-types: adjust default_vcpus correctly
With default_maxvcpus = 0 and default_vcpus = 1 settings, the
default_vcpus will be set to 0 and leads to starting fail.

The default_maxvcpus is not set correctly when it is set to 0,
and the default_vcpus is set to 0.

The correct action is setting default_maxvcpus to the max number
of CPUs or MAX_DRAGONBALL_VCPUS, and the default_vcpus should be
set to the desired value if the valuse is between 0 and
default_maxvcpus.

Fixes: #5110

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-10-08 16:52:05 +08:00
Bin Liu
dd34540b8a
Merge pull request #5305 from liubin/fix/5301-delete-duplicated-PASSTHROUGH_FS_DIR
runtime-rs: delete duplicated PASSTHROUGH_FS_DIR const
2022-10-08 16:39:03 +08:00
Ji-Xinyou
9c1ac3d457 runtime-rs: return port on agent-url req
Add the server vport (1024) when requesting agent-url

Fixes: #5213
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-10-08 16:14:21 +08:00
Fabiano Fidêncio
ce73bc6dac
Merge pull request #5015 from vijaydhanraj/enable_acrn_kata2.x
Enable ACRN hypervisor support for Kata 2.x release
2022-10-08 09:27:59 +02:00
Bin Liu
4616363eec
Merge pull request #5365 from fengwang666/mount-bug-fix
agent: reduce reference count for failed mount
2022-10-08 14:27:38 +08:00
Fupan Li
1b7272c7ca
Merge pull request #5367 from fengwang666/signal-bug-fix
agent: don't exit early if signal fails due to ESRCH
2022-10-08 14:21:50 +08:00
Feng Wang
ef5a2dc3bf agent: don't exit early if signal fails due to ESRCH
ESRCH usually means the process has exited. In this case,
the execution should continue to kill remaining container processes.

Fixes: #5366

Signed-off-by: Feng Wang <feng.wang@databricks.com>
[Fix up cargo updates]
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-10-08 12:15:12 +08:00
Bin Liu
5ace4e2354
Merge pull request #5304 from liubin/fix/5299-delete-duplicated-get_bundle_path
kata-sys-util: delete duplicated get_bundle_path
2022-10-08 10:57:52 +08:00
Vijay Dhanraj
435c8f181a acrn: Enable ACRN hypervisor support for Kata 2.x release
Currently ACRN hypervisor support in Kata2.x releases is broken.
This commit re-enables ACRN hypervisor support and also refactors
the code so as to remove dependency on Sandbox.

Fixes #3027

Signed-off-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
2022-10-07 07:40:32 -07:00
Feng Wang
c31cf7269e agent: reduce reference count for failed mount
The kata agent adds a reference for each storage object before mount
and skip mount again if the storage object is known. We need to
remove the object reference if mount fails.

Fixes: #5364

Signed-off-by: Feng Wang <feng.wang@databricks.com>
2022-10-06 21:37:59 -07:00
Archana Shinde
6e2d39c588
Merge pull request #5311 from likebreath/0930/clh_v27.0
Upgrade to Cloud Hypervisor v27.0
2022-10-04 10:56:00 -07:00
Fabiano Fidêncio
d5572d5fd5
Merge pull request #5106 from norbjd/fix/microvm-machine-options
microvm: Remove kernel_irqchip=on option
2022-10-04 12:19:37 +02:00
Champ-Goblem
89e62d4edf shim: Ensure pagesize is set when reporting hugetbl stats
The containerd stats method and metrics API are broken with Kata 2.5.x, the stats fail to load and the metrics API responds with status code 500

This seems to be down to the conversion from the stats reported by the agent RPC `StatsContainer` where the field `Pagesize` is not
completed by the `setHugetlbStats` method. In the case where multiple sized tables stats are reported, this causes containerd to register two metrics
with the same label set, rather than each being partitioned by the `page` label.

Fixes: #5316
Signed-off-by: Champ-Goblem <cameron@northflank.com>
2022-10-04 09:16:30 +01:00
Bo Chen
067e2b1e33 runtime: clh: Use the new API to boot with TDX firmware (td-shim)
The new way to boot from TDX firmware (e.g. td-shim) is using the
combination of '--platform tdx=on' with '--firmware tdshim'.

Fixes: #5309

Signed-off-by: Bo Chen <chen.bo@intel.com>
2022-10-03 10:30:54 -07:00
Bo Chen
5d63fcf344 runtime: clh: Re-generate the client code
This patch re-generates the client code for Cloud Hypervisor v27.0.
Note: The client code of cloud-hypervisor's (CLH) OpenAPI is
automatically generated by openapi-generator [1-2].

[1] https://github.com/OpenAPITools/openapi-generator
[2] https://github.com/kata-containers/kata-containers/blob/main/src/runtime/virtcontainers/pkg/cloud-hypervisor/README.md

Fixes: #5309

Signed-off-by: Bo Chen <chen.bo@intel.com>
2022-10-03 10:30:42 -07:00
Fabiano Fidêncio
0143036b84
Merge pull request #5303 from liubin/fix/5296-typo-unknow
kata-sys-util: fix typo `unknow`
2022-10-03 15:29:45 +02:00
norbjd
17de94e118 microvm: Remove kernel_irqchip=on option
`kernel_irqchip` option doesn't seem to bring any benefits and, on the
contrary, its usage cause issues when using the microvm machine type.

With this in mind, let's remove it.

Fixes: #1984, #4386

Signed-off-by: norbjd <norbjd@users.noreply.github.com>
Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-10-03 11:48:05 +02:00
Bin Liu
3aeaa6459d runtime-rs: delete duplicated PASSTHROUGH_FS_DIR const
The const PASSTHROUGH_FS_DIR defined twice, delte one.

Fixes: #5301

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-30 15:53:08 +08:00
Bin Liu
43ae972335 kata-sys-util: delete duplicated get_bundle_path
get_bundle_path has already defined in spec.rs,
delete it from fs.rs.

Fixes: #5299

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-30 15:50:58 +08:00
Bin Liu
ac04831223 kata-sys-util: fix typo unknow
Change `unknow` to `unknown`.

Fixes: #5296

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-30 15:47:34 +08:00
Bin Liu
68e8a86aec runtime: fix incorrect comment for SetFsSharingSupport function
The comment for SetFsSharingSupport is not suitable, correct the
function name.

Fixes: #5285

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-30 15:44:44 +08:00
Bin Liu
805e80b2a2
Merge pull request #5278 from openanolis/chao/update_linux_loader_ut
dragonball: update ut for kernel config
2022-09-30 11:12:29 +08:00
Bin Liu
8d4ced3c86 runtime-rs: support ephemeral storage for emptydir
Add support for ephemeral storage and k8s emptydir.

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

Fixes: #4730

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-30 09:10:20 +08:00
Jianyong Wu
6d585d5919 dragonball: fix no "as_str" error on Arm
Cmdline struct update in the latest linux-loader lib and its as_str
method is changed to as_cstring, thus we need fix it according whereas
the old as_str method is used.

Fixes: #5287
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2022-09-29 21:06:31 +08:00
Bin Liu
949ffcc457
Merge pull request #5281 from liubin/fix/5280-update-cargo-lock
runtime-rs: update Cargo.lock
2022-09-29 17:16:21 +08:00
Bin Liu
1352e31180
Merge pull request #5200 from openanolis/agent_rwlock
refactor(runtime-rs): Use RwLock in runtime-agent
2022-09-29 13:15:41 +08:00
Bin Liu
457b0beaf0 runtime-rs: update Cargo.lock
src/dragonball/Cargo.toml is updated and the Cargo.lock is not
commited into repo.

Fixes: #5280

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-29 13:15:01 +08:00
Bin Liu
abbdf89a06
Merge pull request #5271 from liubin/fix/4729-add-close-io-for-kubectl-cp
runtime-rs: fix shim close_io call to support kubectl cp
2022-09-29 13:10:49 +08:00
Peng Tao
046ddc6463 readme: remove libraries mentioning
There are two duplicated mentioning of the rust libraries in README.md.
Let's just remove them all as the section is intended to list out core
Kata components rather than general libraries.

Fixes: #5275
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-09-29 12:10:50 +08:00
Chao Wu
f89ada2de1 dragonball: update ut for kernel config
Since linux loader is updated in the Dragonball and the api for Cmdline
has been changed ( as_str() changed to as_cstring() ), we need to update
unit test in Dragonball.

fixes: #5277

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-09-29 11:35:45 +08:00
Bin Liu
0e899669ee runtime-rs: fix shim close_io call to support kubectl cp
Add close_io to shim and call agent's close_stdin in close_io.

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

Fixes: #4729

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-29 09:35:17 +08:00
Zhongtao Hu
96cf21fad0 runtime-rs: add comments for runtime-rs shared directory
add comments for runtime-rs shared directory

Fixes:#5197
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-09-28 15:46:34 +08:00
Zhongtao Hu
2f1a4b02ee
Merge pull request #5254 from openanolis/chao/update_linux_loader
Dragonball: update linux_loader to 0.6.0
2022-09-28 15:04:09 +08:00
Bin Liu
0f6884b8c3
Merge pull request #5252 from zhaoxuat/main
modify virtio_net_dev_mgr.rs wrong code comments
2022-09-28 11:34:20 +08:00
Bin Liu
d0be4a285e
Merge pull request #5260 from GabyCT/topic/fixrunkdoc
docs: Update urls in runk documentation
2022-09-28 11:30:39 +08:00
Zhongtao Hu
ff053b0808
Merge pull request #5220 from liubin/fix/5184-rs-inotify
runtime-rs: support watchable mount
2022-09-28 11:19:53 +08:00
Zhongtao Hu
319caa8e74
Merge pull request #5097 from openanolis/dbg-console
runtime-rs: debug console support in runtime
2022-09-28 10:30:22 +08:00
Peng Tao
33b0720119
Merge pull request #5193 from openanolis/origin/kata-deploy
kata-deploy: ship the rustified runtime binary
2022-09-28 10:19:16 +08: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
Chao Wu
90ecc015e0 Dragonball: update linux_loader to 0.6.0
Since linux-loader 0.4.0 and 0.5.0 is yanked due to null terminator bug,
we need to update linux-loader to 0.6.0.

And as_str() function should also be changed.

fixes: #5253

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-09-27 23:01:44 +08:00
Bin Liu
c64e56327f
Merge pull request #5190 from liubin/fix/5189-unbind-as-a-const
runtime-rs: define VFIO unbind path as a const
2022-09-27 21:04:18 +08:00
Bin Liu
4a763925e5 runtime-rs: support watchable mount
Use watchable mount to support inotify for virtio-fs.

Fixes: #5184

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-27 19:08:25 +08:00
zhaoxu
abc26b00bb dragonball: modify wrong code comments
modify virtio_net_dev_mgr.rs wrong code comments

Fixes: #5252

Signed-off-by: zhaoxu <zhaoxu@megvii.com>
2022-09-27 18:32:13 +08:00
Bin Liu
c95cf6dce7
Merge pull request #5250 from liubin/fix/5249-set-timeout-to-zero-for-stream-rpc
runtime-rs: set agent timeout to 0 for stream RPCs
2022-09-27 17:39:35 +08:00
Peng Tao
8a2df6b31c
Merge pull request #4931 from jpecholt/snp-support
Added SNP-Support for Kata-Containers
2022-09-27 14:17:54 +08:00
Bin Liu
20bcaf0e36 runtime-rs: set agent timeout to 0 for stream RPCs
For stream RPCs:
- write_stdin
- read_stdout
- read_stderr

there should be no timeout (by setting it to 0).

Fixes: #5249

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-27 11:47:37 +08:00
Bin Liu
407e46b1b7
Merge pull request #5218 from bergwolf/github/deps
runtime/runtime-rs: update dependency
2022-09-27 11:02:46 +08:00
Bin Liu
a2f207b923
Merge pull request #5163 from liubin/fix/5162-add-test-for-StaticResource
runtime-rs: add test for StaticResource
2022-09-26 17:44:20 +08:00
Zhongtao Hu
9d67f5a7e2
Merge pull request #5230 from openanolis/nohc
runtime-rs: remove hardcoded string
2022-09-26 16:01:41 +08:00
quanweiZhou
ad87c7ac56
Merge pull request #5206 from openanolis/hypervisor/readme
docs: add README for runtime-rs hypervisor crate
2022-09-26 16:01:12 +08:00
Bin Liu
5a98fb8d2b
Merge pull request #5186 from liubin/fix/5185
runtime-rs: use Path.is_file to check regular files
2022-09-26 12:33:47 +08:00
Zhongtao Hu
4a36bb9e21
Merge pull request #4924 from openanolis/runtime-rs-netUT
runtime-rs: add unit tests for network resource
2022-09-23 17:45:24 +08:00
Zhongtao Hu
274de024c5 docs: add README for runtime-rs hypervisor crate
add README for runtime-rs hypervisor crate

Fixes:#4634
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-09-23 15:20:02 +08:00
Chao Wu
9cf5de0b4e
Merge pull request #5171 from liubin/fix/5170-use-macro
runtime-rs/resource: use macro to reduce duplicated code
2022-09-23 10:59:53 +08:00
wangyongchao.bj
04bbce8dc3 virtcontainers: add warn log record for qmp hotplug cpu error
The qmp command of hotplug cpu failed error was hidden. It didn't friendly for
the user tracing the hotplug cpu error. The PR help us to improve the hotplug
cpu error log. Add real qemu command error log for `failed to hot add vCPUs`.
Through the error message, we can get the reason of the failed qmp command
 for hotplug cpu operation.

Fixes: #5234

Signed-off-by: wangyongchao.bj <wangyongchao.bj@inspur.com>
2022-09-23 08:22:30 +08:00
Chelsea Mafrica
de869f2565
Merge pull request #5188 from liubin/fix/5187-incorrect-comments-in-kata-types-hypervisor
runtime-rs: fix incorrect comments
2022-09-22 14:09:20 -07:00
Zhongtao Hu
d663f110d7 kata-deploy: get the config path from cri options
get the config path for runtime-rs from cri options

Fixes: #5000
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-09-22 17:39:25 +08:00
Ji-Xinyou
46965739a4 runtime-rs: remove hardcoded string
Use KATA_PATH instead of "run/kata"

Fixes: #5229
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-09-22 16:06:51 +08:00
Zhongtao Hu
a394761a5c kata-deploy: add installation for runtime-rs
setup the compile environment and installation path for the Rust runtime

Fixes:#5000
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-09-22 15:59:44 +08:00
Peng Tao
a2c13bad45
Merge pull request #5156 from fengwang666/uid-reuse-bug
Non-root hypervisor uid reuse bug
2022-09-22 15:35:39 +08:00
Peng Tao
af174c2b6d
Merge pull request #5195 from wllenyj/update-dbs
Build-in Sandbox: update dragonball-sandbox dependencies
2022-09-22 15:07:11 +08:00
Ji-Xinyou
50299a3292 refactor(runtime-rs): Use RwLock in runtime agent
Use RwLock for Agent in runtime, for better concurrency.

Fixes: #5199
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-09-21 17:43:40 +08:00
Peng Tao
9628c7df0c runtime: update runc dependency
To bring fix to CVE-2022-29162.

Fixes: #5217
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-09-21 17:21:37 +08:00
Peng Tao
7fbc883879 runtime-rs: drop dependency on rustc-serialize
We are not using it and it hasn't got any updates for more than five
years, leaving open CVEs unresolved.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-09-21 17:19:58 +08:00
Ji-Xinyou
e23bfd615e runtime-rs: make function name more understandable
Change kparams to kernel_params for understandability.

Fixes: #5068
Signed-Off-By: Ji-Xinyou <jerryji0414@outlook.com>
2022-09-21 11:48:11 +08:00
Ji-Xinyou
426a436780 runtime-rs: add unit test and eliminate raw string
Add two unit tests for coverage and eliminate raw strings to constant.

Fixes: #5068
Signed-Off-By: Ji-Xinyou <jerryji0414@outlook.com>
2022-09-21 11:47:07 +08:00
Ji-Xinyou
87959cb72d runtime-rs: debug console support in runtime
Read debug console configuration in kernel params.

Fixes: #5068
Signed-Off-By: Ji-Xinyou <jerryji0414@outlook.com>
2022-09-21 11:46:55 +08:00
Bin Liu
a2e7434a0f
Merge pull request #5082 from QiliangFan/main
dragonball: Fix problem that stdio console cannot connect to stdout
2022-09-21 11:12:19 +08:00
wllenyj
0399da677d runtime-rs: update dependencies
Updated Cargo.lock.

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-09-20 15:00:14 +08:00
wllenyj
f6f19917a8 dragonball: update dragonball-sandbox dependencies
Updated vmm-sys-util to 0.10.0
Updated virtio-queue to 0.4.0
Updated vm-memory to 0.9.0
Updated linux-loader to 0.5.0

Fixes: #5194

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-09-20 14:48:09 +08:00
Zhongtao Hu
e05e42fd3c
Merge pull request #5113 from liubin/fix/5112-call-TomlConfig-validate-func
runtime-rs: call TomlConfig's validate function after load
2022-09-20 14:38:42 +08:00
Zhongtao Hu
fc65e96ad5
Merge pull request #5133 from openanolis/shimmgmt
feat(Shimmgmt): Shim management server and client
2022-09-20 14:37:19 +08:00
Bin Liu
2caee1f38d runtime-rs: define VFIO unbind path as a const
In src/runtime-rs/crates/hypervisor/src/device/vfio.rs,
the path of new_id is defined as a const, but unbind is used
as a local variable, they should be unified to const.

Fixes: #5189

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-19 16:08:35 +08:00
Bin Liu
3f65ff2d07 runtime-rs: fix incorrect comments
Some comments for types are incorrect in file
 src/libs/kata-types/src/config/hypervisor/mod.rs

Fixes: #5187

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-19 16:03:06 +08:00
Bin Liu
9670a3caac runtime-rs: use Path.is_file to check regular files
Use Path.is_file to replace using `stat` to check the file type.

Fixes: #5185

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-19 15:57:07 +08:00
Joana Pecholt
ded60173d4 runtime: Enable choice between AMD SEV and SNP
This is based on a patch from @niteeshkd that adds a config
parameter to choose between AMD SEV and SEV-SNP VMs as the
confidential guest type in case both types are supported. SEV is
the default.

Signed-off-by: Joana Pecholt <joana.pecholt@aisec.fraunhofer.de>
2022-09-16 17:51:41 +02:00
Joana Pecholt
22bda0838c runtime: Support for AMD SEV-SNP VMs
This commit adds AMD SEV-SNP as a confidential guest option to the
runtime. Information on required components such as OVMF, QEMU and
a kernel supporting SEV-SNP are defined in the versions file and
corresponding configs are added.

Note: The CPU model 'host' provided by the current SNP-QEMU does
not support all SNP capabilities yet, which is why this option is
changed to EPYC-v4.

Note: The guest's physical address space reduction specified with
ReducedPhysBits is 1. Details are can be found in Section 15.34.6
here https://www.amd.com/system/files/TechDocs/24593.pdf

Fixes #4437

Signed-off-by: Joana Pecholt <joana.pecholt@aisec.fraunhofer.de>
2022-09-16 17:51:41 +02:00
Joana Pecholt
105eda5b9a runtime: Initrd path option added to config
Adds initrd configuration option to the configuration.toml that is
generated for the setup using QEMU.

Signed-off-by: Joana Pecholt <joana.pecholt@aisec.fraunhofer.de>
2022-09-16 17:51:41 +02:00
Bin Liu
a8a8a28a34 runtime-rs/resource: use macro to reduce duplicated code
Some device types have the same definition, they can be implemented
by macro to reduce code.

And this commit also deleted the `peer_name` field of the structs that
is never been used.

Fixes: #5170

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-15 15:45:26 +08:00
Bin Liu
156e1c3247 runtime-rs: delete some allow(dead_code) attributes
Some #![allow(dead_code)]s and code are not needed indeed.

Fixes: #5164

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-14 20:50:30 +08:00
qiliangfan
7622452f4b Dragonball: Fix the problem about stdio console
Let stdout stream connect to the com1_device,

Fixes: #5083

Signed-off-by: qiliangfan <fanqiliang@mail.nankai.edu.cn>
2022-09-14 15:53:57 +08:00
Bin Liu
208233288a runtime-rs: add test for StaticResource
Add test case for StaticResource, the old test is not
covering the StaticResource struct.

Fixes: #5162

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-14 11:45:07 +08:00
Feng Wang
f914319874 runtime: store the user name in hypervisor config
The user name will be used to delete the user instead of relying on
uid lookup because uid can be reused.

Fixes: #5155

Signed-off-by: Feng Wang <feng.wang@databricks.com>
2022-09-13 10:32:55 -07:00
Feng Wang
5cafe21770 runtime: make StopVM thread-safe
StopVM can be invoked by multiple threads and needs to be thread-safe

Fixes: #5155

Signed-off-by: Feng Wang <feng.wang@databricks.com>
2022-09-12 21:56:15 -07:00
Feng Wang
c3015927a3 runtime: add more debug logs for non-root user operation
Previously the logging was insufficient and made debugging difficult

Fixes: #5155

Signed-off-by: Feng Wang <feng.wang@databricks.com>
2022-09-12 21:38:57 -07:00
Bin Liu
a58feba9bb
Merge pull request #5105 from liubin/fix/5104-ignore-virtiofs-daemon-for-inline-mode
kata-types: don't check virtio_fs_daemon for inline-virtio-fs
2022-09-13 10:33:56 +08:00
Bin Liu
42d4da9b6c
Merge pull request #5101 from liubin/fix/5100-cpu-period-quota-data-type
kata-types: change return type of getting CPU period/quota function
2022-09-13 10:33:29 +08:00
Tim Zhang
8ec4edcf4f
Merge pull request #5146 from liubin/fix/5145-check-host-dev
runtime-rs: fix host device check pattern
2022-09-13 10:33:05 +08:00
Bin Liu
62cf6e6fc3 runtime-rs: remove meaningless comment
The comment for `generate_mount_path` function is a copy miss
and should be deleted.

Fixes: #5150

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-09 16:07:35 +08:00
Bin Liu
55f4f3a95b
Merge pull request #4897 from ManaSugi/runk/enable-seccomp
runk: Enable seccomp support by default
2022-09-09 14:11:35 +08: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
GabyCT
be462baa7e
Merge pull request #5103 from liubin/fix/5102-add-inline-virtiofs-config
config: add "inline-virtio-fs" as a "shared_fs" type
2022-09-08 10:33:20 -05:00
GabyCT
bcbce8317d
Merge pull request #5061 from liubin/fix/5022-runtime-rs-readme
runtime-rs: add README.md
2022-09-08 10:32:08 -05:00
bin liu
2b1d058572 runtime-rs: fix host device check pattern
Host devices should start with `/dev/` but not `/dev`.

Fixes: #5145

Signed-off-by: bin liu <liubin0329@gmail.com>
2022-09-08 22:44:46 +08:00
Bin Liu
85b49cee02 runtime-rs: add README.md
Add README.md for runtime-rs.

Fixes: #5022

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-08 16:03:45 +08: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
Ji-Xinyou
5add50aea2 runtime-rs: timeout for shim management client
Let client side support timeout if the timeout value is set.
If timeout not set, execute directly.

Fixes: #5114
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-09-08 11:11:33 +08:00
Bin Liu
36d805fab9 config: add "inline-virtio-fs" as a "shared_fs" type
"inline-virtio-fs" is newly supported by kata 3.0 as a "shared_fs" type,
it should be described in configuration file.

"inline-virtio-fs" is the same as "virtio-fs", but it is running in
the same process of shim, does not need an external virtiofsd process.

Fixes: #5102

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-08 11:05:01 +08:00
Bin Liu
5df6ff991d
Merge pull request #5116 from liubin/fix/5115-replace-tab-by-space
libs/kata-types: replace tabs by spaces in comments
2022-09-07 15:53:34 +08:00
Ji-Xinyou
9f13496e13 runtime-rs: shim management client
Add client side function(public), to establish http connections (PUT,
POST, GET) to the long standing shim mgmt server.

Fixes: #5114
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-09-07 15:39:14 +08:00
Bin Liu
aaf6d69089 runtime-rs: call TomlConfig's validate function after load
Call TomlConfig's validate function after it is loaded and
adjusted by annotations.

Fixes: #5112

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-07 11:34:08 +08:00
Bin Liu
fe55f6afd7
Merge pull request #5124 from amshinde/revert-arp-neighbour-api
Revert arp neighbour api
2022-09-07 11:14:53 +08:00
Ji-Xinyou
e891295e10 runtime-rs: shim management - agent-url
Add agent-url to its handler. The general framework of registering URL
handlers is done.

Fixes: #5114
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-09-07 11:13:21 +08:00
Chelsea Mafrica
051dabb0fe
Merge pull request #5099 from liubin/fix/5098-add-default-config-for-runtime-rs
runtime-rs: add default agent/runtime/hypervisor for configuration
2022-09-06 17:49:42 -07:00
Archana Shinde
d23779ec9b Revert "agent: fix unittests for arp neighbors"
This reverts commit 81fe51ab0b.
2022-09-06 15:41:42 -07:00
Archana Shinde
d340564d61 Revert "agent: use rtnetlink's neighbours API to add neighbors"
This reverts commit 845c1c03cf.

Fixes: #5126
2022-09-06 15:41:42 -07:00
Bin Liu
50f9126153 libs/kata-types: replace tabs by spaces in comments
Replace tabs by spaces in the comments of file
libs/kata-types/src/annotations/mod.rs.

Fixes: #5115

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-06 17:32:57 +08:00
Ji-Xinyou
59aeb776b0 runtime-rs: shim management
Add shim management http server and boot it as a light-weight thread
when the sandbox is created.

Fixes: #5114
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-09-06 16:44:16 +08:00
Bin Liu
96c8be715b libs/kata-types: change return type of getting CPU period/quota
period should have a type of u64, and quota should be i64, the
function of getting CPU period and quota from annotations should
use the same data type as function return type.

Fixes: #5100

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-06 11:35:52 +08:00
Bin Liu
fc9c6f87a3 kata-types: don't check virtio_fs_daemon for inline-virtio-fs
If the shared_fs is set to "inline-virtio-fs", the "virtio_fs_daemon"
should be ignored.

Fixes: #5104

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-05 17:44:28 +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
Bin Liu
e879270a0c runtime-rs: add default agent/runtime/hypervisor for configuration
Kata 3.0 introduced 3 new configurations under runtime section:

name="virt_container"
hypervisor_name="dragonball"
agent_name="kata"
Blank values will lead to starting to fail.

Adding default values will make user easy to migrate to kata 3.0.

Fixes: #5098

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-05 15:55:28 +08:00
Bin Liu
e5437a7084
Merge pull request #5063 from liubin/fix/5062-split-amend-spec
runtime-rs: split amend_spec function
2022-09-05 15:00:31 +08: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
Bin Liu
ba013c5d0f
Merge pull request #4744 from openanolis/runtime-rs-static_resource_mgmt
runtime-rs: support functionality of static resource management
2022-09-05 11:17:09 +08:00
Wainer Moschetta
e81a73b622
Merge pull request #4719 from bookinabox/cargo-deny
github-actions: Add cargo-deny
2022-09-02 17:24:50 -03:00
Bin Liu
86ad832e37 runtime-rs: force shutdown shim process in it can't exit
In some case the call of cleanup from shim to service manager will fail,
and the shim process will continue to running, that will make process leak.

This commit will force shutdown the shim process in case of any errors in
service crate.

Fixes: #5087

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-02 19:43:50 +08: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
Peng Tao
b5786361e9
Merge pull request #4862 from egernst/memory-hotplug-limitation
Address Memory hotplug limitation
2022-09-02 16:11:46 +08:00
Bin Liu
41ec71169f runtime-rs: split amend_spec function
amend_spec do two works:

- modify the spec
- check if the pid namespace is enabled

This make it confusable. So split it into two functions.

Fixes: #5062

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-09-01 14:44:54 +08:00
Ji-Xinyou
a828292b47 runtime-rs: add unit tests for network resource
Add UTs for network resource

Fixes: #4923
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-09-01 10:13:09 +08:00
Eric Ernst
9997ab064a sandbox_test: Add test to verify memory hotplug behavior
Augment the mock hypervisor so that we can validate that ACPI memory hotplug
is carried out as expected.

We'll augment the number of memory slots in the hypervisor config each
time the memory of the hypervisor is changed. In this way we can ensure
that large memory hotplugs are broken up into appropriately sized
pieces in the unit test.

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2022-08-31 10:32:30 -07:00
Eric Ernst
f390c122f0 sandbox: don't hotplug too much memory at once
If we're using ACPI hotplug for memory, there's a limitation on the
amount of memory which can be hotplugged at a single time.

During hotplug, we'll allocate memory for the memmap for each page,
resulting in a 64 byte per 4KiB page allocation. As an example, hotplugging 12GiB
of memory requires ~192 MiB of *free* memory, which is about the limit
we should expect for an idle 256 MiB guest (conservative heuristic of 75%
of provided memory).

From experimentation, at pod creation time we can reliably add 48 times
what is provided to the guest. (a factor of 48 results in using 75% of
provided memory for hotplug). Using prior example of a guest with 256Mi
RAM, 256 Mi * 48 = 12 Gi; 12GiB is upper end of what we should expect
can be hotplugged successfully into the guest.

Note: It isn't expected that we'll need to hotplug large amounts of RAM
after workloads have already started -- container additions are expected
to occur first in pod lifecycle. Based on this, we expect that provided
memory should be freely available for hotplug.

If virtio-mem is being utilized, there isn't such a limitation - we can
hotplug the max allowed memory at a single time.

Fixes: #4847

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2022-08-31 10:32:30 -07:00
Peng Tao
f1276180b1
Merge pull request #4996 from liubin/fix/4995-delete-socket-option-for-shim
runtime-rs: delete socket from shim command-line options
2022-08-31 14:16:56 +08:00
Bin Liu
515bdcb138
Merge pull request #4900 from wllenyj/dragonball-ut
Built-in Sandbox: add more unit tests for dragonball.
2022-08-31 14:00:07 +08:00
Eric Ernst
e0142db24f hypervisor: Add GetTotalMemoryMB to interface
It'll be useful to get the total memory provided to the guest
(hotplugged + coldplugged). We'll use this information when calcualting
how much memory we can add at a time when utilizing ACPI hotplug.

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2022-08-30 16:37:47 -07: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
aa581f4b28 cargo.toml: Add oci to src/libs workplace
Adds oci under the src/libs workplace.

oci shares a Cargo.lock file with the rest of src/libs but was not
listed as a member of the workspace.

There is no clear reason why it is not included in the workspace, so
adding it so cargo-deny stop complaining

Signed-off-by: Derek Lee <derlee@redhat.com>
2022-08-30 09:30:03 -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
Bin Liu
11383c2c0e
Merge pull request #4797 from openanolis/runtime-rs-coresched
runtime-rs: add support for core scheduling
2022-08-29 14:28:30 +08: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
Fupan Li
63959b0be6
Merge pull request #5011 from liubin/fix/4962-add-logs
agent: add some logs for mount operation
2022-08-26 17:12:15 +08:00
Bin Liu
c08a8631e0 agent: add some logs for mount operation
Somewhere is lack of log info, add more details about
the storage and log when error will help understand
what happened.

Fixes: #4962

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-08-26 14:09:56 +08:00
Archana Shinde
7d52934ec1
Merge pull request #4798 from amshinde/use-iouring-qemu
Use iouring for qemu block devices
2022-08-26 04:00:24 +05:30
Wainer Moschetta
cbe5e324ae
Merge pull request #4815 from bookinabox/improve-agent-errors
logging: Replace nix::Error::EINVAL with more descriptive msgs
2022-08-25 14:27:56 -03:00
Bin Liu
cce99c5c73 runtime-rs: delete socket from shim command-line options
The socket is not used to specify the socket address, but
an ENV variable is used for runtime-rs.

Fixes: #4995

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-08-25 15:32:17 +08:00
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
Fabiano Fidêncio
ddc94e00b0
Merge pull request #4982 from fidencio/topic/improve-cloud-hypervisor-plus-tdx-support
TDX: Get TDX working again with Cloud Hypervisor + a minor change on QEMU's code
2022-08-25 08:53:10 +02: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
Yushuo
4b57c04c33 runtime-rs: support loading kernel modules in guest vm
Users can specify the kernel module to be loaded through the agent
configuration in kata configuration file or in pod anotation file.

And information of those modules will be sent to kata agent when
sandbox is created.

Fixes: #4894

Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
2022-08-25 10:38:04 +08:00
Peng Tao
aa6bcacb7d
Merge pull request #4973 from bergwolf/github/go-depbot
runtime: cri-o annotations have been moved to podman
2022-08-25 10:12:06 +08:00
Fabiano Fidêncio
dc90eae17b qemu: Drop unnecessary tdx_guest kernel parameter
With the current TDX kernel used with Kata Containers, `tdx_guest` is
not needed, as TDX_GUEST is now a kernel configuration.

With this in mind, let's just drop the kernel parameter.

Fixes: #4981

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-08-24 20:02:43 +02:00
Fabiano Fidêncio
d4b67613f0 clh: Use HVC console with TDX
As right now the TDX guest kernel doesn't support "serial" console,
let's switch to using HVC in this case.

Fixes: #4980

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-08-24 20:02:40 +02:00
Fabiano Fidêncio
c0cb3cd4d8 clh: Avoid crashing when memory hotplug is not allowed
The runtime will crash when trying to resize memory when memory hotplug
is not allowed.

This happens because we cannot simply set the hotplug amount to zero,
leading is to not set memory hotplug at all, and later then trying to
access the value of a nil pointer.

Fixes: #4979

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-08-24 20:02:22 +02:00
Fabiano Fidêncio
9f0a57c0eb clh: Increase API and SandboxStop timeouts for TDX
While doing tests using `ctr`, I've noticed that I've been hitting those
timeouts more frequently than expected.

Till we find the root cause of the issue (which is *not* in the Kata
Containers), let's increase the timeouts when dealing with a
Confidential Guest.

Fixes: #4978

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-08-24 20:02:12 +02: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
Fabiano Fidêncio
c142fa2541 clh: Lift the sharedFS restriction used with TDX
When booting the TDX kernel with `tdx_disable_filter`, as it's been done
for QEMU, VirtioFS can work without any issues.

Whether this will be part of the upstream kernel or not is a different
story, but it easily could make it there as Cloud Hypervisor relies on
the VIRTIO_F_IOMMU_PLATFORM feature, which forces the guest to use the
DMA API, making these devices compatible with TDX.

See Sebastien Boeuf's explanation of this in the
3c973fa7ce208e7113f69424b7574b83f584885d commit:
"""
By using DMA API, the guest triggers the TDX codepath to share some of
the guest memory, in particular the virtqueues and associated buffers so
that the VMM and vhost-user backends/processes can access this memory.
"""

Fixes: #4977

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-08-24 17:14:05 +02: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
a06d819b24 runtime: cri-o annotations have been moved to podman
Let's swith to depending on podman which also simplies indirect
dependency on kubernetes components. And it helps to avoid cri-o
security issues like CVE-2022-1708 as well.

Fixes: #4972
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-08-24 18:11:37 +08: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
Peng Tao
e0ec09039d runtime-rs: update async-std dependency
So that we bump several indirect dependencies like crossbeam-channel,
crossbeam-utils to bring in fixes to known security issues like CVE-2020-15254.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-08-24 16:56:29 +08:00
Bin Liu
2b5dc2ad39
Merge pull request #4705 from bergwolf/github/agent-ut-improve
UT: test_load_kernel_module needs root
2022-08-24 16:22:55 +08:00
Bin Liu
6551d4f25a
Merge pull request #4051 from bergwolf/github/vmx-vm-factory
enable vmx for vm factory
2022-08-24 16:22:37 +08:00
Bin Liu
ad91801240
Merge pull request #4870 from cyyzero/runk-cgroup
runk: add pause/resume commands
2022-08-24 14:44:43 +08:00
Derek Lee
763ceeb7ba logging: Replace nix::Error::EINVAL with more descriptive msgs
Replaces instances of anyhow!(nix::Error::EINVAL) with other messages to
make it easier to debug.

Fixes #954

Signed-off-by: Derek Lee <derlee@redhat.com>
2022-08-23 13:44:46 -07: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
Fabiano Fidêncio
d797036b77
Merge pull request #4861 from ryansavino/upgrade-kernel-support-5.19
kernel: upgrade guest kernel support to 5.19
2022-08-22 14:57:00 +02:00
Bin Liu
8c8e97a495
Merge pull request #4772 from pmores/drop-in-cfg-files-support-rs
Drop-in cfg files support in runtime-rs
2022-08-22 13:41:56 +08:00
Bin Liu
eb91ee45be
Merge pull request #4754 from liubin/fix/4749-rollback-when-creating-container-failed
agent: do some rollback works if case of do_create_container failed
2022-08-22 10:44:11 +08:00
Ryan Savino
8e201501ef kernel: fix for set_kmem_limit error
Fixes: #4390

Fix in cargo cgroups-rs crate - Updated crate version to 0.2.10

Signed-Off-By: Ryan Savino <ryan.savino@amd.com>
2022-08-19 13:08:14 -05:00
Fabiano Fidêncio
9806ce8615
Merge pull request #4937 from chenhengqi/fix-error-msg
network: Fix error message for setting hardware address on TAP interface
2022-08-19 17:54:58 +02:00
Pavel Mores
57bd3f42d3 runtime-rs: plug drop-in decoding into config-loading code
To plug drop-in support into existing config-loading code in a robust
way, more specifically to create a single point where this needs to be
handled, load_from_file() and load_raw_from_file() were refactored.
Seeing as the original implemenations of both functions were identical
apart from adjust_config() calls in load_from_file(), load_from_file()
was reimplemented in terms of load_raw_from_file().

Fixes  #4771

Signed-off-by: Pavel Mores <pmores@redhat.com>
2022-08-19 11:01:29 +02:00
Pavel Mores
87b97b6994 runtime-rs: add filesystem-related part of drop-in handling
The central function being added here is load() which takes a path to a
base config file and uses it to load the base config file itself, find
the corresponding drop-in directory (get_dropin_dir_path()), iterate
through its contents (update_from_dropins()) and load each drop-in in
turn and merge its contents with the base file (update_from_dropin()).

Also added is a test of load() which mirrors the corresponding test in
the golang runtime (TestLoadDropInConfiguration() in config_test.go).

Signed-off-by: Pavel Mores <pmores@redhat.com>
2022-08-19 11:01:29 +02:00
Pavel Mores
cf785a1a23 runtime-rs: add core toml::Value tree merging
This is the core functionality of merging config file fragments into the
base config file.  Our TOML parser crate doesn't seem to allow working
at the level of TomlConfig instances like BurntSushi, used in the Golang
runtime, does so we implement the required functionality at the level of
toml::Value trees.

Tests to verify basic requirements are included.  Values set by a base
config file and not touched by a subsequent drop-in should be preserved.
Drop-in config file fragments should be able to change values set by the
base config file and add settings not present in the base.  Conversion
of a merged tree into a mock TomlConfig-style structure is tested as
well.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2022-08-19 11:01:29 +02:00
Fabiano Fidêncio
828383bc39
Merge pull request #4933 from likebreath/0816/prepare_clh_v26.0
Upgrade to Cloud Hypervisor v26.0
2022-08-18 18:36:53 +02:00
James O. D. Hunt
6d6edb0bb3
Merge pull request #4903 from cmaf/tracing-defer-rootSpan-end
runtime: tracing: End root span at end of trace
2022-08-18 08:51:41 +01:00
Peng Tao
f508c2909a runtime: constify splitIrqChipMachineOptions
A simple cleanup.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-08-18 10:09:20 +08:00
Peng Tao
2b0587db95 runtime: VMX is migratible in vm factory case
We are not spinning up any L2 guests in vm factory, so the L1 guest
migration is expected to work even with VMX.

See https://www.linux-kvm.org/page/Nested_Guests

Fixes: #4050
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-08-18 10:08:43 +08:00
Peng Tao
fa09f0ec84 runtime: remove qemuPaths
It is broken that it doesn't list QemuVirt machine type. In fact we
don't need it at all. Just drop it.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-08-18 10:06:10 +08:00
Peng Tao
326f1cc773 agent: enrich some error code path
So that it is easier to find out why some function fails.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-08-18 10:02:12 +08:00
Peng Tao
4f53e010b4 agent: skip test_load_kernel_module if non-root
We need root privilege to load a real kernel module.

Fixes: #4704
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-08-18 10:02:12 +08:00
Bo Chen
3a597c2742 runtime: clh: Use the new 'payload' interface
The new 'payload' interface now contains the 'kernel' and 'initramfs'
config.

Fixes: #4952

Signed-off-by: Bo Chen <chen.bo@intel.com>
2022-08-17 12:23:43 -07:00
Bo Chen
16baecc5b1 runtime: clh: Re-generate the client code
This patch re-generates the client code for Cloud Hypervisor v26.0.
Note: The client code of cloud-hypervisor's (CLH) OpenAPI is
automatically generated by openapi-generator [1-2].

[1] https://github.com/OpenAPITools/openapi-generator
[2] https://github.com/kata-containers/kata-containers/blob/main/src/runtime/virtcontainers/pkg/cloud-hypervisor/README.md

Fixes: #4952

Signed-off-by: Bo Chen <chen.bo@intel.com>
2022-08-17 12:23:12 -07:00
wllenyj
c75970b816 dragonball: add more unit test for config manager
Added more unit tests for config manager.

Fixes: #4899

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-08-17 23:46:26 +08:00
Hengqi Chen
8ff5c10ac4 network: Fix error message for setting hardware address on TAP interface
Error out with the correct interface name and hardware address instead.

Fixes: #4944

Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
2022-08-17 16:42:07 +08:00
Peng Tao
338c282950 dep: update nix dependency
To fix CVE-2021-45707 that affects nix < 0.20.2.

Fixes: #4929
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-08-17 16:06:26 +08:00
James O. D. Hunt
82ad43f9bf
Merge pull request #4928 from liubin/fix/4925-share-test-utils-for-rust
libs/test-utils: share test code by create a new crate
2022-08-17 08:31:11 +01:00
Bin Liu
8cd1e50eb6
Merge pull request #4921 from liubin/fix/2920-delete-vergen
runtime-rs: delete vergen dependency
2022-08-17 10:09:12 +08:00
Bin Liu
34746496b7 libs/test-utils: share test code by create a new crate
More and more Rust code is introduced, the test utils original in agent
should be made easy to share, move it into a new crate will make it
easy to share between different crates.

Fixes: #4925

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-08-17 00:12:44 +08:00
Bin Liu
eab7c8f28f runtime-rs: delete vergen dependency
vergen is a build dependency, but it is not being used.
we are processing ver/commit hash by make command, but not by vergen.

Fixes: #4920

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-08-16 15:31:24 +08:00
Bin Liu
828574d27c
Merge pull request #4893 from openanolis/runtime-rs-main
Runtime-rs: support persist file
2022-08-16 14:42:22 +08:00
Bin Liu
830fb266e6
Merge pull request #4854 from openanolis/runtime-rs-delete
runtime-rs: delete route model
2022-08-15 20:48:58 +08:00
Ji-Xinyou
ff7c78e0e8 runtime-rs: static resource mgmt default to false
Static resource management should be default to false. If default to be
true, later update sandbox operation, e.g. resize, will not work.

Fixes: #4742
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-08-15 14:42:38 +08:00
Ji-Xinyou
00f3a6de12 runtime-rs: make static resource mgmt idiomatic
Make the get value process (cpu and mem) more idiomatic.

Fixes: #4742
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-08-15 11:18:35 +08:00
Zhongtao Hu
4d7f3edbaf runtime-rs: support the functionality of cleanup
Cleanup sandbox resource

Fixes: #4891
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-08-13 15:56:38 +08:00
Zhongtao Hu
5aa83754e5 runtime-rs: support save to persist file and restore
Support the functionality of save and restore for sandbox state

Fixes:#4891
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-08-13 15:44:13 +08:00
Chelsea Mafrica
fcc1e0c617 runtime: tracing: End root span at end of trace
The root span should exist the duration of the trace. Defer ending span
until the end of the trace instead of end of function. Add the span to
the service struct to do so.

Fixes #4902

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
2022-08-12 13:15:39 -07:00
Zhongtao Hu
c280d6965b runtime-rs: delete route model
As route model is used for specific internal scenario, and it's not for
the general requirement.

Fixes:#4838
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-08-11 15:56:43 +08:00
Bin Liu
ca9d16e5ea runtime-rs: update Cargo.lock
Update Cargo.lock

Fixes: #4875

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-08-11 10:34:36 +08:00
Ji-Xinyou
4a54876dde runtime-rs: support static resource management functionality
Supports functionalities of static resource management, enabled by
default.

Fixes: #4742
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-08-11 09:46:44 +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
Tim Zhang
4813a3cef9
Merge pull request #4711 from liubin/fix/4710-wait-nydusd-api-server-ready
nydus: wait nydusd API server ready before mounting share fs
2022-08-10 17:20:17 +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
liubin
2ae807fd29 nydus: wait nydusd API server ready before mounting share fs
If the API server is not ready, the mount call will fail, so before
mounting share fs, we should wait the nydusd is started and
the API server is ready.

Fixes: #4710

Signed-off-by: liubin <liubin0329@gmail.com>
Signed-off-by: Bin Liu <bin@hyper.sh>
2022-08-08 16:18:38 +08:00
Tim Zhang
8d4d98587f
Merge pull request #4746 from liubin/fix/4745-add-log-field
runtime: explicitly mark the source of the log is from qemu.log
2022-08-08 15:21:01 +08:00
Bin Liu
9516286f6d
Merge pull request #4829 from LetFu/fix/addUnlock
runtime: add unlock before return in sendReq
2022-08-08 14:42:44 +08:00
Archana Shinde
c1e3b8f40f govmm: Refactor qmp functions for adding block device
Instead of passing a bunch of arguments to qmp functions for
adding block devices, use govmm BlockDevice structure to reduce these.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2022-08-05 13:16:34 -07:00
Archana Shinde
598884f374 govmm: Refactor code to get rid of redundant code
Get rid of redundant return values from function.
args and blockdevArgs used to return different values to maintain
compatilibity between qemu versions. These are exactly the same now.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2022-08-05 13:16:34 -07:00
Archana Shinde
00860a7e43 qmp: Pass aio backend while adding block device
Allow govmm to pass aio backend while adding block device.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2022-08-05 13:16:34 -07:00
Archana Shinde
e1b49d7586 config: Add block aio as a supported annotation
Allow Block AIO to be passed as a per pod annotation.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2022-08-05 13:16:34 -07:00
Archana Shinde
ed0f1d0b32 config: Add "block_device_aio" as a config option for qemu
This configuration will allow users to choose between different
I/O backends for qemu, with the default being io_uring.
This will allow users to fallback to a different I/O mechanism while
running on kernels olders than 5.1.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2022-08-05 13:16:34 -07:00
Fabiano Fidêncio
e2968b177d
Merge pull request #4763 from cyyzero/runk-ps
runk: add ps sub-command
2022-08-05 16:28:38 +02:00
chmod100
d8ad16a34e runtime: add unlock before return in sendReq
Unlock is required before return, so there need to add unlock

Fixes: #4827

Signed-off-by: chmod100 <letfu@outlook.com>
2022-08-05 13:30:12 +00:00
Peng Tao
b828190158 Merge pull request #4823 from openanolis/runtime-rs-merge-main-runtime-rs
Depends-on:github.com/kata-containers/tests#4986
Runtime-rs:merge main runtime rs
2022-08-05 14:42:22 +08:00
Zhongtao Hu
8bbffc42cf runtime-rs:update rtnetlink version
update rtnetlink version for runtime-rs

Fixes:#4824
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-08-05 11:18:09 +08:00
Zhongtao Hu
e403838131 runtim-rs: Merge remote-tracking branch 'origin/main' into runtime-rs
To keep runtime-rs up to date, we will merge main into runtime-rs every
week.

Fixes:kata-containers#4822
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-08-05 10:49:33 +08:00
GabyCT
2764bd7522
Merge pull request #4770 from justxuewei/refactor/agent/netlink-neighbor
agent: Use rtnetlink's neighbours API to add neighbors
2022-08-04 12:09:30 -05:00
Zhongtao Hu
389ae97020 runtime-rs:skip the test when the arch is s390x
github.com/kata-containers/tests#4986.To avoid returning an error when
running the ci, we just skip the test if the arch is s390x

Fixes: #4816
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-08-04 21:13:50 +08:00
Zhongtao Hu
945e02227c runtime-rs:skip the build process when the arch is s390x
github.com/kata-containers/tests#4986.To avoid returning an error when running the ci, we just skip the build
process if the arch is s390x

Fixes: #4816
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-08-04 21:13:40 +08:00
Archana Shinde
b6cd2348f5 govmm: Add io_uring as AIO type
io_uring was introduced as a new kernel IO interface in kernel 5.1.
It is designed for higher performance than the older Linux AIO API.
This feature was added in qemu 5.0.

Fixes #4645

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2022-08-03 10:43:12 -07:00
Archana Shinde
81cdaf0771 govmm: Correct documentation for Linux aio.
The comments for "native" aio are incorrect. Correct these.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2022-08-03 10:41:50 -07:00
Ji-Xinyou
a355812e05 runtime-rs: fixed bug on core-sched error handling
Kernel code returns -errno, this should check negative values.

Fixes: #4429
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-08-03 15:26:48 +08:00
Bin Liu
8b0e1859cb
Merge pull request #4784 from openanolis/fix-protocol-ci-err
libs: fix CI error for protocols
2022-08-03 11:03:02 +08: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
Ji-Xinyou
591dfa4fe6 runtime-rs: add support for core scheduling
Linux 5.14 supports core scheduling to have better security control
for SMT siblings. This PR supports that.

Fixes: #4429
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-08-02 17:54:04 +08:00
Zhongtao Hu
7247575fa2 runtime-rs:fix cargo clippy
fix cargo clippy

Fixes: #4791
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-08-02 13:17:37 +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
Quanwei Zhou
86ac653ba7 libs: fix CI error for protocols
Fix CI error for protocols.

Fixes: #4781
Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com>
2022-08-01 16:26:52 +08:00
Xuewei Niu
81fe51ab0b agent: fix unittests for arp neighbors
Set an ARP address explicitly before netlink::test_add_one_arp_neighbor() running.

Signed-off-by: Xuewei Niu <justxuewei@apache.org>
2022-08-01 16:19:25 +08:00
Xuewei Niu
845c1c03cf agent: use rtnetlink's neighbours API to add neighbors
Bump rtnetlink version from 0.8.0 to 0.11.0. Use rtnetlinks's API to
add neighbors and fix issues to adapt new verson of rtnetlink.

Fixes: #4607

Signed-off-by: Xuewei Niu <justxuewei@apache.org>
2022-08-01 13:44:07 +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
Peng Tao
0aefab4d80
Merge pull request #4739 from liubin/fix/4738-trace-rpc-calls
agent: log RPC calls for debugging
2022-07-29 14:18:23 +08:00
Peng Tao
5457deb034
Merge pull request #4741 from openanolis/fix-stop-failed-in-azure
runtime-rs: fix stop failed in azure
2022-07-29 11:41:16 +08:00
Quanwei Zhou
fa0b11fc52 runtime-rs: fix stdin hang in azure
Fix stdin hang in azure.

Fixes: #4740
Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com>
2022-07-28 16:16:37 +08:00
yaoyinnan
5c3155f7e2 runtime: Support for host cgroup v2
Support cgroup v2 on the host. Update vendor containerd/cgroups to add cgroup v2.

Fixes: #3073

Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
2022-07-28 10:30:45 +08:00
Bin Liu
50b0b7cc15
Merge pull request #4681 from Tim-0731-Hzt/runtime-rs-sharepid
runtime-rs: fix set share sandbox pid namespace
2022-07-27 21:43:58 +08:00
Bin Liu
557229c39d
Merge pull request #4724 from yahaa/fix-docs
Docs: fix tables format error
2022-07-27 21:13:29 +08:00
Bin Liu
09672eb2da agent: do some rollback works if case of do_create_container failed
In some cases do_create_container may return an error, mostly due to
`container.start(process)` call. This commit will do some rollback
works if this function failed.

Fixes: #4749

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-07-27 10:23:46 +08:00
Archana Shinde
1b01ea53d9
Merge pull request #4735 from nubificus/feature-fc-v1.1
versions: Update Firecracker version to v1.1.0
2022-07-27 04:50:32 +05:30
Peng Tao
27c82018d1
Merge pull request #4753 from Tim-Zhang/agent-fix-stream-fd-double-close
agent: Fix stream fd's double close
2022-07-27 00:54:07 +08:00
Bin Liu
6fddf031df
Merge pull request #4664 from lifupan/main
container: kill all of the processes in a container when it terminated
2022-07-26 23:12:11 +08:00
Tim Zhang
f5aa6ae467 agent: Fix stream fd's double close problem
The fd would be closed on Pipestream's dropping and we should
not close it agian.

Fixes: #4752

Signed-off-by: Tim Zhang <tim@hyper.sh>
2022-07-26 20:05:06 +08:00
yahaa
6e149b43f7 Docs: fix tables format error
Fixes: #4725

Signed-off-by: yahaa <1477765176@qq.com>
2022-07-26 19:05:09 +08:00
Bin Liu
85f4e7caf6 runtime: explicitly mark the source of the log is from qemu.log
In qemu.StopVM(), if debug is enabled, the shim will dump logs
from qemu.log, but users don't know which logs are from qemu.log
and shim itself. Adding some additional messages will
help users to distinguish these logs.

Fixes: #4745

Signed-off-by: Bin Liu <bin@hyper.sh>
2022-07-26 16:08:59 +08:00
Peng Tao
129335714b
Merge pull request #4727 from openanolis/anolis-fix-network
fix network failed for kata ci
2022-07-26 15:10:55 +08:00
Peng Tao
71384b60f3
Merge pull request #4713 from openanolis/adjust_default_vcpu
runtime-rs: handle default_vcpus greator than default_maxvcpu
2022-07-26 15:02:34 +08:00
gntouts
56d49b5073 versions: Update Firecracker version to v1.1.0
This patch upgrades Firecracker version from v0.23.4 to v1.1.0

* Generate swagger models for v1.1.0 (from firecracker.yaml)
* Replace ht_enabled param to smt (API change)
* Remove NUMA-related jailer param --node 0

Fixes: #4673
Depends-on: github.com/kata-containers/tests#4968

Signed-off-by: George Ntoutsos <gntouts@nubificus.co.uk>
Signed-off-by: Anastassios Nanos <ananos@nubificus.co.uk>
2022-07-26 07:01:26 +00:00
Zhongtao Hu
b3147411e3 runtime-rs:add unit test for set share pid ns
Fixes:#4680
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-07-26 14:42:00 +08:00
Zhongtao Hu
1ef3f8eac6 runtime-rs: set share sandbox pid namespace
Set the share sandbox pid namepsace from spec

Fixes:#4680
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-07-26 14:41:59 +08:00
Quanwei Zhou
57c556a801 runtime-rs: fix stop failed in azure
Fix the stop failed in azure.

Fixes: #4740
Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com>
2022-07-26 12:16:32 +08:00
liubin
0e24f47a43 agent: log RPC calls for debugging
We can log all RPC calls to the agent for debugging purposes
to check which RPC is called, which can help us to understand
the container lifespan.

Fixes: #4738

Signed-off-by: liubin <liubin0329@gmail.com>
2022-07-26 10:32:44 +08:00
Tim Zhang
e764a726ab
Merge pull request #4715 from Tim-Zhang/fix-ut-test_do_write_stream
agent: fix fd-double-close problem in ut test_do_write_stream
2022-07-25 17:34:26 +08:00
Peng Tao
3f4dd92c2d
Merge pull request #4702 from openanolis/runtime-rs-endpoint-dev
runtime-rs: add functionalities support for macvlan and vlan endpoints
2022-07-25 17:04:45 +08:00
Tim Zhang
427b29454a
Merge pull request #4709 from liubin/fix/4708-unwrap-error
rustjail: check result to let it return early
2022-07-25 15:05:20 +08:00
Quanwei Zhou
c825065b27 runtime-rs: fix tc filter setup failed
Fix bug using tc filter and protocol needs to use network byte order.

Fixes: #4726
Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com>
2022-07-25 11:16:33 +08:00
Quanwei Zhou
e0194dcb5e runtime-rs: update route destination with prefix
Update route destination with prefix.

Fixes: #4726
Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com>
2022-07-25 11:16:22 +08:00
Wainer Moschetta
0b4a91ec1a
Merge pull request #4644 from bookinabox/optimize-get-paths
cgroups: remove unnecessary get_paths()
2022-07-22 17:01:01 -03:00
Ji-Xinyou
896478c92b runtime-rs: add functionalities support for macvlan and vlan endpoints
Add macvlan and vlan support to runtime-rs code and corresponding unit
tests.

Fixes: #4701
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-07-22 10:09:11 +08:00
Tim Zhang
912641509e agent: fix fd-double-close problem in ut test_do_write_stream
The fd will closed on struct Process's dropping, so don't
close it again manually.

Fixes: #4598

Signed-off-by: Tim Zhang <tim@hyper.sh>
2022-07-21 19:37:15 +08:00
Zhongtao Hu
43045be8d1 runtime-rs: handle default_vcpus greator than default_maxvcpu
when the default_vcpus is greater than the default_maxvcpus, the default
vcpu number should be set equal to the default_maxvcpus.

Fixes: #4712
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-07-21 16:37:56 +08:00
liubin
0d7cb7eb16 agent: delete agent-type property in announce
Since there is only one type of agent now, the
agent-type is not needed anymore.

Signed-off-by: liubin <liubin0329@gmail.com>
2022-07-21 14:53:01 +08:00
liubin
eec9ac81ef rustjail: check result to let it return early.
check the result to let it return early if there are some errors

Fixes: #4708

Signed-off-by: liubin <liubin0329@gmail.com>
2022-07-21 14:51:30 +08:00
Quanwei Zhou
54f53d57ef runtime-rs: support disable_guest_seccomp
support disable_guest_seccomp

Fixes: #4691
Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com>
2022-07-21 07:46:28 +08:00
Bin Liu
540303880e
Merge pull request #4688 from quanweiZhou/fix_sandbox_cgroup_false
runtime-rs: fix sandbox_cgroup_only=false panic
2022-07-19 20:38:57 +08:00
Peng Tao
7c146a5d95
Merge pull request #4684 from quanweiZhou/fix-ctr-exit-error
runtime-rs: fix ctr exit failed
2022-07-19 16:02:20 +08:00
Peng Tao
4c3bd6b1d1
Merge pull request #4656 from openanolis/runtime-rs-ipvlan
runtime-rs: support functionalities of ipvlan endpoint
2022-07-19 11:15:31 +08:00
Bin Liu
960f2a7f70
Merge pull request #4678 from Tim-0731-Hzt/runtime-rs-makefile-2
runtime-rs: remove the value of hypervisor path in DB config
2022-07-19 09:34:45 +08:00
Quanwei Zhou
e9988f0c68 runtime-rs: fix sandbox_cgroup_only=false panic
When run with configuration `sandbox_cgroup_only=false`, we will call
`gen_overhead_path()` as the overhead path. The `cgroup-rs` will push
the path with the subsystem prefix by `PathBuf::push()`. When the path
has prefix “/” it will act as root path, such as
```
let mut path = PathBuf::from("/tmp");
path.push("/etc");
assert_eq!(path, PathBuf::from("/etc"));
```
So we shoud not set overhead path with prefix "/".

Fixes: #4687
Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com>
2022-07-19 08:30:34 +08:00
Quanwei Zhou
cebbebbe8a runtime-rs: fix ctr exit failed
During use, there will be cases where the container is in the stop state
and get another stop. In this case, the second stop needs to be ignored.

Fixes: #4683
Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com>
2022-07-19 07:43:22 +08:00
Bin Liu
758cc47b32
Merge pull request #4671 from liubin/4670-upgrade-nix
kata-sys-util: upgrade nix version
2022-07-18 23:31:07 +08:00
Ji-Xinyou
62182db645 runtime-rs: add unit test for ipvlan endpoint
Add unit test to check the integrity of IPVlanEndpoint::new(...)

Fixes: #4655
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-07-18 15:56:06 +08:00
xuejun-xj
99654ce694 runtime-rs: update dbs-xxx dependencies
Update dbs-xxx commit ID for aarch64 in runtime-rs/Cargo.toml file to add
dependencies for aarch64.

Fixes: #4676

Signed-off-by: xuejun-xj <jiyunxue@alibaba.linux.com>
2022-07-18 13:46:46 +08:00
xuejun-xj
f4c3adf596 runtime-rs: Add compile option file
Add file aarch64-options.mk for compiling on aarch64 architectures.

Fixes: #4676

Signed-off-by: xuejun-xj <jiyunxue@alibaba.linux.com>
2022-07-18 13:46:46 +08:00
xuejun-xj
545ae3f0ee runtime-rs: fix warning
Module anyhow::anyhow is only used on x86_64 architecture in
crates/hypervisor/src/device/vfio.rs file.

Fixes: #4676

Signed-off-by: xuejun-xj <jiyunxue@alibaba.linux.com>
2022-07-18 13:46:39 +08:00
Zhongtao Hu
19eca71cd9 runtime-rs: remove the value of hypervisor path in DB config
As a built in VMM, Path, jailer path, ctlpath are not needed for
Dragonball. So we don't generate those value in Makefile.

Fixes: #4677
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-07-18 13:37:51 +08:00
Ji-Xinyou
d8920b00cd runtime-rs: support functionalities of ipvlan endpoint
Add support for ipvlan endpoint

Fixes: #4655
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
2022-07-18 11:34:03 +08:00
xuejun-xj
2b01e9ba40 dragonball: fix warning
Add map_err for vcpu_manager.set_reset_event_fd() function.

Fixes: #4676

Signed-off-by: xuejun-xj <jiyunxue@alibaba.linux.com>
2022-07-18 09:52:13 +08:00
liubin
996a6b80bc kata-sys-util: upgrade nix version
New nix is supporting UMOUNT_NOFOLLOW, upgrade nix
version to use this flag instead of the self-defined flag.

Fixes: #4670

Signed-off-by: liubin <liubin0329@gmail.com>
2022-07-15 17:38:15 +08:00
Fupan Li
d93e4b939d container: kill all of the processes in this container
When a container terminated, we should make sure there's no processes
left after destroying the container.

Before this commit, kata-agent depended on the kernel's pidns
to destroy all of the process in a container after the 1 process
exit in a container. This is true for those container using a
separated pidns, but for the case of shared pidns within the
sandbox, the container exit wouldn't trigger the pidns terminated,
and there would be some daemon process left in this container, this
wasn't expected.

Fixes: #4663

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2022-07-14 16:39:49 +08:00
Bin Liu
575b5eb5f5
Merge pull request #4506 from cyyzero/runk-exec
runk: Support `exec` sub-command
2022-07-14 14:22:24 +08:00
Quanwei Zhou
3c989521b1 dragonball: update for review
update for review

Fixes: #3785
Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com>
2022-07-14 10:43:59 +08:00
wllenyj
274598ae56 kata-runtime: add dragonball config check support.
add dragonball config check support.

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-07-14 10:43:50 +08:00
Chao Wu
1befbe6738 runtime-rs: Cargo lock for fix version problem
Cargo lock for fix version problem

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-07-14 08:49:39 +08: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
Zhongtao Hu
3f6123b4dd libs: update configuration and annotations
1. support annotation for runtime.name, hypervisor_name, agent_name.
2. fix parse memory from annotation

Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-07-14 08:49:17 +08:00
Derek Lee
9ae2a45b38 cgroups: remove unnecessary get_paths()
Change get_mounts to get paths from a borrowed argument rather than
calling get_paths a second time.

Fixes #3768

Signed-off-by: Derek Lee <derlee@redhat.com>
2022-07-13 09:17:14 -07:00
Fabiano Fidêncio
be31207f6e clh: Don't crash if no network device is set by the upper layer
`ctr` doesn't set a network device when creating the sandbox, which
leads to Cloud Hypervisor's driver crashing, see the log below:
```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x55641c23b248]
goroutine 32 [running]:
github.com/kata-containers/kata-containers/src/runtime/virtcontainers.glob..func1(0xc000397900)
	/home/ubuntu/go/src/github.com/kata-containers/kata-containers/src/runtime/virtcontainers/clh.go:163 +0x128
github.com/kata-containers/kata-containers/src/runtime/virtcontainers.(*cloudHypervisor).vmAddNetPut(...)
	/home/ubuntu/go/src/github.com/kata-containers/kata-containers/src/runtime/virtcontainers/clh.go:1348
github.com/kata-containers/kata-containers/src/runtime/virtcontainers.(*cloudHypervisor).bootVM(0xc000397900, {0x55641c76dfc0, 0xc000454ae0})
	/home/ubuntu/go/src/github.com/kata-containers/kata-containers/src/runtime/virtcontainers/clh.go:1378 +0x5a2
github.com/kata-containers/kata-containers/src/runtime/virtcontainers.(*cloudHypervisor).StartVM(0xc000397900, {0x55641c76dff8, 0xc00044c240},
0x55641b8016fd)
        /home/ubuntu/go/src/github.com/kata-containers/kata-containers/src/runtime/virtcontainers/clh.go:659 +0x7ee
github.com/kata-containers/kata-containers/src/runtime/virtcontainers.(*Sandbox).startVM.func2()
        /home/ubuntu/go/src/github.com/kata-containers/kata-containers/src/runtime/virtcontainers/sandbox.go:1219 +0x190
github.com/kata-containers/kata-containers/src/runtime/virtcontainers.(*LinuxNetwork).Run.func1({0xc0004a8910, 0x3b})
        /home/ubuntu/go/src/github.com/kata-containers/kata-containers/src/runtime/virtcontainers/network_linux.go:319 +0x1b
github.com/kata-containers/kata-containers/src/runtime/virtcontainers.doNetNS({0xc000048440, 0xc00044c240}, 0xc0005d5b38)
        /home/ubuntu/go/src/github.com/kata-containers/kata-containers/src/runtime/virtcontainers/network_linux.go:1045 +0x163
github.com/kata-containers/kata-containers/src/runtime/virtcontainers.(*LinuxNetwork).Run(0xc000150c80, {0x55641c76dff8, 0xc00044c240}, 0xc00014e4e0)
	/home/ubuntu/go/src/github.com/kata-containers/kata-containers/src/runtime/virtcontainers/network_linux.go:318 +0x105
github.com/kata-containers/kata-containers/src/runtime/virtcontainers.(*Sandbox).startVM(0xc000107d40, {0x55641c76dff8, 0xc0005529f0})
	/home/ubuntu/go/src/github.com/kata-containers/kata-containers/src/runtime/virtcontainers/sandbox.go:1205 +0x65f
github.com/kata-containers/kata-containers/src/runtime/virtcontainers.createSandboxFromConfig({_, _}, {{0x0, 0x0, 0x0}, {0xc000385a00, 0x1, 0x1},
{0x55641d033260, 0x0, ...}, ...}, ...)
        /home/ubuntu/go/src/github.com/kata-containers/kata-containers/src/runtime/virtcontainers/api.go:91 +0x346
github.com/kata-containers/kata-containers/src/runtime/virtcontainers.CreateSandbox({_, _}, {{0x0, 0x0, 0x0}, {0xc000385a00, 0x1, 0x1},
{0x55641d033260, 0x0, ...}, ...}, ...)
        /home/ubuntu/go/src/github.com/kata-containers/kata-containers/src/runtime/virtcontainers/api.go:51 +0x150
github.com/kata-containers/kata-containers/src/runtime/virtcontainers.(*VCImpl).CreateSandbox(_, {_, _}, {{0x0, 0x0, 0x0}, {0xc000385a00, 0x1, 0x1},
{0x55641d033260, ...}, ...})
        /home/ubuntu/go/src/github.com/kata-containers/kata-containers/src/runtime/virtcontainers/implementation.go:35 +0x74
github.com/kata-containers/kata-containers/src/runtime/pkg/katautils.CreateSandbox({_, _}, {_, _}, {{0xc0004806c0, 0x9}, 0xc000140110, 0xc00000f7a0,
{0x0, 0x0}, ...}, ...)
        /home/ubuntu/go/src/github.com/kata-containers/kata-containers/src/runtime/pkg/katautils/create.go:175 +0x8b6
github.com/kata-containers/kata-containers/src/runtime/pkg/containerd-shim-v2.create({0x55641c76dff8, 0xc0004129f0}, 0xc00034a000, 0xc00036a000)
        /home/ubuntu/go/src/github.com/kata-containers/kata-containers/src/runtime/pkg/containerd-shim-v2/create.go:147 +0xdea
github.com/kata-containers/kata-containers/src/runtime/pkg/containerd-shim-v2.(*service).Create.func2()
        /home/ubuntu/go/src/github.com/kata-containers/kata-containers/src/runtime/pkg/containerd-shim-v2/service.go:401 +0x32
created by github.com/kata-containers/kata-containers/src/runtime/pkg/containerd-shim-v2.(*service).Create
        /home/ubuntu/go/src/github.com/kata-containers/kata-containers/src/runtime/pkg/containerd-shim-v2/service.go:400 +0x534
```

This bug has been introduced as part of the
https://github.com/kata-containers/kata-containers/pull/4312 PR, which
changed how we add the network device.

In order to avoid the crash, let's simply check whether we have a device
to be added before iterating the list of network devices.

Fixes: #4618

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-07-13 10:40:21 +02:00
Fabiano Fidêncio
dc3b6f6592 versions: Update Cloud Hypervisor to v25.0
Cloud Hypervisor v25.0 has been released on July 7th, 2022, and brings
the following changes:

**ch-remote Improvements**
The ch-remote command has gained support for creating the VM from a JSON
config and support for booting and deleting the VM from the VMM.

**VM "Coredump" Support**
Under the guest_debug feature flag it is now possible to extract the memory
of the guest for use in debugging with e.g. the crash utility.
(https://github.com/cloud-hypervisor/cloud-hypervisor/issues/4012)

**Notable Bug Fixes**
* Always restore console mode on exit
  (https://github.com/cloud-hypervisor/cloud-hypervisor/issues/4249,
   https://github.com/cloud-hypervisor/cloud-hypervisor/issues/4248)
* Restore vCPUs in numerical order which fixes aarch64 snapshot/restore
  (https://github.com/cloud-hypervisor/cloud-hypervisor/issues/4244)
* Don't try and configure IFF_RUNNING on TAP devices
  (https://github.com/cloud-hypervisor/cloud-hypervisor/issues/4279)
* Propagate configured queue size through to vhost-user backend
  (https://github.com/cloud-hypervisor/cloud-hypervisor/issues/4286)
* Always Program vCPU CPUID before running the vCPU to fix running on Linux
  5.16
  (https://github.com/cloud-hypervisor/cloud-hypervisor/issues/4156)
* Enable ACPI MADT "Online Capable" flag for hotpluggable vCPUs to fix newer
  Linux guest

**Removals**
The following functionality has been removed:

* The mergeable option from the virtio-pmem support has been removed
  (https://github.com/cloud-hypervisor/cloud-hypervisor/issues/3968)
* The dax option from the virtio-fs support has been removed
  (https://github.com/cloud-hypervisor/cloud-hypervisor/issues/3889)

Fixes: #4641

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-07-12 14:47:58 +00:00
Bin Liu
f3335c99ce
Merge pull request #4614 from Tim-0731-Hzt/runtime-rs-merge-main
Runtime-rs merge main
2022-07-12 19:25:11 +08:00
xuejun-xj
d2584991eb dragonball: fix dependency unused warning
Fix the warning "unused import: `dbs_arch::gic::Error as GICError`" and
"unused import: `dbs_arch::gic::GICDevice`" in file src/vm/mod.rs when
compiling.

Fixes: #4544

Signed-off-by: xuejun-xj <jiyunxue@alibaba.linux.com>
Signed-off-by: jingshan <jingshan@linux.alibaba.com>
2022-07-11 17:55:04 +08:00
xuejun-xj
458f6f42f6 dragonball: use const string for legacy device type
As string "com1", "com2" and "rtc" are used in two files
(device_manager/mod.rs and device_manager/legacy.rs), we use public
const variables COM1, COM2 and RTC to replace them respectively.

Fixes: #4544

Signed-off-by: xuejun-xj <jiyunxue@alibaba.linux.com>
Signed-off-by: jingshan <jingshan@linux.alibaba.com>
2022-07-11 17:46:10 +08:00
Zhongtao Hu
0826a2157d Merge remote-tracking branch 'origin/main' into runtime-rs-1
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
2022-07-11 09:47:23 +08:00
xuejun-xj
f6f96b8fee dragonball: add legacy device support for aarch64
Implement RTC device for aarch64.

Fixes: #4544

Signed-off-by: xuejun-xj <jiyunxue@alibaba.linux.com>
Signed-off-by: jingshan <jingshan@linux.alibaba.com>
2022-07-10 17:35:30 +08:00
xuejun-xj
7a4183980e dragonball: add device info support for aarch64
Implement generate_virtio_device_info() and
get_virtio_mmio_device_info() functions su support the mmio_device_info
member, which is used by FDT.

Fixes: #4544

Signed-off-by: xuejun-xj <jiyunxue@linux.alibaba.com>
Signed-off-by: jingshan <jingshan@linux.alibaba.com>
2022-07-10 17:09:59 +08:00
Chao Wu
9cee52153b fmt: do cargo fmt and add a dependency for blk_dev
fmt: do cargo fmt and add a dependency for blk_dev

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-07-07 10:32:35 +08:00
Chao Wu
47a4142e0d fs: change vhostuser and virtio into const
change fs mode vhostuser and virtio into const.

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-07-07 10:32:35 +08:00
Chao Wu
e14e98bbeb cpu_topo: add handle_cpu_topology function
add handle_cpu_topology funciton to make it easier to understand the
set_vm_configuration function.

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-07-07 10:32:35 +08:00
Chao Wu
5d3b53ee7b downtime: add downtime support
add downtime support in `resume_all_vcpus_with_downtime`

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-07-07 10:32:35 +08:00
Chao Wu
6a1fe85f10 vfio: add vfio as TODO
We add vfio as TODO in this commit and create a github issue for this.

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-07-07 10:32:35 +08:00
Chao Wu
5ea35ddcdc refractor: remove redundant by_id
remove redundant by_id in get_vm_by_id_mut and get_vm_by_id. They are
optimized to get_vm_mut and get_vm.

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-07-07 10:32:35 +08:00
Chao Wu
b646d7cb37 config: remove ht_enabled
Since cpu topology could tell whether hyper thread is enabled or not, we
removed ht_enabled config from VmConfigInfo

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-07-07 10:32:35 +08:00
Chao Wu
cb54ac6c6e memory: remove reserve_memory_bytes
This is currently an unsupported feature and we will remove it from the
current code.

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-07-07 10:32:35 +08:00
Chao Wu
bde6609b93 hotplug: add room for other hotplug solution
Add room in the code for other hotplug solution without upcall

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-07-07 10:32:35 +08:00
wllenyj
d88b1bf01c dragonball: update vsock dependency
1. fix vsock device init failed
2. fix VsockDeviceConfigInfo not found

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-07-07 10:32:35 +08:00
Chao Wu
dd003ebe0e Dragonball: change error name and fix compile error
Change error name from `StartMicrovm` to `StartMicroVm`,
`StartMicrovmError` to `StartMicroVmError`.

Besides, we fix a compile error in config_manager.

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-07-07 10:32:35 +08:00
Chao Wu
38957fe00b UT: fix compile error in unit tests
fix compile error in unit tests for DummyConfigInfo.

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-07-07 10:32:35 +08:00
wllenyj
11b3f95140 dragonball: add virtio-fs device support
Virtio-fs devices are supported.

Fixes: #4257

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-07-07 10:32:35 +08:00
wllenyj
948381bdbe dragonball: add virtio-net device support
Virtio-net devices are supported.

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-07-07 10:32:35 +08:00
wllenyj
3d20387a25 dragonball: add virtio-blk device support
Virtio-blk devices are supported.

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-07-07 10:32:35 +08:00
Chao Wu
87d38ae49f Doc: add document for Dragonball API
add detailed explanation for Dragonball API

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-07-07 10:32:26 +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
Manabu Sugimoto
4d89476c91 runtime: Fix DisableSelinux config
Enable Kata runtime to handle `disable_selinux` flag properly in order
to be able to change the status by the runtime configuration whether the
runtime applies the SELinux label to VMM process.

Fixes: #4599
Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2022-07-06 15:50:28 +09:00
wllenyj
090de2dae2 dragonball: fix the clippy errors.
fix clippy errors  and do fmt in this PR.

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-07-06 11:29:49 +08:00
wllenyj
a1593322bd dragonball: add vsock api to api server
Enables vsock to use the api for device configuration.

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-07-06 11:29:49 +08:00
wllenyj
89b9ba8603 dragonball: add set_vm_configuration api
Set virtual machine configuration configurations.

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-07-06 11:29:49 +08:00
wllenyj
95fa0c70c3 dragonball: add start microvm support
We add microvm start related support in thie pull request.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
Signed-off-by: jingshan <jingshan@linux.alibaba.com>
Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-07-06 11:29:49 +08:00
wllenyj
5c1ccc376b dragonball: add Vmm struct
The Vmm struct is global coordinator to manage API servers, virtual
machines etc.

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-07-06 11:29:49 +08:00
Jiang Liu
4d234f5742 dragonball: refactor code layout
Refactored some code layout.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2022-07-06 11:29:49 +08:00
wllenyj
cfd5dae47c dragonball: add vm struct
The vm struct to manage resources and control states of an virtual
machine instance.

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
Signed-off-by: jingshan <jingshan@linux.alibaba.com>
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
2022-07-06 11:29:46 +08:00
wllenyj
527b73a8e5 dragonball: remove unused feature in AddressSpaceMgr
log_dirty_pages is useless now and will be redesigned to support live
migration in the future.

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
2022-07-06 11:28:32 +08:00
Fabiano Fidêncio
071dd4c790
Merge pull request #4109 from pmores/drop-in-cfg-files-support
Drop in cfg files support
2022-07-05 22:21:24 +02:00
Peng Tao
514b4e7235
Merge pull request #4543 from openanolis/anolis/add_vcpu_configure_aarch64
runtime-rs: Dragonball sandbox - add Vcpu::configure() function for aarch64
2022-07-05 17:47:40 +08:00
Bin Liu
d9e868f44e
Merge pull request #4479 from quanweiZhou/enhance-get-handled-signal
agent: enhance get handled signal
2022-07-05 15:18:21 +08:00
Bin Liu
b33ad7e57a
Merge pull request #4574 from jelipo/fix-serde-serializing
oci: fix serde skip serializing condition
2022-07-05 13:51:43 +08:00
Bin Liu
0189738283
Merge pull request #4576 from ManaSugi/fix/oci-poststart-hook
agent: Run OCI poststart hooks after a container is launched
2022-07-05 11:08:49 +08:00
Peng Tao
cd2d8c6fe2
Merge pull request #4580 from ManaSugi/fix/replace-libc-with-nix
agent: Replace some libc functions with nix ones
2022-07-05 10:53:42 +08:00
Peng Tao
a1de394e51
Merge pull request #4550 from liubin/fix/4548-overwrite-mount-type-for-bind-mount
runtime: overwrite mount type to bind for bind mounts
2022-07-04 19:56:26 +08:00
haining.cao
0ddb34a38d oci: fix serde skip serializing condition
There is an extra space on the serde serialization condition.

Fixes: #4578

Signed-off-by: haining.cao <haining.cao@daocloud.io>
2022-07-04 16:16:04 +08:00
xuejun-xj
7120afe4ed dragonball: add vcpu test function for aarch64
add create_vcpu() function in vcpu test unit for aarch64

Fixes: #4445

Signed-off-by: xuejun-xj <jiyunxue@linux.alibaba.com>
Signed-off-by: jingshan <jingshan@linux.alibaba.com>
2022-07-04 15:23:43 +08:00
xuejun-xj
648d285a24 dragonball: add vcpu support for aarch64
add configure() function for aarch64 vcpu

Fixes: #4543

Signed-off-by: xuejun-xj <jiyunxue@linux.alibaba.com>
Signed-off-by: jingshan <jingshan@linux.alibaba.com>
2022-07-04 15:23:37 +08:00
xuejun-xj
7dad7c89f3 dragonball: update dbs-xxx dependency
change to up-to-date commit ID

Fixes: #4543

Signed-off-by: xuejun-xj <jiyunxue@linux.alibaba.com>
Signed-off-by: jingshan <jingshan@linux.alibaba.com>
2022-07-04 15:23:11 +08:00
Manabu Sugimoto
fbb2e9bce9 agent: Replace some libc functions with nix ones
Replace `libc::setgroups()`, `libc::fchown()`, and `libc::sethostname()`
functions with nix crate ones for safety and maintainability.

Fixes: #4579

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2022-07-04 14:49:38 +09:00
Manabu Sugimoto
acd3302bef agent: Run OCI poststart hooks after a container is launched
Run the OCI `poststart` hooks must be called after the
user-specified process is executed but before the `start`
operation returns in accordance with OCI runtime spec.

Fixes: #4575

Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
2022-07-03 18:03:51 +09:00