Commit Graph

4749 Commits

Author SHA1 Message Date
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
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
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
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
Liu Jiang
710932df06 netlink: use features for slog and agent handler
Use features to enable/disable slog and agent handler on demand.
This helps to reduce dependency chains if slog/agent handler is unused.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-06-01 16:07:44 +08:00
Liu Jiang
bbd40203d4 netlink: group kata agent code into a dedicated file
Group kata agent specific code into a dedicated file, so we could easily
make it optional later.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-05-31 03:12:25 +08:00
Liu Jiang
4774814c73 netlink: get rid of dependency on rustjail
The netlink crate is a library to communicate with Linux kenrel by using
the netlink socket. It's generic enough to be reused by other clients.
So get rid of dependency on the rustjail crate by:
1) normalize all pub interfaces to return Result<T, nix::Error>,
2) add helpers to reduce duplicated code,
3) move parse_mac() into lib.rs,

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-05-31 03:02:48 +08:00
Liu Jiang
6995178903 netlink: use bool for condition flags
Minor improvements for netlink by using bool for condition flags.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-05-31 02:58:10 +08:00
James O. D. Hunt
43db1284e9
Merge pull request #239 from Tim-Zhang/neigh
agent: port https://github.com/kata-containers/agent/pull/784
2020-05-29 15:56:52 +01:00
Tim Zhang
635c7a785a agent: port https://github.com/kata-containers/agent/pull/784
Add grpc API for adding arp neighbours for a network
interface. These are expected to be static arp entries
sent by the runtime.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2020-05-29 22:28:10 +08:00
Tim Zhang
cb58075a26 agent: fix make generate-protocols errors
Got:
make PROTO_FILE=agent.proto generate-protocol
google/protobuf/descriptor.proto: Read access is denied for file: /usr/local/include/google/protobuf/descriptor.proto

This commit will fix this error.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2020-05-29 16:05:04 +08:00
Salvador Fuentes
a449786544 versions: move versions.yaml to top directory
Instead of having the versions.yaml in the runtime source,
it makes more sense to have it in the root directory of
the project.

Signed-off-by: Salvador Fuentes <salvador.fuentes@intel.com>
2020-05-28 10:33:25 -05:00
Hui Zhu
85256e0494
Merge pull request #236 from liubin/refactoring-proto-compilation
Agent: centrally manage proto files
2020-05-28 10:05:05 +08:00
Hui Zhu
38f196b06e
Merge pull request #233 from liubin/porting/agent-616
agent: porting https://github.com/kata-containers/agent/pull/616
2020-05-28 10:03:28 +08:00
bin liu
a3eb0c970e Agent: centrally manage proto files
In Kata 1.x, agent interface is defined in agent repo and vendored by runtime. But in Kata 2.0, agent and runtime will use ttrpc as protocol, and agent is using rust language, so runtime can't vendor agent again, have to compile from agent's protobuf files.

This PR will hold proto files under src/agent, and compile it to rust/go sources for agent/runtime. Typing `make generate-protocols` under root of this repo or `src/agent` can see how to use it.

Signed-off-by: bin liu <bin@hyper.sh>
2020-05-27 21:05:36 +08:00
bin liu
9b9f2b2ff0 agent: porting https://github.com/kata-containers/agent/pull/616
this PR will port the original PR to kata 2.0.

Signed-off-by: bin liu <bin@hyper.sh>
2020-05-26 18:17:54 +08:00
Peng Tao
0e0f30b152 vc: fix device driver test
We should import kata-containers path.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-05-26 01:15:24 -07:00
Jose Carlos Venegas Munoz
202a877d36 utils: Fix case version check for stable releases
For stable versions the format used `x.y.z`.

kata-env was failing trying to make a new release from 1.11.0-rc to
1.11.0

This fix kata-env for releases 1.11+ where this regression was
introduced.

Fixes: kata-containers/runtime#2674
Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-05-26 00:51:01 -07:00
Bo Chen
48b20e75f8 clh: vsock: Supply the right VsockConfig to Vmconfig
With the new HTTP API from CLH, it removes the support of multiple
virtio-vsock devices, as the Linux kernel does not support it.

Signed-off-by: Bo Chen <chen.bo@intel.com>
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-05-26 00:51:01 -07:00
Bo Chen
4887ce059c versions: Move to cloud-hypervisor v0.7.0
Changes:

