Commit Graph

3071 Commits

Author SHA1 Message Date
Archana Shinde
a976548fb2 shm: handle shm mount backed by empty-dir memory volumes
[cherry picked from runtime commit 3c4fe035e8041b44e1f3e06d5247938be9a1db15]

Check if shm mount is backed by empty-dir memory based volume.
If so let the logic to handle epehemeral volumes take care of this
mount, so that shm mount within the container is backed by tmpfs mount
within the the container in the VM.

Fixes: #323
Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-06-23 03:10:45 -07:00
Julio Montes
eed66021da virtcontainers: Fix structured logging in device/config package
[cherry picked from runtime commit d0dbd0485d2f4ec3760f6fa1252ded86a7709042]

Call the `device/config` package `SetLogger()` function to ensure all its log
records contain all required structured logging fields.

Signed-off-by: Julio Montes <julio.montes@intel.com>
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-06-23 00:53:05 -07:00
Peng Tao
422768082d agent: update Cargo lock
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-06-23 00:52:46 -07:00
James O. D. Hunt
72283b86dd logging: Fix structured logging in store package
[ cherry-picked from runtime commit 13887bf89da9d2d7c215d77ca63129e1813e4c4a ]

Call the `store` packages `SetLogger()` function to ensure all its log
records contain all required structured logging fields.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-06-23 00:52:39 -07:00
Peng Tao
042135949a vc: make host shared path readonly
We need to make sure containers cannot modify host path unless it is explicitly shared to it. Right now we expose an additional top level shared directory to the guest and allow it to be modified. This is less ideal and can be enhanced by following method:
1. create two directories for each sandbox:
  -. /run/kata-containers/shared/sandboxes/$sbx_id/mounts/, a directory to hold all host/guest shared mounts
  -. /run/kata-containers/shared/sandboxes/$sbx_id/shared/, a host/guest shared directory (9pfs/virtiofs source dir)
2. /run/kata-containers/shared/sandboxes/$sbx_id/mounts/ is bind mounted readonly to /run/kata-containers/shared/sandboxes/$sbx_id/shared/, so guest cannot modify it
3. host-guest shared files/directories are mounted one-level under /run/kata-containers/shared/sandboxes/$sbx_id/mounts/ and thus present to guest at one level under /run/kata-containers/shared/sandboxes/$sbx_id/shared/

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-06-23 00:44:44 -07:00
Peng Tao
a76443485c
Merge pull request #319 from lifupan/device_cgroup
Port rootfs access fix to rust agent
2020-06-23 11:06:17 +08:00
Peng Tao
285411ae89
Merge pull request #314 from jodh-intel/2.0-dev-collect-script-more-twists
runtime: Use more folds in collect script
2020-06-23 10:52:58 +08:00
Julio Montes
18c882b0fa
Merge pull request #316 from bpradipt/2.0-ppc64le
qemu: Remove Qemu version check in ppc64le unit test
2020-06-22 11:02:11 -05:00
Julio Montes
5c35e3e757
Merge pull request #322 from bpradipt/fwport-ppc64le
[Forward port] Bring ppc64le fixes to 2.0 dev tree
2020-06-22 09:14:39 -05:00
Pradipta Kr. Banerjee
2d241a6acc qemu: Remove hard-coding of Qemu machine options for ppc64le
Hard-coded Qemu machine options create challenges when running Kata
with latest Qemu (v5.0) or with latest processor version.
This patch makes it configurable by leveraging the existing machine_accelerators
option in configuration.toml.

This patch fixes #2657 for ppc64le

Signed-off-by: bpradipt@in.ibm.com
2020-06-22 06:36:43 +00:00
Pradipta Kr. Banerjee
b4d3a0af87 qemu: Fix Qemu binary path for Power across distros
The default ppc64le Qemu binary path was specific for Ubuntu.
This patch fixes the default binary path for both Fedora and Ubuntu

Fixes: #2738

Signed-off-by: bpradipt@in.ibm.com
2020-06-22 06:35:03 +00:00
fupan.lfp
3e00bdffaf agent: fix the issue of broken logger for agent as init process
Dup a new file descriptor for temporary logger writer,
since this logger would be dropped and it's writer would
be closed out of if definition scope, which would cause
the logger process thread terminated if it used the original
pipe write fd.

Fixes: #318

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-06-16 17:13:29 +08:00
fupan.lfp
2548426b0f device: Do not allow container access to the guest rootfs device
With this change, a container is not longer given access to
the underlying root partition.
This is done by explicitly adding the root partition
to the device cgroup of the container.

