Commit Graph

6199 Commits

Author SHA1 Message Date
Carlos Venegas
b0e51e59fa qemu: Improve cache build
Add arguments and files as needed, if only of them
changes the build will start from the change and
not from scratch.

Signed-off-by: Carlos Venegas <jos.c.venegas.munoz@intel.com>
2021-03-23 20:52:39 +00:00
Carlos Venegas
bc587da9f5 qemu: Add suffix for qemu binaries.
To build different qemu versions with the
same qemu code add a prefix on install.

Signed-off-by: Carlos Venegas <jos.c.venegas.munoz@intel.com>
2021-03-23 20:52:39 +00:00
Carlos Venegas
5493517b4f qemu: add CACHE_TIMEOUT
Add docker ARG to provide a date to invalid cache, if the date changes
the image will be rebuild. This is required to keep build dependencies
with security fixes, but still take advantage of build qemu faster using
docker cache.

Signed-off-by: Carlos Venegas <jos.c.venegas.munoz@intel.com>
2021-03-23 20:52:39 +00:00
Carlos Venegas
98d01ce6b9 qemu: Apply patches for specific versions.
Today we apply patches per base branch. Having
two qemu versions in a similar base version can make
can have problems if one of the trees already has a patch.
If a patch is needed only for one specific tag/commit
add only the patch to that version.