96be8229 release: Release v0.7.0
5115ad6e vmm: config: Support on/off/true/false for all booleans
d5bfa2df vmm, vhost_user_block: Make parameter names match --disk
2f0bc06b vmm: Update default devices names as "internal"
aaba6e77 vmm: Add virtio-console to the list of Migratable devices
9ab4bb1a devices: serial: Expect an identifier upon device creation
06487131 vm-virtio: pci: Expect an identifier upon device creation
eeb7e10d vm-virtio: mmio: Expect an identifier upon device creation
9d84ef50 vmm: Make the virtio identifier mandatory
14350f5d devices: ioapic: Expect an identifier upon device creation
55687157 vm-virtio: iommu: Expect an identifier upon device creation
052eff1c vm-virtio: console: Expect an identifier upon device creation
354c2a4b vm-virtio: vhost-user-net: Expect an identifier upon device creation
46e0b3ff vm-virtio: vhost-user-blk: Expect an identifier upon device creation
bb7fa71f vm-virtio: vhost-user-fs: Expect an identifier upon device creation
ec5ff395 vm-virtio: vsock: Expect an identifier upon device creation
9b53044a vm-virtio: mem: Expect an identifier upon device creation
1592a929 vm-virtio: pmem: Expect an identifier upon device creation
2e91b738 vm-virtio: rng: Expect an identifier upon device creation
9eb7413f vm-virtio: net: Expect an identifier upon device creation
be946caf vm-virtio: blk: Expect an identifier upon device creation
ff9c8b84 vmm: Always generate the next device name
81831413 vmm: Add an identifier to the ioapic device
e4386c8b vmm: Add an identifier to the virtio-iommu device
75ddd2a2 vmm: Add an identifier to the --console device
eac350c4 vmm: Add an identifier to the virtio-mem device
6802ef54 vmm: Add an identifier to the --rng device
d71d52e9 vmm: Fix virtio-console creation with virtual IOMMU
b08fde59 vmm: Fix virtio-rng creation with virtual IOMMU
8031ac33 vmm: Fix virtio-vsock creation with virtual IOMMU
50134969 Jenkins: Run musl unit and integration tests on master branch
ce794f78 ci: Pass target triple to the test scripts
33b0e158 resources: Add musl tools and toolchain to the Dockerfile
ad9374bd dev_cli: Add --libc to the build and test commands
8cef3574 vmm: seccomp: Add fork, gettid and pipe2 syscalls to permitted list
ce7678f2 vmm: seccomp: Add tkill syscall to permitted list
12758d7f vmm: seccomp: Add epoll_pwait syscall to permitted list
86fcd19b build: Initial musl support
a5de4955 vmm: Only allow removal of specific types of virtio device
9ed880d7 vmm: Add an identifier to the --fs device
7e0ab6b5 vmm: Fix pmem device creation
3012975c tests: Enhance vsock integration test to support hotplug
6c2bca5f bin: ch-remote: Add support for adding vsock devices
8de7448d vmm: api: Add "add-vsock" API entry point
bf09a1e6 openapi: Add "id" field to VsockConfig
a76cf086 vmm: vm: Remove vsock device from config
99422324 vmm: vm: Add "add_vsock()"
1d61c476 vmm: device_manager: Add support for hotplugging virtio-vsock devices
f8501a3b vmm: config: Move --vsock syntax to VsockConfig
6e049e0d vmm: Add an identifier to the --vsock device
10348f73 vmm, main: Support only zero or one vsock devices
9d1f95a3 openapi: Add missing "id" field
30e2e515 build(deps): bump serde_json from 1.0.51 to 1.0.52
dd9d0d04 build(deps): bump micro_http from `0d87a94` to `c9ffb90`
cdc8493a build(deps): bump thiserror from 1.0.15 to 1.0.16

Fixes: kata-containers/runtime#2658
Signed-off-by: Bo Chen <chen.bo@intel.com>
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-05-26 00:51:01 -07:00
Jose Carlos Venegas Munoz
54f12461db clh: memory: remove pmem size argument
Pmem size now is calculated by the hypervisor. This is not required
anymore. Remove it to simplify the code.

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-05-26 00:51:01 -07:00
Jose Carlos Venegas Munoz
83891592c1 versions: Move to latest cloud-hypervisor
Changes:

f5debc4 build(deps): bump libssh2-sys from 0.2.16 to 0.2.17
37dfb4c build(deps): bump hermit-abi from 0.1.11 to 0.1.12
e1a07ce vmm: vm: Unpark the threads before shutdown when the current state is paused
1df38da vmm, tests: Make specifying a size optional for virtio-pmem
7481e4d vmm: config: Validate that shared memory is enabled if using vhost-user
2ac6971 vmm: MemoryManager: Cleanup the usage of std::ffi/io/result
3f42f86 vmm: Add the 'shared' and 'hugepages' controls to MemoryConfig
d6aa717 build(deps): bump syn from 1.0.17 to 1.0.18
3eaeba4 vm-virtio: Fix FS_IO callback for virtio-fs
df14a68 build(deps): bump smallvec from 1.3.0 to 1.4.0
e685854 gh: Separate the build and release jobs
c790bba tests: Migrate from Ubuntu Eoan to Focal
e525af7 build(deps): bump ryu from 1.0.3 to 1.0.4
3e8a6ba ci: Ignore test_snapshot_restore
9ebf052 build(deps): bump cc from 1.0.51 to 1.0.52
f6b150a ci: Add integration test for VM migration
9f08f53 build(deps): bump pin-utils from 0.1.0-alpha.4 to 0.1.0
9c7215d docs: Add the vhost-user-blk test doc
3574437 build(deps): bump cc from 1.0.50 to 1.0.51
4fc75cf vm-virtio: Implement Snapshottable trait for Console
d41ce90 vm-virtio: Implement Snapshottable trait for Pmem
f626bd6 build(deps): bump parking_lot_core from 0.7.1 to 0.7.2
5a380a6 vmm: memory_manager: Support non-power-of-2 block sizes
f8ee89a build(deps): bump arc-swap from 0.4.5 to 0.4.6
49322c5 vm-virtio: Implement the Snapshottable trait for Net
24c2b67 vm-virtio: Improve virtio-net rx queue processing
03dd249 vm-virtio: Restore queues based on used index
cf707da vm-virtio: Extend Queue helpers
c22fd39 vmm: Remove virtio device's userspace mapping on hot-unplug
0a97c25 vmm: Extend MemoryManager to remove userspace mappings
b2de1cd vm-virtio: Implement shutdown() for virtio-fs
fbcf3a7 vm-virtio: Implement userspace_mappings() for virtio-pmem
b035399 vm-virtio: Implement userspace_mappings() for virtio-fs
3fb0a02 vm-virtio: Get userspace mappings from VirtioDevice
8b823e5 build(deps): bump backtrace-sys from 0.1.35 to 0.1.36
c23b488 ci: Factorize virtio-fs hotplug integration tests
f68b08b tests: add integration tests for vm.add-fs route
18f7789 vmm: Add hotplugged virtio devices to the DeviceManager list
c2abadc vmm: Add ability to add virtio-fs device post-boot
bb2139a vmm/api: Add vm.add-fs route
d35e775 vmm: Update KVM userspace mapping when PCI BAR remapping
49cc73a vm-virtio: pci: Make sure to return the correct list of BARs
187b1ee vm-virtio: Implement the Snapshottable trait for Block
a484aa7 vm-virtio: Implement the Snapshottable trait for Rng
ac7178e vmm: Keep migratable devices list as a Vec
b6fdbf7 vm-virtio: Implement Snapshottable trait for MmioDevice
12fec55 vm-virtio: Add helpers to update queue indexes
fd45e94 vm-virtio: Add the ability to serialize a Queue
b7faf4f vhost_user_fs: Add the WRITE_KILL_PRIV write flag.
0870028 vhost_user_fs: Add the IOCTL_COMPAT_32 flag
592cfba vhost_user_fs: Add the EXPLICIT_INVAL_DATA capability flag
621ea83 vhost_user_fs: Add the ZERO_MESSAGE_OPENDIR capability flag
a2830da vhost_user_fs: Add the CACHE_SYMLINKS flag
926a414 vhost_user_fs: Add support for MAX_PAGES
747f31d vhost_user_fs: Add the ABORT_ERROR flag
5eb903a vhost_user_fs: Add support for FOPEN_CACHE_DIR
97e2d5d vhost_user_fs: Add support for CopyFileRange
b8cfdab pci: configuration: Use correct algorithm for BAR size reporting
9bd5ec8 pci, vfio, vm-virtio: Specify a PCI revision ID of 1 for virtio-pci
e7e0e8a vmm, devices: Add firmware debug port device
82d0cdf vhost_user_net: Simplify match values for handle_event()
a517be4 vhost_user_blk: Add multithreaded multiqueue support
13c8283 vhost_user_blk: Make everything private when possible
a31f5f8 vhost_user_blk: Move disk initialization to VhostUserBlkBackend
e78e34b vhost_user_blk: Make DiskFile sharable across threads
808586e vhost_user_blk: Simplify the code by removing VringWorker
ea82632 tests: Enhance test_pmem_hotplug to also unplug device
6389418 tests: Enhance test_disk_hotplug to also unplug device
f9a0445 vmm: vm: Remove device from configuration after unplug
444e5c2 vmm: device_manager: Generalise NoAvailableVfioDeviceName
5bab9c3 vmm: device_manager: Assign ids to pmem/net/disk devices if absent
514491a vmm: device_manager: Support unplugging virtio-pci devices
2fa652a vm-virtio: pci: Add virtio_device() accessor
476e4ce vmm: device_manager: Add virtio-pci devices into id to BDF map
b38470d vmm: config: Add "id" parameter to {Net, Disk, Pmem}Config
1beb62e vmm: vm: Don't panic on kernel load error

Fixes: kata-containers/runtime#2609
Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-05-26 00:51:01 -07:00
Julio Montes
c1959f3df3 virtcontainers: constrain runtime after creating network
Runtime must setup the network before moving itself into the cgroup, otherwise
it won't be able to get the vhost/net queues file descriptors for the
hypervisor.

Signed-off-by: Julio Montes <julio.montes@intel.com>
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-05-26 00:51:01 -07:00
Julio Montes
5f9d141159 virtcontainers: update sandbox's device cgroup
Update sandbox's device cgroup before hotpluggin a device and after it has
been removed from the VM, this way the device cgroup in the host is
fully honoured and the hypervisor will have access only to the devices needed
for the sandbox, improving the security.

Signed-off-by: Julio Montes <julio.montes@intel.com>
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-05-26 00:51:00 -07:00
Julio Montes
e6aac8390e virtcontainers: remove all the code related to HasCRIContainerType
All the code related to HasCRIContainerType is useless and no longer needed
since the CRIContainerType annotation is not considered for constraining or
not the sandbox

Signed-off-by: Julio Montes <julio.montes@intel.com>
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-05-26 00:50:23 -07:00
Julio Montes
8f5a69373b virtcontainers: apply constraints to the sandbox cgroup
Kata relies on the cgroup parent created and configured by the container
engine, but sometimes the sandbox cgroup is not configured and the container
may have access to all the resources, hence the runtime must constrain the
sandbox and update the list of devices with the devices hotplugged in the
hypervisor.