Fixes: #317

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-06-16 17:13:18 +08:00
Pradipta Kr. Banerjee
21c9535ab4 qemu: Remove Qemu version check in ppc64le unit test
The Qemu version check in unit test case is no longer needed for
Power since we don't support Kata with Qemu version < 4.x.

Fixes: #315

Signed-off-by: bpradipt@in.ibm.com
2020-06-13 17:45:01 +00:00
James O. D. Hunt
dee2cd67f2 runtime: Use more folds in collect script
Improve the output of the data collection script to use lots more folds.
This makes it easier to review the information when viewing the pasted
output in a GitHub issue.

Fixes: #313.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-12 11:40:30 +01:00
James O. D. Hunt
9665868852 runtime: Ignore empty throttlers in collect script
Fix bug by ignoring empty throttlers in the data collection script.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-12 11:35:37 +01:00
James O. D. Hunt
c8015efaa7 runtime: Refector collect script
Add `start_section()` and `end_section()` functions to the data
collection script to allow new unfoldable sections to be created.

Redefine `show_header()` and `show_footer()` to use the new functions.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-12 11:31:34 +01:00
Julio Montes
46f2618340
Merge pull request #311 from jodh-intel/2.0-dev-collect-script-add-shimv2-version
runtime: Add containerd shim v2 version to collect script
2020-06-11 14:02:55 -05:00
Yang Bo
a665f227a7
Merge pull request #303 from lifupan/pause_resume
container pause/resume support
2020-06-11 20:28:41 +08:00
James O. D. Hunt
dae74d5d7a runtime: Add containerd shim v2 version to collect script
Now that the Kata containerd shim v2 can display a version string,
add those details to the data collection script.

Fixes: #309.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-11 08:54:58 +01:00
James O. D. Hunt
13f35f3a6f
Merge pull request #242 from jiangliu/netlink
Refine netlink crate to be reused by other projects
2020-06-11 08:22:54 +01:00
fupan.lfp
e6c0a0bfca container: add pause/resume container functions
add pause/resume container functions.

Fixes:#302

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-06-11 10:16:28 +08:00
James O. D. Hunt
c132bb6bf0
Merge pull request #308 from jodh-intel/2.0-dev-containerd2-add-version-option
shimv2: Add a "--version" cli option
2020-06-10 15:45:04 +01:00
Julio Montes
f9361df8bf
Merge pull request #305 from tedyu/sandbox-create-err
virtcontainers: Check the correct error variable for sandbox creation
2020-06-10 09:39:10 -05:00
James O. D. Hunt
0e08712dc8
Merge pull request #225 from jodh-intel/2.0-dev-trace-forwarder
src: Add trace forwarder component
2020-06-10 11:53:40 +01:00
James O. D. Hunt
f3a37bc67a shimv2: Add a "--version" cli option
All components should support a `--version` option to allow clear
identification of the version of the component being used.

Note that the build changes are required to allow the shim binary to
access the golang code generated by the build (such as the `version`
variable).

Fixes: #307.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-10 11:51:29 +01:00
James O. D. Hunt
56b8ad995b build: Fold long clean line
Folded the overly long clean rule across multiple lines.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-10 11:51:29 +01:00
James O. D. Hunt
6890693444
Merge pull request #244 from jodh-intel/2.0-dev-add-podman-to-collect-script
runtime: Add podman and containerd shim v2 to data collection script
2020-06-10 11:29:11 +01:00
fupan.lfp
fe4166342a container: change the container status from string to enum
Change the container's status from string type to
enum.

Fixes: #302

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-06-10 16:46:41 +08:00
Ted Yu
e469d6b99d virtcontainers: Check the correct error variable for sandbox creation
This PR makes the deferred func check the correct error variable.

Fixes #2759

Signed-off-by: Ted Yu <yuzhihong@gmail.com>
2020-06-10 01:06:49 -07:00
James O. D. Hunt
48d3471cfe docs: Add trace forwarder doc reference
Add a pointer to the trace forwarder README to the top-level README.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-09 09:55:48 +01:00
James O. D. Hunt
9b987c17d9 src: Add trace forwarder component
Add a new system component, used only when tracing is enabled. The
component listens to the agent over VSOCK, forwarding trace spans
created by the agent in the virtual machine onwards to an OpenTelemetry
collector (such as Jaeger) running on the host.