Signed-off-by: Carlos Venegas <jos.c.venegas.munoz@intel.com>
2021-03-23 20:52:39 +00:00
Tim Zhang
40861fbab5
Merge pull request #1517 from jodh-intel/agent-server-address-cmdline
agent: Allow server address to be specified on kernel command-line
2021-03-23 19:33:25 +08:00
Peng Tao
190f813427 runtime/katautils: PFlash should be initialized
newQemuHypervisorConfig() sets it to an empty slice. We have to set the
same in the test config otherwise it is nil and reflect DeepEqual would
fail.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2021-03-23 17:49:47 +08:00
Peng Tao
b2ec5a43d5 runtime: fix cleanupSandboxBindMounts panic
Found in UT:
--- FAIL: TestKataCleanupSandbox (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2021-03-23 16:44:47 +08:00
Peng Tao
9b689ea1d7 runtime/cli: fix TestMainBeforeSubCommandsLoadConfigurationFail failure
Now that it is `kata-config`...

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2021-03-23 16:40:38 +08:00
Peng Tao
8e71c4fc7a runtime: fix missing context argument in mocked sandbox APIs
Missing context.Context in several APIs.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2021-03-23 16:19:46 +08:00
Peng Tao
8ff62beeb4 runtime: fix vcmock build failure
github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/vcmock
virtcontainers/pkg/vcmock/container.go:19:10: cannot use c.MockSandbox
(type *Sandbox) as type virtcontainers.VCSandbox in return argument:
        *Sandbox does not implement virtcontainers.VCSandbox (missing
	GetHypervisorPid method)
github.com/kata-containers/kata-containers/src/runtime/pkg/katautils

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2021-03-23 15:57:07 +08:00
Tim Zhang
0e4b28e838 rustjail: rework execute_hook
Fixes: #1532

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-03-22 20:20:30 +08:00
Bin Liu
dd6da22a11
Merge pull request #1525 from Tim-Zhang/disconnect-get-oom
agent: disconnect rpc get_oom_event when destroy_sandbox.
2021-03-22 15:19:31 +08:00
Chelsea Mafrica
7da3bdc68e
Merge pull request #1363 from eadamsintel/qat-docs
docs: Update QAT instructions to work with Kata 2.0 repos
2021-03-19 18:33:19 -07:00
David Gibson
89e5fa7a2f
Merge pull request #1506 from dgibson/bug1505
agent: Update Cargo.lock for earlier dependency change
2021-03-20 11:34:32 +11:00
Chelsea Mafrica
8c1abc3b57
Merge pull request #1418 from Amulyam24/fix-docker-ppc64le
osbuiler: fixing USE_DOCKER for ppc64le
2021-03-19 17:22:12 -07:00
Chelsea Mafrica
f26db684c8
Merge pull request #1508 from dgibson/bug1507
agent: Fix unused import warning in unit tests
2021-03-19 14:20:00 -07:00
Chelsea Mafrica
3369fc8b4b
Merge pull request #1514 from fgiudici/port_cgroup_fix
[forwardport] Fixup systemd cgroup handling
2021-03-19 14:18:03 -07:00
Chelsea Mafrica
16c6c1e272
Merge pull request #1389 from cmaf/fix-span-ordering
runtime: Fix ordering of trace spans
2021-03-19 13:07:42 -07:00
Carlos Venegas
a09e58fa80 packaging: Use local file for assets.
When kata used multiple repositories, versions file was
downloaded. This is not needed anymore as the file is part
of the same repository.

Signed-off-by: Carlos Venegas <jos.c.venegas.munoz@intel.com>
2021-03-19 15:50:41 +00:00
James O. D. Hunt
451b45f9d7 agent: Make use of test consts for error messages
Make use of the `const` values for error messages that were previously
only used for the unit tests. This guarantees consistency.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2021-03-19 09:17:31 +00:00
Tim Zhang
8c4d3346d4 agent: disconnect rpc get_oom_event when destroy_sandbox.
Otherwise it would block the shutdown of ttrpc.

Fixes: #1524

Signed-off-by: Tim Zhang <tim@hyper.sh>
2021-03-19 16:42:37 +08:00
Carlos Venegas
07cfa4ce22 qemu: patches: Fail if not patches directory
Fail if not patches directory is found.  Help to prevent
build a new qemu version with missing patches.

Signed-off-by: Carlos Venegas <jos.c.venegas.munoz@intel.com>
2021-03-18 20:07:40 +00:00
Carlos Venegas
e221c45d7a versions: Update qemu database
Only use 'version' key to build qemu..

The version could be used as any valid target:
branch, tag or commit.

Using different keys to build is confusing.

Signed-off-by: Carlos Venegas <jos.c.venegas.munoz@intel.com>
2021-03-18 19:37:35 +00:00
Carlos Venegas
5abdd2aaf0 qemu: move 5.0.0 patches to its own dir.
Some patches has conflicts with old experimental kernel. Move patches to its own specific version.

Signed-off-by: Carlos Venegas <jos.c.venegas.munoz@intel.com>
2021-03-18 19:25:55 +00:00
Adams, Eric
259c179162 docs: Update QAT instructions to work with Kata 2.0 repos
This fixes the guide to work with the Kata 2.0 repos and provide more
details on how to verify with ctr and kubernetes.

Fixes: #1362

Signed-off-by: Adams, Eric <eric.adams@intel.com>
2021-03-18 11:19:46 -07:00
James O. D. Hunt
34e7d5ed97 agent: Validate CID
Validate the container ID as we cannot / should not rely on the
container manager / runtime to do this.

Fixes: #1520.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2021-03-18 11:19:34 +00:00
James O. D. Hunt
b265870997 runtime: Validate CID
Validate the container ID as we cannot rely on the container manager
doing this.

Fixes: #1520.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2021-03-18 11:19:32 +00:00
James O. D. Hunt
12e9f7f82c runtime: Add missing test mock function
Added a missing `vcmock.Sandbox.GetHypervisorPid()` function.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2021-03-17 10:37:47 +00:00
James O. D. Hunt
ea51c17b64 agent: Allow server address to be specified on kernel command-line
To make debugging and testing easier, allow the ttRPC server address to
be specified via `/proc/cmdline` as `agent.server_addr=`.

Fixes: #1516.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2021-03-17 08:22:03 +00:00
Chelsea Mafrica
4bf84b4b2f runtime: Add contexts to calls in unit tests
Modify calls in unit tests to use context since many functions were
updated to accept local context to fix trace span ordering.

Fixes #1355

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
2021-03-16 17:39:28 -07:00
Chelsea Mafrica
9e4932a6e2 runtime: use root span for shimv2 tracing
Add rootCtx to service struct in shimv2 to use as parent of spans
created in shimv2 for a more organized trace ouput.

Fixes #1355

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
2021-03-16 17:39:28 -07:00
Chelsea Mafrica
6b0dc60dda runtime: Fix ordering of trace spans
A significant number of trace calls did not use a parent context that
would create proper span ordering in trace output. Add local context to
functions for use in trace calls to facilitate proper span ordering.
Additionally, change whether trace function returns context in some
functions in virtcontainers and use existing context rather than
background context in bindMount() so that span exists as a child of a
parent span.

Fixes #1355

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
2021-03-16 17:39:28 -07:00
Fabiano Fidêncio
50f317dcff
Merge pull request #1463 from egernst/bindmount-infra
runtime: add support for readonly sandbox bindmounts
2021-03-16 11:34:53 +01:00
Julien Ropé
3a77e4eb8c build: remove unused variables from Makefile
Some variable are initialized in the Makefile, but never used.
Removing them to clean up the Makefile.

Fixes: #1003

Signed-off-by: Julien Ropé <jrope@redhat.com>
2021-03-16 08:51:16 +01:00
Eric Ernsteernst
d7cb3df0d2 cgroups: Add systemd detection when creating cgroup manager
Look at the provided cgroup path to determine whether systemd is being
used to manage the cgroups. With this, systemd cgroups are being detected
and created appropriately for the sandbox.

Fixes: #599

Signed-off-by: Eric Ernsteernst <eric@amperecomputing.com>

(forward port of https://github.com/kata-containers/runtime/pull/2817)
Signed-off-by: Francesco Giudici <fgiudici@redhat.com>
2021-03-16 08:27:14 +01:00
Eric Ernsteernst
f659871f55 cgroups: remove unused SystemdCgroup variable and accessor/mutators
Since we are now detecting, no longer to keep this state.

Signed-off-by: Eric Ernsteernst <eric@amperecomputing.com>

(forward port of https://github.com/kata-containers/runtime/pull/2817)
Signed-off-by: Francesco Giudici <fgiudici@redhat.com>
2021-03-16 08:26:15 +01:00
Wainer Moschetta
943a7553be
Merge pull request #1496 from wainersm/qemu_5_2-respin
Bump to QEMU 5.2.0 - respin
2021-03-12 09:48:14 -03:00
David Gibson
b0e966c3bd agent: Fix unused import warning in unit tests
This unneeded import was accidentally introduced by 81607e34.

fixes #1507

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-03-12 17:25:13 +11:00
David Gibson
d5a9d56e79 agent: Update Cargo.lock for earlier dependency change
Commit 81607e34 updated src/agent/rustjail/Cargo.toml, to remove an
unneeded dependency.  That causes cargo to update src/agent/Cargo.lock
on each build.  However, the change to Cargo.lock wasn't checked in
meaning anyone working on the agent code will get bogus diffs with every
build.  Check in the missing file to fix this.

fixes #1505

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-03-12 16:51:30 +11:00
Fupan Li
62d30ca2b6
Merge pull request #1498 from liubin/fix/1497-task-exit-pid
runtime: return hypervisor Pid in TaskExit event
2021-03-11 12:58:28 +08:00
Bo Chen
396565fa56
Merge pull request #1489 from jcvenegas/2021-03-03/codecov
agent: makefile: Add codecov target
2021-03-10 11:21:33 -08:00
Wainer dos Santos Moschetta
0f7950fb2a packaging: configure QEMU with -O2
Currently the the configure-hypervisor.sh doesn't set any optimization flag when
compiling QEMU >= 5.2.0 since the configure script will implicitly set -O2 on Ubuntu. But
on other environments, for example CentOS 7, it won't be set any optimization and this
results on the compiler warn:

  # warning _FORTIFY_SOURCE requires compiling with optimization (-O)

To avoid this inconsistent behavior across different build environments, let's explicitly
set the -O2 flag.

Reported-by: Eric Ernst <eric.g.ernst@gmail.com>
Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
2021-03-10 11:16:52 -03:00
Wainer dos Santos Moschetta
224c50f420 snap: Package virtiofsd and fix path
This contain to fixes for the virtiofsd on snap:
 * removed the "-/usr/libexec" so that virtiofsd is copied to prime
 * The configuration.toml expects virtiofsd in /usr/libexec/kata-qemu so it should be passed "kata-qemu"
   to configure_hypervisor.sh script and it wil configure to install the executable onto the right directory.

Fixes #1238
Depends-on: github.com/kata-containers/kata-containers#1349
Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
2021-03-10 11:16:52 -03:00
Wainer Moschetta
6e496941a5
Merge pull request #1349 from wainersm/qemu_5_2
Bump to QEMU 5.2.0
2021-03-10 11:14:45 -03:00
Peng Tao
e0f191fbbc
Merge pull request #1501 from egernst/fix-exec-groups
exec: ensure sup groups are added to agent request
2021-03-10 10:18:24 +08:00
Eric Ernst
f0d49851db exec: ensure sup groups are added to agent request
Extra groups were not being handled when exec'ing. Ensure
that these are handled.

Before this, running a pod with:
```
 ...snippet...
 securityContext:
   fsGroup: 266
   runAsGroup: 51020
   runAsUser: 264
```

And then exec'ing would not supply the fsGroup:
```
$ kubectl exec -it kata-bb  -- sh -c id
uid=264 gid=51020
```

Fixes: #1500

Signed-off-by: Eric Ernst <eric.g.ernst@gmail.com>
2021-03-09 17:17:55 -08:00
Fabiano Fidêncio
9e90105092
Merge pull request #1495 from lifupan/fix_homedir
rustjail: fix the issue of home_dir function
2021-03-09 14:36:45 +01:00
bin
b034458960 runtime: return hypervisor Pid in TaskExit event
Other RPC calls return Pid of hypervisor, the TaskExit should
return the same Pid.

Fixes: #1497

Signed-off-by: bin <bin@hyper.sh>
2021-03-09 17:41:44 +08:00
GabyCT
856ffb85fc
Merge pull request #1420 from eadamsintel/qat-dockerfile
osbuilder: Port QAT Dockerfile to 2.0 repo
2021-03-08 11:34:28 -06:00
fupan.lfp
81607e348e rustjail: fix the issue of home_dir function
Since the crate dirs::home_dir function depends on the
libc's api: getpwuid_r, but this api function wouldn't
be static linked on glibc, thus we'd better to figure
out an alternative way to get the home dir from /etc/passwd.
For much more info about this glibc's issue, please see:
https://sourceware.org/bugzilla/show_bug.cgi?id=19341.

This commit read and parse the "/etc/passwd" directly and
fetch the corresponding uid's home dir.

Fixes: #675

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
2021-03-08 21:51:23 +08:00