Fixes: kata-containers/runtime#2605
Signed-off-by: Julio Montes <julio.montes@intel.com>
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-05-26 00:50:23 -07:00
Julio Montes
9cdc899c76 pkg/cgroups: update the list of devices for the hypervisor
The hypervisor needs access to `/dev/vfio/vfio` to use VFIO devices.
Remove all devicemapper devices from the allowed list, the device cgroup
must be updated when before hotpluggin any device.

Signed-off-by: Julio Montes <julio.montes@intel.com>
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-05-26 00:50:23 -07:00
Julio Montes
44ed777c0f pkg/cgroups: add methods to add and remove device from the cgroup
add `AddDevice` and `RemoveDevice` to cgroup manager to allow adding
and removing devices from the device cgroup

Signed-off-by: Julio Montes <julio.montes@intel.com>
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-05-26 00:50:23 -07:00
Julio Montes
045c7ae9a3 pkg/cgroups: implement functions to get information from a host device
Add functions to convert a host device to a cgroup device or linux device,
the first one is used to update the device cgroup and the second one to
update the resources in the OCI spec.

Signed-off-by: Julio Montes <julio.montes@intel.com>
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-05-26 00:50:23 -07:00
Julio Montes
387d3d34dc device: add GetHostPath() to generic device
`GetHostPath()` method returns the device path in the host, this way the
runtime can get the device information for updating the sandbox's device
cgroup.

Signed-off-by: Julio Montes <julio.montes@intel.com>
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-05-26 00:50:23 -07:00
Peng Tao
4fdb4cffd5 runtime: update vendor/modules.txt
go 1.14 requires it to match go.mod and exposes a backtrace with
slightly difference.

Fixes: #227
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-05-25 23:30:42 -07:00
Peng Tao
6bc69760c0 vendor: move ttrpc proto code out of vendor
We do not really depend on the go agent generated grpc code any more.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-05-25 23:30:42 -07:00
fupan.lfp
555f620653 agent: hardcode the Cargo.lock file
Hardcode the Cargo.lock file to prevent dependencies
change which would cause some compatible issues.

Fixes: #230

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-05-26 11:39:07 +08:00
fupan.lfp
08e3d259ca agent: fix the issue of building error with latest ttrpc
Since the ttrpc upgraded with async supported, which isn't
compatible with current agent, thus it's better to change
the dependency to a stable branch.

Fixes: #229

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-05-26 11:14:39 +08:00
fupan.lfp
1d6e7ac405 change the protocols from grpc to ttrpc
Switch protocols from grpc to ttrpc

Fixes: #148

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-05-09 17:39:34 +08:00
fupan.lfp
010b7a9fba vendor: add the ttrpc protos
add the ttrpc protocol files

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-05-09 15:36:43 +08:00
fupan.lfp
663c7e7921 vendor: update the required vendors
update the required vendors

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-05-08 20:38:12 +08:00
Peng Tao
e90c5d45b3 runtime: build with vendor
So that we don't have to download dependencies.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-04-29 19:25:40 -07:00
Peng Tao
06b3f313a2 shimv2: do not reset service config
Only load runtime config when it is not set.
We do not expect a service's runtime config to change while
it is running.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-04-29 18:39:03 -07:00
Peng Tao
6de95bf36c gomod: update runtime import path
To use the kata-containers repo path.

Most of the change is generated by script:
find . -type f -name "*.go" |xargs sed -i -e \
's|github.com/kata-containers/runtime|github.com/kata-containers/kata-containers/src/runtime|g'

Fixes: #201
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-04-29 18:39:03 -07:00
Peng Tao
359b78c1c9 runtime: fix cli non-root ci
It turns out kata check needs root privilege to
call modprobe otherwise it fails.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-04-29 02:40:33 -07:00
Peng Tao
a5589196ce runtime: fix TestMainBeforeSubCommands
It is simply wrong to test kata-check within before sub commands
as it is NOT before at all. Besides it causes errors if kata is
not installed.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-04-29 02:40:33 -07:00
Peng Tao
3b5768e6e0 runtime: remove unneeded test conf
We don't really use them anymore.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-04-27 20:52:12 -07:00
Peng Tao
4fceb03d96 markdown: fix markdown checke failures
Pass markdown checker.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-04-27 19:50:59 -07:00
Peng Tao
93b72558ad runtime: enable make file
go test needs explicit -mod=vendor argument.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-04-27 19:50:45 -07:00
Peng Tao
426a9cab6e runtime: fix agnet ut
We should not use a plain unix socket reader to act as grpc
server. Place a really mock grpc server instead.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-04-27 19:50:37 -07:00
Peng Tao
e540648950 vendor: move to go mod
Get rid of go dep finally ;)

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-04-27 19:50:29 -07:00
Peng Tao
98e3e99843 Merge remote-tracking branch 'runtime/1.11.0-rc0' into runtime-1.11.0-rc0
Merge runtime 1.11.0-rc0 in.

Fixes: #192
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-04-27 19:49:18 -07:00
Peng Tao
a02a8bda66 runtime: move all code to src/runtime
To prepare for merging into kata-containers repository.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-04-27 19:39:25 -07:00
fupan.lfp
3ea23a9a5d add license headers to proto files
add license headers to proto files