Fixes: #224.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-09 09:55:47 +01:00
James O. D. Hunt
b165e2a437 runtime: Add containerd shim v2 to collect script
Capture log output from the Kata containerd shim v2.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-09 09:19:49 +01:00
James O. D. Hunt
ca8acf5895 runtime: Add podman to data collection script
Updated `kata-collect-data.sh` to gather basic podman details.

Fixes: #243.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-09 09:19:49 +01:00
James O. D. Hunt
ebbfa321ae runtime: Fix throttler log handling in collect script
Fix a long-standing bug where the KSM throttler logs would not be
collected by removing the last (unused) parameter to the
`find_system_journal_problems()` function.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-09 09:19:49 +01:00
James O. D. Hunt
40a37aa5c6 runtime: Re-order funcs in data collection script
Ensure functions defined before calling them in the data collection
script.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-09 09:19:49 +01:00
James O. D. Hunt
e0148c9cb9 runtime: Fix legacy package regex in collect script
The function that checks for legacy packages in the collect script was
missing pipes denoting regex alternation.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-09 09:15:59 +01:00
James O. D. Hunt
04eced50ad runtime: Fix whitespace in collect script
Remove extraneous whitespace from the `kata-collect-data.sh` script.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-09 09:15:59 +01:00
James O. D. Hunt
e5f5bc2278
Merge pull request #223 from jodh-intel/2.0-dev-kata-agent-ctl
tools: Add kata-agent-ctl
2020-06-08 17:41:17 +01:00
James O. D. Hunt
2e97fbfdc0 docs: Reference kata-agent-ctl doc
Add a link to the `kata-agent-ctl` README.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-08 11:22:19 +01:00
James O. D. Hunt
8a1949546c tools: Add agent-ctl tool
Add a low-level agent control tool that can manipulate the agent
via ttRPC.

Fixes: #222.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-08 11:22:19 +01:00
James O. D. Hunt
2e53d237ce logging: Add ability to convert between log level name and slog level
Added new functions to convert to/from a log level name (like `debug`)
to/from the equivalent `slog::Level::Debug`.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-08 11:22:19 +01:00
James O. D. Hunt
e80124ec0f logging: Simplify and update copyright
Tiny simplification. Also updated the copyright.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-08 11:22:19 +01:00
James O. D. Hunt
b95ff30cbf cargo: Moved tempfile crate to dev deps
Don't require the `tempfile` crate unless building in dev mode (such as
when running tests).

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-08 11:22:19 +01:00
James O. D. Hunt
a2dce2dc71 logging: Move agent logger to a separate package
The agent logger is useful and generic enough that it can be used by
other components, so move the agent logging package to below a top level
`pkg` to encourage re-use.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2020-06-08 11:22:17 +01:00
Liu Jiang
4e31bcf8b2 netlink: clean all clippy warnings
Clean up all clippy warning.
Also fix a bug in dealing with IFLA_IFNAME attribute.
nlh.addattr_var(IFLA_IFNAME, name.as_ptr() as *const u8, name.len() + 1);
The `name` is a rust String, which doesn't including the trailing '\0',
so name.len() + 1 may cause invalid memory access.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-06-01 22:31:44 +08:00
Liu Jiang
f5cfd412e4 netlink: fix an error in formatting MAC address
When formatting MAC address, we should left-padding zeros instead
of right-padding.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-06-01 17:58:28 +08:00
Liu Jiang
de23ec1943 netlink: implement TryFrom instead of From to avoid unwrap()
Implment `TryFrom<IPAddress> for RtIPAddr` instead of From<IPAddress>,
so error code could be returned instead of unwrap().
Do the same for `TryFrom<Route> for RtRoute`.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-06-01 17:58:27 +08:00
Liu Jiang
1b8c2cba60 netlink: refine interface to reduce unsafe code
There are too much unsafe code in the netlink crate, we need to reduce
unsafe code as much as possible. To achieve this, methods are classified
as public interfaces and internal methods.

All public interface of RtnlHandle has been reimplemented as safe code,
only some public helper functions to manipulater Netlink message data
structures are implemented as unsafe code.

The code to parse IPv4/IPv6/MAC addresses has been moved to a dedicated
file named parser.rs.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-06-01 16:07:46 +08:00
Liu Jiang
3fe930b946 netlink: get rid of dependency on scan_fmt
The scan_fmt crate has dependency on other four crates, and it's trivial
to use std library to implement the same logic. Get rid of scan_fmt to
reduce the dependency chain.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-06-01 16:07:45 +08:00