Fixes: #148

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-04-22 22:12:38 +08:00
lifupan
a7041c27dc agent: switch from grpc to ttrpc as agent protocol
switch from grpc to ttrpc
Fixes: #148

Signed-off-by: lifupan <lifupan@gmail.com>
2020-04-22 22:12:18 +08:00
fupan.lfp
ba3c732f86 grpc: fix the issue of potential crashes
It's better to check whether the sandbox's get_container
result instead of unwrap it directly, otherwise it would
crash the agent if the conainer id is invalid.

Fixes: #178

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-04-02 18:58:24 +08:00
fupan.lfp
32431d701c rpc: fix the issue of kill container process
When kill a process, if the exec id is empty, then
it means to kill all processes in the container, if
the exec id isn't empty, then it will only kill the
specific exec process.

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-04-02 17:58:46 +08:00
fupan.lfp
986e666b0b sandbox: fix the issue of missing setting hostname
When setup the persisten uts namespace, it's should
set the hostname for this ns.

Fixes: #175

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-03-31 17:22:24 +08:00
fupan.lfp
7d9bdf7b01 grpc: Fix the issue passing wrong exec_id to exec process
This issue was brought accidently by PR #174, fix this issue.

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-03-31 17:19:40 +08:00
fupan.lfp
9220fb8e0c rustjail: unify the rustjail's log to contain container id and exec id
Add the container id and exec id to start container's log
which would make it clearly to check the log.

Fixes: #173

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-03-27 20:10:50 +08:00
fupan.lfp
c1b6838e25 rustjail: refactoring the way of creating container process
In the previous implementation, create a container process
by forking the parent process as the container process,
and then at the forked child process do much more setting,
such as rootfs mounting, drop capabilities and so on, at
last exec the container entry cmd to switch into container
process.

But since the parent is a muti thread process, which would
cause a dead lock in the forked child. For example, if one
of the parent process's thread do some malloc operation, which
would take a mutex lock, and at the same time, the parent forked
a child process, since the mutex lock status would be inherited
by the child process but there's no chance to release the lock
in the child since the child process only has a single thread
which would meet a dead lock if it would do some malloc operation.

Thus, the new implementation would do exec directly after forked
and then do the setting in the exec process. Of course, this requred
a data communication between parent and child since the child cannot
depends on the shared memory by fork way.

Fixes: #166
Fixes: #133

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-03-23 17:12:10 +08:00
fupan.lfp
e56b10f835 rustjail: remove the unused imported crates
remove the unused imported crates

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-03-20 17:04:05 +08:00
fupan.lfp
ded27f48d5 oci: add Default and Clone to oci spec objects
Add the clone and default feature to oci
spec objects.

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-03-20 17:03:54 +08:00
fupan.lfp
7df8edef1b rustjail: replace protocol spec with oci spec
transform the rpc protocol spec to
oci spec.

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-03-20 16:26:32 +08:00
James O. D. Hunt
8280208443
Merge pull request #154 from awprice/issue-152
agent: add configurable container pipe size cmdline option
2020-03-18 08:36:23 +00:00
fupan.lfp
245183cb28 cargo: add a workspace and run all the tests in the workspace
Add a worksapce and run all of the tests in
under this workspace.

Fixes:#155

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-03-16 16:34:59 +08:00
Alex Price
204edf0e51 agent: add configurable container pipe size cmdline option
Adds a cmdline option to configure the stdout/stderr pipe sizes.
Uses `F_SETPIPE_SZ` to resize the write side of the pipe after
creation.

Example Cmdline option: `agent.container_pipe_size=2097152`

fixes #152

Signed-off-by: Alex Price <aprice@atlassian.com>
2020-03-04 15:31:59 +11:00
GabyCT
35c33bba47
Merge pull request #145 from Pennyzct/build_service_for_rust_agent
systemd-service: build rust-agent systemd services
2020-03-03 13:17:27 -06:00
Penny Zheng
f0eaeac3be path-absolutize: version update
The latest tag version v1.2.0 fixes the error of inapporiately using
mutable static.

Fixes: #144

Signed-off-by: Penny Zheng <penny.zheng@arm.com>
2020-03-03 09:24:13 +08:00
Penny Zheng
3136712d8e systemd-service: build rust-agent systemd services
I add another sub-command `build-service` in Makefile to
generate rust-agent-related systemd service files, which
are necessary for building guest rootfs image.
The whole design is following the one in go-agent.

Fixes: #144

Signed-off-by: Penny Zheng <penny.zheng@arm.com>
2020-03-03 09:24:02 +08:00
fupan.lfp
289d61730c grpc: fix the issue of crash agent when didn't find the process
It's better to catch the  error of couldn't find the process
in tty_win_resize service, other wise, an invalid process id
could crash the agent.

Fixes: #137

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-02-11 10:04:19 +08:00
Yang Bo
e2c9426ebf Merge pull request #134 from liubin/master
should ignore  invalid a key-value pair as an env
2020-02-10 11:14:36 +08:00
Kant
40b5a56688 agent: ignore invalid a key-value pair as an env
Fixes #135

Signed-off-by: Kant <lb203159@antfin.com>
2020-02-08 13:51:28 +08:00
Yang Bo
269daa94ef Revert: "Makefile: Fix rust agent build using "--release"."
This reverts commit a3e46a369f.

There is still problem with static link, built binary will
segmentfault on clearlinux. So revert this patch for now.

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

Fixes: #69

Signed-off-by: Yang Bo <bo@hyper.sh>
2020-02-08 12:56:34 +08:00
Yang Bo
afc7b4d523
Merge pull request #129 from yyyeerbo/wip
Makefile: Fix rust agent build using "--release".
2020-02-07 15:31:58 +08:00
Yang Bo
a3e46a369f Makefile: Fix rust agent build using "--release".
Based on @ericho's work on the bug

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

Fixes: #69

Signed-off-by: Yang Bo <bo@hyper.sh>
2020-02-07 11:38:03 +08:00
Fupan Li
356222fbba
Merge pull request #132 from yyyeerbo/wip2
vsock: support log_vport and debug_console_vport
2020-02-07 10:06:42 +08:00
Yang Bo
3c1252ea79 vsock: support log_vport and debug_console_vport
Fixes: #61, #64

Signed-off-by: Yang Bo <bo@hyper.sh>
2020-02-04 20:32:07 +08:00
Tim Zhang
c373f846f5 agent: separate logging into a single crate
Since the codes in logging.rs is weakly related to the project,
separating it from the project will reduce coupling and make it reusable.

Fixes: #131

Signed-off-by: Tim Zhang <tim@hyper.sh>
2020-02-03 20:40:26 +08:00
James O. D. Hunt
b5e741ba8b
Merge pull request #125 from lifupan/fix_agent_crash
agent: fix the issue of crash agent without spec
2020-01-20 11:29:16 +00:00
fupan.lfp
2be8661ffa agent: fix the issue of missing restore process's cwd
It should restore to it's previous cwd after it
create container in which it would change it's
cwd to container's bundle path.

Fixes: #126

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-01-20 11:00:48 +08:00
fupan.lfp
6c7453db78 agent: fix the issue of crash agent without spec
To check is the oci spec passed in, other wise,
it would crash the agent unwrap it directly.

Fixes: #124

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2020-01-18 18:26:01 +08:00
Yang Bo
1b1e066083
Merge pull request #108 from Pennyzct/build_bug_fix
Running rust-agent on AArch64
2020-01-15 21:43:31 +08:00
Fupan Li
8fbc673e68
Merge pull request #119 from quanweiZhou/add-test-case
add oci compatibility test case
2020-01-09 14:54:11 +08:00
Yang Bo
c4f15f1280
Merge pull request #91 from ericho/master
agent: Add unit tests for sandbox.rs
2020-01-09 12:51:41 +08:00
quanweiZhou
d2225334d9 agent: add oci compatibility test case
add oci compatibility test case for src/agent/oci/src/lib.rs
follow by Open Container Initiative Runtime Specification

Fixes: #118

Signed-off-by: quanweiZhou <quanweiZhou@linux.alibaba.com>
2020-01-09 11:14:24 +08:00
Penny Zheng
7dfc4e0219 linker: no such file linking error on AArch64
When using default cc linker, we will have segfault.
Debugging with `rust-gdb`, the specific error is as follows:
src/string/memcpy.c: No such file or directory.
Only changing linker with `aarch64-linux-musl-gcc`, the
`rust-agent` could be totally statically linked and run successfully.

Fixes: #107

Signed-off-by: Penny Zheng <penny.zheng@arm.com>
2020-01-09 11:08:23 +08:00
Penny Zheng
44b2caa2e5 AArch64: missing symbols on target aarch64-unknown-linux-musl
The __addtf3, __subtf3 and __multf3 symbols are used by aarch64-musl,
but are not provided by rust compiler-builtins.
For now, the only temporary but functional workaround accepted by rust
communities is to get them from libgcc.

Fixes: #107

Signed-off-by: Penny Zheng <penny.zheng@arm.com>
2020-01-09 11:06:04 +08:00
Penny Zheng
9621a7f3f5 ABI: only support arm 64-bit platform
We only support running Kata Containers on AArch64.

Fixes: #107

Signed-off-by: Penny Zheng <penny.zheng@arm.com>
2020-01-09 09:59:20 +08:00
Yang Bo
a5192a16e8 netlink: pull out netlink as library crate.
Fixes: #111

Signed-off-by: Yang Bo <yb203166@antfin.com>
2020-01-04 06:45:52 -08:00
Erich Cordoba
92301a6382 agent: Add unit tests for sandbox.rs
These are the unit tests for the sandbox struct. This is the summary
of the most important changes:

  - To test containers it was needed to create a `LinuxContainer` type
    and this requires root privileges. So, some tests now requires root
    user to be run.
  - There was a bug in the `unset_sandbox_storage` method. The return
    type was wrapped in a `Result` to avoid this problem.

Fixes: #50

Signed-off-by: Erich Cordoba <erich.cordoba.malibran@intel.com>
2019-12-06 13:11:07 -06:00
Liu Jiang
154c68eb93 agent: group Linux ABI constants into dedicated file
Group Linux ABI related constants into dedicated file for maintenance.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-12-02 22:19:33 +08:00
Liu Jiang
000bb8592d agent: refine device.rs for better maintenance
1) pass reference instead of value when possible.
2) simplify code.
3) rename get_device_pci_address() as get_pci_device_address() to keep
   consistency get_pci_device_name().
4) refine get_device_name() for maintenance.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-12-02 22:19:29 +08:00
Liu Jiang
94311e4997 agent: fix wrong return value of set_sandbox_storage()
Function set_sandbox_storage() is designed to return true when the
reference count drops from 1 to 0. But current implementation always
return true no matter the reference count is, which may cause removing
an in use mountpoint.

Fixes: #88

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-12-02 22:19:28 +08:00
Liu Jiang
b1748323f0 agent: refine namespace.rs/sandbox.rs for better maintenance
Refine namespace.rs for better maintenance:
1) avoid unnecessary clone
2) make NamespaceType::get() return &str instead of String
3) minor syntax changes
4) remove unused enable_grpc_trace

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-12-02 22:19:27 +08:00
Liu Jiang
a4adacaa10 agent: refine uevent.rs for better maintenance
Refine uevent.rs for better maintenance:
1) use dedicated function to handle uevents.
2) use dedicated function to handle blk add events.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-12-02 10:05:44 +08:00
Liu Jiang
8868eaeb4c agent: clean up clippy warnings about '`static'
warning: Constants have by default a `'static` lifetime
  --> src/grpc.rs:59:24
   |
59 | const CONTAINER_BASE: &'static str = "/run/kata-containers";
   |                       -^^^^^^^---- help: consider removing `'static`: `&str`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-11-30 18:54:23 +08:00
Liu Jiang
eb6258b751 agent: improve logger implemetation
Improve loger implementation by:
1) avoid unnecessary clone() operations.
2) change Arc<Mutex<slog::Level>> to Mutex<slog::Level>. We should use
atomic<usize> instead of Mutex<slog::Level> for better performance here.
But with slog_async::Async drainer in the pipeline, RuntimeLevelFilter
drainer will only get from a single-thread context, so keep it as is.
3) minor syntax cleanups.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-11-30 18:33:07 +08:00
lifupan
4c051ed717 config: fix the issue of parse cmdline options
It's should use string.eq() to match option's
key words exactly instead of using string.starts_with()
for single key options and for "key=value" options it's
bettet to match "key=" instead of "key" with string.starts_with()
which would match wrongly such as passed options "agent.log_vsock"
which would match "agent.log" with string.starts_with()
and trigger parsing issues.

Fixes: #96

Signed-off-by: lifupan <lifupan@gmail.com>
2019-11-29 09:21:20 +08:00
Yang Bo
b9158efe3a
Merge pull request #93 from lifupan/fix_copy_file
Fix copy file
2019-11-25 11:40:32 +08:00
lifupan
aeeb6fce73 grpc: fix the issue of wrong containers base dir
The base dir should be "/run/kata-containers" instead
of "/run/agent".

Fixes: #92

Signed-off-by: lifupan <lifupan@gmail.com>
2019-11-25 10:35:17 +08:00
lifupan
5f29f3e293 grpc: fix the issue of return ENOENT for chmod on a file/dir
When call "C" func directly, it's needed to change the string to
CString. To avoid using the unsafe calling, replace it with the
rust safe function to set mode for a file/dir.

Signed-off-by: lifupan <lifupan@gmail.com>
2019-11-25 10:21:07 +08:00
Liu Jiang
a47a94218f agent: rename SerializeError as Error
Rename SerializeError as Error and export it as the Error codes for
the OCI crate.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-11-22 18:08:56 +08:00
Liu Jiang
c34bdd06db agent: simplify implementation of oci/serialize
Simplify implementation of oci/serialize:
1) explicitly export pub members.
2) avoid unnecessary & and mut operators.
3) define Result to avoid duplicated code.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-11-22 18:08:56 +08:00
Liu Jiang
b0edfc75ff agent: clean up clippy warnings about '`static'
warning: Constants have by default a `'static` lifetime
   --> src/lib.rs:254:26
    |
254 | pub const PIDNAMESPACE: &'static str = "pid";
    |                         -^^^^^^^---- help: consider removing `'static`: `&str`
    |
    = note: #[warn(clippy::const_static_lifetime)] on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#const_static_lifetime

Fixes: #90

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-11-22 16:48:47 +08:00
lifupan
6b611030db agent: fix the issue dead lock on AGENT_CONFIG
Once parsed cmdline and set the config on AGENT_CONFIG,
release the write lock as soon as possible. In case other
thread would get read lock on it.

Fixes:#87

Signed-off-by: lifupan <lifupan@gmail.com>
2019-11-19 18:32:11 +08:00
Yang Bo
60d713e84d
Merge pull request #82 from ericho/namespace-uts
agent: Add unit tests for `namespace.rs`
2019-11-14 07:39:56 +08:00
Eric Ernst
7be308befe
Merge pull request #81 from jodh-intel/add-version-option
Add version option
2019-11-13 08:13:03 -08:00
Erich Cordoba
8aa2c78dd2 agent: Add unit tests for namespace.rs
This patch adds a unit test for `namespace.rs`. The baseline for this
test comes from the Go agent tests in which the namespace is mounted in
a temporary folder.

In order to enable testing in the temporary folder the code was refactored
allow configuration for the specified namespace, thus the changes done
are described below:

- The `setup_persistent_ns` method was moved inside the `Namespace` type.
- A builder pattern was implemented for the `Namespace` type. This allows
  the caller to set the type of the desired namespace as well as the root
  folder which will help the testing.
- A new `NamespaceType` enum was introduced to represent the namespace type.
- The user of the `Namespace` type (sandbox.rs) was updated accordingly.

Fixes: #50

Signed-off-by: Erich Cordoba <erich.cordoba.malibran@intel.com>
2019-11-13 10:04:41 -06:00
Xu Wang
9112257c23
Merge pull request #86 from lifupan/fix_initrd_panic
agent: init agent as init before parsing cmd line
2019-11-13 01:03:48 +08:00
lifupan
d011b39e96 agent: init agent as init before parsing cmd line
When kata-agent run as init process in initrd, do the
init in which will do some base mount such as mount
/proc; thus the following config.parse_cmdline can access
/proc/cmdline to parse the parameters such as agent.log etc.

Fixes: #85

Signed-off-by: lifupan <lifupan@gmail.com>
2019-11-13 01:01:29 +08:00
James O. D. Hunt
3fe04a2ddc main: Add --version CLI option
Support `--version` which dumps the announce message and exits.

Fixes: #80.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2019-11-11 13:50:45 +00:00
Fupan Li
cb1849cd2c
Merge pull request #84 from ericho/ci-and-rustfmt
agent: Fix CI and rustfmt issues
2019-11-11 11:01:51 +08:00
Fupan Li
60609cacd0
Merge pull request #74 from yyyeerbo/wip
netlink: Fix invalid route crashes agent
2019-11-11 10:59:59 +08:00
Erich Cordoba
8834e3a759 agent: Fix CI and rustfmt issues
The CI was failing due to two problems.

1. The `ci/static-checks.sh` was run from an incorrect place.
2. `rustfmt` was failing as some code wasn't correctly formatted.

This patch address all the changed requested by rustfmt and the
`static-checks.sh` script was updated

Fixes: #83

Signed-off-by: Erich Cordoba <erich.cordoba.malibran@intel.com>
2019-11-08 15:58:59 -06:00
Yang Bo
9dce527793
Merge pull request #77 from awprice/issue-62
config: add hotplug timeout option
2019-11-08 15:05:55 +08:00
Yang Bo
089f3b4651
Merge pull request #72 from ericho/master
agent: Move test macros to a separate module to be commonly used.
2019-11-08 15:02:56 +08:00
Alex Price
e06a230c30 config: add hotplug timeout option
This adds an option to the agent to control the hotplug timeout of block devices.
Retains the previous behaviour of defaulting to 3 seconds if not specified.
Can be increased when block device hot plugging is taking longer than expected.

fixes #62

Signed-off-by: Alex Price <aprice@atlassian.com>
2019-11-06 21:12:27 +11:00
Erich Cordoba
b14f5a1f89 agent: Move test macros to a separate module to be commonly used.
The `skip_*` macros will be useful across the different tests so having
them in a separate module can help with code duplication. This change
creates a new module and exports the macros at crate level.

Signed-off-by: Erich Cordoba <erich.cordoba.malibran@intel.com>
2019-11-05 10:01:43 -06:00
Yang Bo
d33c2f84a8 netlink: Fix invalid route crashes agent
Invalid routes in update_routes request crash agent, fix it

Fixes: #73

Signed-off-by: Yang Bo <bo@hyper.sh>
2019-11-05 10:45:35 +08:00
James O. D. Hunt
f55667df38 build: Allow building with gnu target
Fixes to allow the rust agent to be built using a gnu target.
Specifically, remove assumptions about musl-specific types.

Fixes: #70.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2019-11-01 14:05:34 +00:00
Yang Bo
d045169476
Merge pull request #68 from yyyeerbo/wip
rust-agent: Set BUILDTYPE to debug.
2019-11-01 19:16:42 +08:00
Yang Bo
783cb13f8d
Merge pull request #66 from ericho/master
agent: Remove `get_key_value` to enable building in stable rust.
2019-11-01 18:59:31 +08:00
Yang Bo
9df1d0e002 rust-agent: Set BUILDTYPE to debug.
Since build with --release produces corrupted binary in ci, we removed
--release. However, the make install target cannot find the binary,
set BUILDTYPE to debug

Fixes: #67

Signed-off-by: Yang Bo <bo@hyper.sh>
2019-11-01 17:17:38 +08:00
Erich Cordoba
5c96a920bd agent: Remove get_key_value to enable building in stable rust.
The get_key_value method is currently only avaiable in nightly rust.
As only this feature is required it worth to refactor and enable building
in the stable channel.

The method was removed by first getting the value from the CGROUPS hashmap,
then key is get by iterating over all the keys. The checks for an empty key and
key == "devices" were moved out of the hashmap block.

The README.md was updated as well to detail the instructions for stable rust.

Signed-off-by: Erich Cordoba <erich.cordoba.malibran@intel.com>
2019-10-31 12:25:34 -06:00
James O. D. Hunt
2787c545ac main: Split config code into separate module
Create a config module and add more tests. Also enable setting the log
level from the kernel command-line.

Fixes: #59, #63.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2019-10-31 15:07:49 +00:00
Yang Bo
f8ced638d2 rust-agent: Land rust agent into kata-containers
Fixes: #56

Signed-off-by: Yang Bo <bo@hyper.sh>
2019-10-31 10:46:45 +08:00