Commit Graph

705 Commits

Author SHA1 Message Date
Alex Carter
638c2c4164 static-build: Add AmdSev option for OVMF builder
Introduces new build of firmware needed for SEV

Fixes: kata-containers#4169

Signed-off-by: Alex Carter <alex.carter@ibm.com>
2022-07-28 09:56:06 -05:00
Alex Carter
f0b58e38d2 static-build: Add build script for OVMF
Introduces a build script for OVMF. Defaults to X86_64 build (x64 in OVMF)

Fixes: #4169

Signed-off-by: Alex Carter <alex.carter@ibm.com>
2022-07-28 09:07:49 -05:00
GabyCT
9dfd949f23
Merge pull request #4646 from amshinde/add-liburing-qemu
qemu: Add liburing to qemu build
2022-07-27 15:47:49 -05:00
Archana Shinde
f690b0aad0 qemu: Add liburing to qemu build
io_uring is a Linux API for asynchronous I/O introduced in qemu 5.0.
It is designed to better performance than older aio API.
We could leverage this in order to get better storage performance.

We should be adding liburing-dev to qemu build to leverage this feature.
However liburing-dev package is not available in ubuntu 20.04,
it is avaiable in 22.04.

Upgrading the ubuntu version in the dockerfile to 22.04 is causing
issues in the static qemu build related to libpmem.

So instead we are building liburing from source until those build issues
are solved.

Fixes: #4645

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2022-07-14 19:21:47 -07:00
Fabiano Fidêncio
051181249c packaging: Add a "-" in the dir name if $BUILD_DIR is available
Currently $BUILD_DIR will be used to create a directory as:
/opt/kata/share/kata-qemu${BUILD_DIR}

It means that when passing a BUILD_DIR, like "foo", a name would be
built like /opt/kata/share/kata-qemufoo
We should, instead, be building it as /opt/kata/share/kata-qemu-foo.

Fixes: #4638

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-07-12 21:27:41 +02:00
Fabiano Fidêncio
201ff223f6 packaging: Use the $BUILD_SUFFIX when renaming the qemu binary
Instead of always naming the binary as "-experimental", let's take
advantage of the $BUILD_SUFFIX that's already passed and correctly name
the binary according to it.

Fixes: #4638

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-07-12 15:09:31 +02:00
Bin Liu
9f0e4bb775
Merge pull request #4628 from fidencio/topic/rework-tee-kernel-builds
kernel: Deduplicate code used for building TEE kernels
2022-07-12 17:25:04 +08:00
Fabiano Fidêncio
cda1919a0a
Merge pull request #4609 from fidencio/topic/kata-deploy-simplify-config-path-handling
packaging: Simplify config path handling
2022-07-11 23:48:54 +02:00
Fabiano Fidêncio
1a25afcdf5 kernel: Allow passing the URL to download the tarball
Passing the URL to be used to download the kernel tarball is useful in
various scenarios, mainly when doing a downstream build, thus let's add
this new option.

This new option also works around a known issue of the Dockerfile used
to build the kernel not having `yq` installed.

Fixes: #4629

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-07-11 14:23:49 +02:00
Fabiano Fidêncio
80c68b80a8 kernel: Deduplicate code used for building TEE kernels
There's no need to have the entire function for building SEV / TDX
duplicated.

Let's remove those functions and create a `get_tee_kernel()` which takes
the TEE as the argument.

Fixes: #4627

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-07-11 13:25:17 +02:00
Fabiano Fidêncio
46fd7ce025
Merge pull request #4595 from amshinde/fix-clh-tarball-build
Fix clh tarball build
2022-07-08 20:15:30 +02:00
Fabiano Fidêncio
f7ccf92dc8 kata-deploy: Rely on the configured config path
Instead of passing a `KATA_CONF_FILE` environament variable, let's rely
on the configured (in the container engine) config path, as both
containerd and CRI-O support it, and we're using this for both of them.

Fixes: #4608

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-07-08 15:02:26 +02:00
Fabiano Fidêncio
386a523a05 kata-deploy: Pass the config path to CRI-O
As we're already doing for containerd, let's also pass the configuration
path to CRI-O, as all the supported CRI-O versions do support this
configuration option.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-07-08 12:36:47 +02:00
Archana Shinde
e57a1c831e build: Mark git repos as safe for build
This is not an issue when the build is run as non-privilged user.
Marking these as safe in case where the build may be run as root
or some other user.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2022-07-07 12:11:00 -07:00
Fabiano Fidêncio
c09634dbc7
Merge pull request #4592 from fidencio/revert-kata-deploy-changes-after-2.5.0-rc0-release
release: Revert kata-deploy changes after 2.5.0-rc0 release
2022-07-07 08:59:43 +02:00
Bin Liu
bee7915932
Merge pull request #4533 from bookinabox/simplify-nproc
tools/snap: simplify nproc
2022-07-07 11:38:29 +08:00
Archana Shinde
efdb92366b build: Fix clh source build as normal user
While running make as non-privileged user, the make errors out with
the following message:
"INFO: Build cloud-hypervisor enabling the following features: tdx
Got permission denied while trying to connect to the Docker daemon
socket at unix:///var/run/docker.sock: Post
"http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/create?fromImage=cloudhypervisor%2Fdev&tag=20220524-0":
dial unix /var/run/docker.sock: connect: permission denied"

Even though the user may be part of docker group, the clh build from
source does a docker in docker build. It is necessary for the user of
the nested container to be part of docker build for the build to
succeed.

Fixes #4594

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2022-07-06 18:28:00 -07:00
Derek Lee
0e40ecf383 tools/snap: simplify nproc
Replaces calls of nproc	with nproc with

nproc ${CI:+--ignore 1}

to run nproc with one less processing unit than the maximum to prevent
DOS-ing the local machine.

If process is being run in a container (determined via whether $CI is
null), all processing units avaliable will be used.

Fixes #3967

Signed-off-by: Derek Lee <derlee@redhat.com>
2022-07-06 15:04:08 -07:00
Fabiano Fidêncio
5010c643c4 release: Revert kata-deploy changes after 2.5.0-rc0 release
As 2.5.0-rc0 has been released, let's switch the kata-deploy / kata-cleanup
tags back to "latest", and re-add the kata-deploy-stable and the
kata-cleanup-stable files.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2022-07-05 22:23:49 +02:00
Fabiano Fidêncio
f4eea832a1 release: Adapt kata-deploy for 2.5.0-rc0
kata-deploy files must be adapted to a new release.  The cases where it
happens are when the release goes from -> to:
* main -> stable:
  * kata-deploy-stable / kata-cleanup-stable: are removed

* stable -> stable:
  * kata-deploy / kata-cleanup: bump the release to the new one.

There are no changes when doing an alpha release, as the files on the
"main" branch always point to the "latest" and "stable" tags.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2022-07-05 22:23:05 +02:00
Archana Shinde
4e48509ed9 build: Set safe.directory for runtime repo
While doing a docker build for shim-v2, we see this:

```
fatal: unsafe repository
('/home/${user}/go/src/github.com/kata-containers/kata-containers' is
owned by someone else)
To add an exception for this directory, call:

        git config --global --add safe.directory
/home/${user}/go/src/github.com/kata-containers/kata-containers
```

This is because the docker container build is run as root while the
runtime repo is checked out as normal user.

Unlike this error causing the rootfs build to error out, the error here
does not really cause `make shim-v2-tarball` to fail.

However its good to get rid of this error message showing during the
make process.

Fixes: #4572

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2022-06-30 20:52:44 -07:00
Gabriela Cervantes
1a78c3df2e packaging: Remove unused kata docker configure script
This PR removes an unused kata configure docker script which was used
in packaging for kata 1.x but not longer being used in kata 2.x

Fixes #4546

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
2022-06-28 15:10:39 +00:00
Archana Shinde
2488a0f6c0
Merge pull request #4439 from amshinde/update-kernel-to-5.15.46
versions: Update kernel to latest LTS version 5.15.48
2022-06-24 11:03:32 -07:00
Archana Shinde
93874cb3bb packaging: Restrict kernel patches applied to top-level dir
The apply_patches.sh script applies all patches in the patches
directory,  as well as subdirectories. This means if there is a sub-dir
called "experimental" under a major kernel version directory,
experimental patches would be applied to the default kernel supported by
Kata.
We did not come accross this issue earlier as typically the experimental
kernel version was different from the default kernel.
With both the default kernel and the arm-experimental kernel having the
same major kernel version (5.15.x) at this time, trying to update the
kernel patch version revealed that arm-experimental patches were being
applied to the default kernel.

Restricting the patches to be applied to the top level directory will
solve the issue. The apply_patches script should ignore any
sub-directories meant for experimental patches.

Fixes #4520

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2022-06-23 10:43:52 -07:00
Fabiano Fidêncio
9ff10c0830 kernel: Add CONFIG_EFI=y as part of the TDX fragments
Otherwise `./build-kernel.sh -x tdx setup` will fail with the following
error:
```
$ ./build-kernel.sh -x tdx setup
INFO: Config version: 92
INFO: Kernel version: tdx-guest-v5.15-4
INFO: kernel path does not exist, will download kernel
INFO: Apply patches from
/home/ffidenci/go/src/github.com/kata-containers/kata-containers/tools/packaging/kernel/patches/tdx-guest-v5.15-4.x
INFO: Found 0 patches
INFO: Enabling config for 'tdx' confidential guest protection
INFO: Constructing config from fragments:
/home/ffidenci/go/src/github.com/kata-containers/kata-containers/tools/packaging/kernel/configs/fragments/x86_64/.config

WARNING: unmet direct dependencies detected for UNACCEPTED_MEMORY
  Depends on [n]: EFI [=n] && EFI_STUB [=n]
  Selected by [y]:
  - INTEL_TDX_GUEST [=y] && HYPERVISOR_GUEST [=y] && X86_64 [=y] &&
    CPU_SUP_INTEL [=y] && PARAVIRT [=y] && SECURITY [=y] &&
     X86_X2APIC[=y]
INFO: Some CONFIG elements failed to make the final .config:
INFO: Value requested for CONFIG_EFI_STUB not in final .config
INFO: Generated config file can be found in
/home/ffidenci/go/src/github.com/kata-containers/kata-containers/tools/packaging/kernel/configs/fragments/x86_64/.config
ERROR: Failed to construct requested .config file
ERROR: failed to find default config
```

Fixes: #4510

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-06-22 15:21:30 +02:00
Bin Liu
e422730c7f
Merge pull request #4497 from GabyCT/topic/removeunusedref
packaging: Remove unused publish kata image script
2022-06-21 17:46:45 +08:00
James O. D. Hunt
e11fcf7d3c
Merge pull request #4168 from Champ-Goblem/patch/fix-chronyd-failure-on-boot
rootfs: Fix chronyd.service failing on boot
2022-06-21 09:43:13 +01:00
Gabriela Cervantes
c7dd10e5ed packaging: Remove unused publish kata image script
This PR removes unused the publish kata image script which
was used on kata 1.x when we had OBS packages which are not
longer used on kata 2.x

Fixes #4496

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
2022-06-20 14:43:39 +00:00
Chelsea Mafrica
1d5448fbca
Merge pull request #4180 from Alex-Carter01/build-kernel-efi-secret
kernel building: efi_secret module
2022-06-13 13:34:06 -07:00
Fabiano Fidêncio
1ef0b7ded0 runtime: Switch to using the rust version of virtiofsd (all but power)
So far this has been done for x86_64.  Now that the support for building
and testing has been added for all arches, let's do the second part of
the switch.

We're still not done yet for powerpc, as some a virtifosd crash on the
rust version has been found by the maintainer.

Fixes: #4258, #4260

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-06-13 10:41:26 +02:00
Fabiano Fidêncio
9773838c01 virtiofsd: export env vars needed for building it
@jongwu, mentioned on an PR[0] that env vars should be exported to
ensure that virtiofsd is statically built for non-x86_64 architectures.

[0]: https://github.com/kata-containers/kata-containers/pull/4308#issuecomment-1137125592

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-06-10 13:27:02 +02:00
Alex Carter
db5048d52c kernel: build efi_secret module for SEV
Add kernel fork for sev to kernel builder with efi_secret. Additionally, install efi_secret module for sev.

Fixes: #4179
Signed-off-by: Alex Carter <alex.carter@ibm.com>
2022-06-09 12:28:43 -05:00
Fabiano Fidêncio
24182d72d9
Merge pull request #4322 from jodh-intel/snap-cleanup
snap: Use helper script and cleanup
2022-06-02 11:47:02 +02:00
Eric Ernst
7c4049aabb osbuilder: add iptables package
Since we are introducing an agent API for interacting with guest
iptables, let's ensure that our example rootfs' have iptables-save/restore
installed.

Fixes: #4356

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2022-05-31 09:21:02 -07:00
James O. D. Hunt
cb2b30970d snap: Build using destructive mode
Destructive mode is required to build the Kata Containers snap. See:

```
.github/workflows/snap-release.yaml
.github/workflows/snap.yaml
```

Hence, update the last file that we forgot to update with
`--destructive-mode`.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-05-26 15:56:36 +01:00
James O. D. Hunt
60823abb9c docs: Move snap README
Move the snap README to a subdirectory to resolve the warning given by
`snapcraft` (folded and reformatted slightly for clarity):

```
The 'snap' directory is meant specifically for snapcraft,
but it contains the following non-snapcraft-related paths,
which is unsupported and will cause unexpected behavior:

- README.md

If you must store these files within the 'snap' directory,
move them to 'snap/local', which is ignored by snapcraft.
```

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-05-26 15:56:36 +01:00
Jianyong Wu
10c13d719a qemu: remove virtiofsd option in qemu config
As virtiofsd will be built base on rust, "virtiofsd" option is no longer
needed in qemu.

Fixes: #4258
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2022-05-23 12:57:59 +08:00
Jianyong Wu
d20bc5a4d2 virtiofsd: build rust based virtiofsd from source for non-x86_64
Based on @fidencio's opoinon,
On Arm: static build virtiofsd using musl lib;
on ppc64 & s390: static build virtiofsd using gnu lib;

Fixes: #4258
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2022-05-23 12:57:59 +08:00
Gabriela Cervantes
24a2b0f6a2 docs: Remove clear containers reference in README
This PR removes the clear containers reference as this is not longer
being used and is deprecated at the rootfs builder README.

Fixes #4278

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
2022-05-18 14:53:17 +00:00
GabyCT
9458cc0053
Merge pull request #4273 from GabyCT/topic/removenemuconf
kernel: Remove nemu.conf from packaging
2022-05-17 16:06:45 -05:00
Gabriela Cervantes
abad33eba0 kernel: Remove nemu.conf from packaging
This PR removes the nemu.conf as we are not longer using NEMU from
the kernel configurations.

Fixes #4272

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
2022-05-17 16:23:17 +00:00
Rafael Fonseca
e87eb13c4f tools: delete unused param from get_from_kata_deps callers
The param was deleted by a09e58fa80, so
update the callers not to use it.

Fixes #4245

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
2022-05-17 15:18:41 +02:00
Chelsea Mafrica
4f586d2a91 packaging: Add kernel config option for SGX in Gramine
For the Gramine Shielded Containers guest kernel, CONFIG_NUMA must be
enabled.

Fixes  #4266

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
2022-05-16 16:58:26 -07:00
Fabiano Fidêncio
6ffdebd202
Merge pull request #4255 from cmaf/tools-patch-qemu-sgx-numa
tools: Add QEMU patches for SGX numa support
2022-05-16 18:10:41 +02:00
Fabiano Fidêncio
d1f2852d8b tools: Stop building virtiofsd with qemu (for x86_64)
As we finally can move to using the rust virtiofs daemon, let's stop
bulding and packaging the C version of the virtiofsd for x86_64.

Fixes: #4249
Depends-on: github.com/kata-containers/tests#4785

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-05-16 09:30:24 +02:00
Chelsea Mafrica
b4b9068cb7 tools: Add QEMU patches for SGX numa support
There are a few patches for SGX numa support in QEMU added after the
6.2.0 release. Add them for SGX support in Kata.

Fixes #4254

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
2022-05-13 16:34:57 -07:00
Fabiano Fidêncio
71f59f3a7b local-build: Add support for building virtiofsd
As done for the other binaries we release, let's add support for
"building" (or pulling down) the static binary we ship as part of the
kata-containers static tarball (the same one used by kata-deploy).

Right now the virtiofsd is installed in /opt/kata/libexec/virtiofsd, a
different path than the virtiofsd that comes with QEMU.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-05-13 11:37:36 +02:00
Fabiano Fidêncio
c7ac55b6d7 dockerbuild: Install unzip
As virtiofsd comes in the `zip` format, let's install unzip in the
containers and then be able to access the virtiofsd binary.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-05-13 11:37:36 +02:00
Fabiano Fidêncio
8e2042d055 tools: add script to pull virtiofsd
Right now this is very much x86_64 specific, but I'd like to count on
the maintainers of the other architectures to expand it.

Also, the name as it's now may be misleading, as we're actually only
pulling the binary that's statically built using `musl` and released as
part of virtiofsd official releases.  But we'll need to build it for the
other architectures, thus I'm following the naming of the scripts used
by the other components.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-05-13 11:37:21 +02:00
Champ-Goblem
1b7fd19acb rootfs: Fix chronyd.service failing on boot
In at least kata versions 2.3.3 and 2.4.0 it was noticed that the guest
operating system's clock would drift out of sync slowly over time
whilst the pod was running.

This had previously been raised and fixed in the old reposity via [1].
In essence kvm_ptp and chrony were paired together in order to
keep the system clock up to date with the host.

In the recent versions of kata metioned above,
the chronyd.service fails upon boot with status `266/NAMESPACE`
which seems to be due to the fact that the `/var/lib/chrony`
directory no longer exists.

This change sets the `/var/lib/chrony` directory for the `ReadWritePaths`
to be ignored when the directory does not exist, as per [2].

[1] https://github.com/kata-containers/runtime/issues/1279
[2] https://www.freedesktop.org/software/systemd
/man/systemd.exec.html#ReadWritePaths=

Fixes: #4167
Signed-off-by: Champ-Goblem <cameron_mcdermott@yahoo.co.uk>
2022-04-29 17:15:29 +01:00
Julio Montes
081f6de874 versions: change qemu tdx url and tag
https://github.com/intel/qemu-dcp is the new repo that supports
qemu with Intel TDX

fixes #4171

Signed-off-by: Julio Montes <julio.montes@intel.com>
2022-04-28 13:46:11 -05:00
Fabiano Fidêncio
ccb0183934 kata-deploy: Add support to RKE2
"RKE2 - Rancher's Next Generation Kuberentes Distribution" can easily be
supported by kata-deploy with some simple adjustments to what we've been
relying on for "k3s".

The main differences between k3s and RKE2 are, basically:
1. The location where the containerd configuration is stored
   - k3s: /var/lib/rancher/k3s/agent/etc/containerd/
   - rke2: /var/lib/rancher/rke2/agent/etc/containerd/
2. The name of the systemd services used:
   - k3s: k3s.service or k3s-agent.service
   - rke2: rke2-server.service or rke2-agent.service

Knowing this, let's add a new overlay for RKE2, adapt the kata-deploy
and the kata-cleanup scripts, and that's it.

Fixes: #4160

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-04-27 19:05:36 +02:00
Fabiano Fidêncio
9d39362e30 kata-deploy: Reestructure the installing section
Let's move the specific installation instructions, such as for k3s,
upper in the document.

This helps reading (and also skipping) according to what the user
is looking for.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2022-04-27 19:05:36 +02:00
Fabiano Fidêncio
18d27f7949 kata-deploy: Add a missing $ prefix in the README
Commit short-log says it all.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2022-04-27 19:05:36 +02:00
Greg Kurz
b658dccc5f tools: fix typo in clh directory name
This allows to get released binaries again.

Fixes: #4151

Signed-off-by: Greg Kurz <groug@kaod.org>
2022-04-26 17:57:32 +02:00
Greg Kurz
afbd60da27 packaging: Fix clh build from source fall-back
If we fail to download the clh binary, we fall-back to build from source.
Unfortunately, `pull_clh_released_binary()` leaves a `cloud_hypervisor`
directory behind, which causes `build_clh_from_source()` not to clone
the git repo:

    [ -d "${repo_dir}" ] || git clone "${cloud_hypervisor_repo}"

When building from a kata-containers git repo, the subsequent calls
to `git` in this function thus apply to the kata-containers repo and
eventually fail, e.g.:

+ git checkout v23.0
error: pathspec 'v23.0' did not match any file(s) known to git

It doesn't quite make sense actually to keep an existing directory the
content of which is arbitrary when we want to it to contain a specific
version of clh. Just remove it instead.

Fixes: #4151

Signed-off-by: Greg Kurz <groug@kaod.org>
2022-04-26 17:57:32 +02:00
David Esparza
9e4ca0c4f8 doc: Improve kata-deploy README.md by changing sh blocks to bash blocks
The idea is to pass this README file to kata-doc-to-script.sh script and
then execute the result.

Added comments with a file name on top of each YAML snippet.
This helps in assigning a file name when we cat the YAML to a file.

Fixes: #3943

Signed-off-by: David Esparza <david.esparza.borquez@intel.com>
2022-03-30 05:30:41 -04:00
snir911
f1a88371c8
Merge pull request #3991 from gkurz/fix-kata-deploy-binaries-sh
tools/packaging: Fix error path in `kata-deploy-binaries.sh -s`
2022-03-30 11:51:43 +03:00
Hui Zhu
e1a39bde8b
Merge pull request #3987 from bergwolf/kata-deploy
kata-deploy: fix version bump from -rc to stable
2022-03-30 16:13:27 +08:00
Greg Kurz
a779e19bee tools/packaging: Fix error path in 'kata-deploy-binaries.sh -s'
`make kata-tarball` relies on `kata-deploy-binaries.sh -s` which
silently ignores errors, and you may end up with an incomplete
tarball without noticing it because `make`'s exit status is 0.

`kata-deploy-binaries.sh` does set the `errexit` option and all the
code in the script seems to assume that since it doesn't do error
checking. Unfortunately, bash automatically disables `errexit` when
calling a function from a conditional pipeline, like done in the `-s`
case:

	if [ "${silent}" == true ]; then
		if ! handle_build "${t}" &>"$log_file"; then
                ^^^^^^
           this disables `errexit`

and `handle_build` ends with a `tar tvf` that always succeeds.

Adding error checking all over the place isn't really an option
as it would seriously obfuscate the code. Drop the conditional
pipeline instead and print the final error message from a `trap`
handler on the special ERR signal. This requires the `errtrace`
option as `trap`s aren't propagated to functions by default.

Since all outputs of `handle_build` are redirected to the build
log file, some file descriptor duplication magic is needed for
the handler to be able to write to the orignal stdout and stderr.

Fixes #3757

Signed-off-by: Greg Kurz <groug@kaod.org>
2022-03-29 19:00:46 +02:00
Greg Kurz
0baebd2b37 tools/packaging: Fix usage of kata-deploy-binaries.sh
Add missing documentation for -s .

Signed-off-by: Greg Kurz <groug@kaod.org>
2022-03-29 19:00:46 +02:00
Fabiano Fidêncio
2eb07455d0 tools: Add a generate_vendor.sh script
This script is responsible for generating a tarball with all the rust
vendored code that is needed for fully building kata-containers on a
disconnected environment.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-03-29 12:36:36 +02:00
Peng Tao
93d03cc064 kata-deploy: fix version bump from -rc to stable
In such case, we should bump from "latest" tag rather than from
current_version.

Fixes: #3986
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2022-03-29 03:41:12 +00:00
David Gibson
025fa60268
Merge pull request #3969 from gkurz/kata-deploy-copy-yq-installer
tools/packaging/kata-deploy: Copy install_yq.sh before starting parallel builds
2022-03-29 12:56:09 +11:00
GabyCT
a07956a369
Merge pull request #3966 from devimc/2022-03-22/fixOsbuilderQAT
osbuilder/qat: don't pull kata sources if exist
2022-03-25 15:12:03 -06:00
Julio Montes
c27963276b osbuilder/qat: don't pull kata sources if exist
don't pull kata sources if they already exist under GOPATH

fixes #3965

Signed-off-by: Julio Montes <julio.montes@intel.com>
2022-03-25 09:09:52 -06:00
Greg Kurz
154c8b03d3 tools/packaging/kata-deploy: Copy install_yq.sh in a dedicated script
'make kata-tarball' sometimes fails early with:

cp: cannot create regular file '[...]/tools/packaging/kata-deploy/local-build/dockerbuild/install_yq.sh': File exists

This happens because all assets are built in parallel using the same
`kata-deploy-binaries-in-docker.sh` script, and thus all try to copy
the `install_yq.sh` script to the same location with the `cp` command.
This is a well known race condition that cannot be avoided without
serialization of `cp` invocations.

Move the copying of `install_yq.sh` to a separate script and ensure
it is called *before* parallel builds. Make the presence of the copy
a prerequisite for each sub-build so that they still can be triggered
individually. Update the GH release workflow to also call this script
before calling `kata-deploy-binaries-in-docker.sh`.

Fixes #3756

Signed-off-by: Greg Kurz <groug@kaod.org>
2022-03-25 15:59:24 +01:00
David Gibson
1ed7da8fc7 packaging: Eliminate TTY_OPT and NO_TTY variables in kata-deploy
NO_TTY configured whether to add the -t option to docker run.  It makes no
sense for the caller to configure this, since whether you need it depends
on the commands you're running.  Since the point here is to run
non-interactive build scripts, we don't need -t, or -i either.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Greg Kurz <groug@kaod.org>
2022-03-25 15:52:02 +01:00
David Gibson
bad859d2f8 tools/packaging/kata-deploy/local-build: Add build to gitignore
This directory consists entirely of files built during a make kata-tarball,
so it should not be committed to the tree. A symbolic link to this directory
might be created during 'make tarball', ignore it as well.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
[greg: - rearranged the subject to make the subsystem checker happy
       - also ignore the symbolic link created by
         `kata-deploy-binaries-in-docker.sh`]
Signed-off-by: Greg Kurz <groug@kaod.org>
2022-03-25 15:52:02 +01:00
Julio Montes
459f4bfedb osbuilder/qat: use centos as base OS
move away from ubuntu, since now it's easier to build using
CentOS as base OS

fixes #3936

Signed-off-by: Julio Montes <julio.montes@intel.com>
2022-03-24 08:18:29 -06:00
GabyCT
d9cd8cde2b
Merge pull request #3909 from fidencio/wip/clh-allow-testing-a-specific-pr
static-build,clh: Add the ability to build from a PR
2022-03-23 15:24:34 -06:00
James O. D. Hunt
3edf25b6c9
Merge pull request #3682 from Jakob-Naucke/cross
Multistrap Ubuntu & enable cross-building guest
2022-03-21 11:11:47 +00:00
Fabiano Fidêncio
ebec6903b8 static-build,clh: Add the ability to build from a PR
Right now it doesn't do much for us, as we're always building from a
specific version.  However, this opens the possibility for us to add a
CI, similar to the one we have for CRI-O, for testing against each
cloud-hypervisor PR, on the cloud-hypervisor branch.

Fixes: #3908

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-03-20 11:24:40 +01:00
Julio Montes
18d4d7fb1d tools: update QEMU to 6.2
bring Intel SGX support

Changes tha may impact in Kata Containers
Arm:
The 'virt' machine now supports an emulated ITS
The 'virt' machine now supports more than 123 CPUs in TCG emulation mode
The pl031 real-time clock device now supports sending RTC_CHANGE QMP events

PowerPC:
Improved POWER10 support for the 'powernv' machine
Initial support for POWER10 DD2.0 CPU added
Added support for FORM2 PAPR NUMA descriptions in the "pseries" machine
 type

s390x:
Improved storage key emulation (e.g. fixed address handling, lazy
 storage key enablement for TCG, ...)
New gen16 CPU features are now enabled automatically in the latest
 machine type

KVM:
Support for SGX in the virtual machine, using the /dev/sgx_vepc device
 on the host and the "memory-backend-epc" backend in QEMU.
New "hv-apicv" CPU property (aliased to "hv-avic") sets the
 HV_DEPRECATING_AEOI_RECOMMENDED bit in CPUID[0x40000004].EAX.

virtio-mem:
QEMU now fully supports guest memory dumps with virtio-mem.
QEMU now cleanly supports precopy migration, postcopy migration and
 background snapshots with virtio-mem.

fixes #3902

Signed-off-by: Julio Montes <julio.montes@intel.com>
2022-03-16 10:35:39 -06:00
Garrett Mahin
dacf6e3955 doc: fix filename typo
Corrects a filename typo in cleanup cluster part
of kata-deploy README.md

Fixes: #3869
Signed-off-by: Garrett Mahin <garrett.mahin@gmail.com>
2022-03-13 17:39:08 -05:00
James O. D. Hunt
5d6d39be48 scripts: Change here document delimiters
Fix the outstanding scripts using non standard shell here document delimiters.

This should have been caught by
https://github.com/kata-containers/tests/pull/3937, but there is a bug
in the checker which is fixed on
https://github.com/kata-containers/tests/pull/4569.

Fixes: #3864.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-03-10 09:23:37 +00:00
Eric Ernst
e042593208
Merge pull request #3848 from fidencio/wip/release-dont-consider-rc-as-stable
tools: release: Do not consider release candidates as stable releases
2022-03-08 15:09:04 -08:00
Julio Montes
5ec7592dfa kernel: fix cve-2022-0847
bump guest kernel version to fix cve-2022-0847 "Dirty Pipe"

fixes #3852

Signed-off-by: Julio Montes <julio.montes@intel.com>
2022-03-08 09:49:15 -06:00
Eric Ernst
2b41d275a6 release: Revert kata-deploy changes after 2.4.0-rc0 release
As 2.4.0-rc0 has been released, let's switch the kata-deploy / kata-cleanup
tags back to "latest", and re-add the kata-deploy-stable and the
kata-cleanup-stable files.

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2022-03-07 14:14:56 -08:00
Eric Ernst
84dff44057 release: Adapt kata-deploy for 2.4.0-rc0
kata-deploy files must be adapted to a new release.  The cases where it
happens are when the release goes from -> to:
* main -> stable:
  * kata-deploy-stable / kata-cleanup-stable: are removed

* stable -> stable:
  * kata-deploy / kata-cleanup: bump the release to the new one.

There are no changes when doing an alpha release, as the files on the
"main" branch always point to the "latest" and "stable" tags.

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2022-03-07 11:15:25 -08:00
Fabiano Fidêncio
4adf93ef2c tools: release: Do not consider release candidates as stable releases
During the release of 2.4.0-rc0 @egernst noticed an incositency in the
way we handle release tags, as release candidates are being taken as
"stable" releases, while both the kata-deploy tests and the release
action consider this as "latest".

Ideally we should have our own tag for "release candidate", but that's
something that could and should be discussed more extensively outside of
the scope of this quick fix.

For now, let's align the code generating the PR for bumping the release
with what we already do as part of the release action and kata-deploy
test, and tag "-rc"  as latest, regardless of which branch it's coming
from.

Fixes: #3847

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-03-07 20:09:18 +01:00
Jakob Naucke
72f7e9e300
osbuilder: Multistrap Ubuntu
Use `multistrap` for building Ubuntu rootfs. Adds support for building
for foreign architectures using the `ARCH` environment variable.
In the process, the Ubuntu rootfs workflow is vastly simplified.

Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2022-03-07 11:58:46 +01:00
Jakob Naucke
0a313eda1c
osbuilder: Fix use of LIBC in rootfs.sh
- Add a doc comment
- Pass to build container, e.g. to build x86_64 with glibc (would
  always use musl)

Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2022-03-07 11:58:46 +01:00
Jakob Naucke
2c86b956fa
osbuilder: Simplify Rust installation
no double export, direct target

Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2022-03-07 11:58:46 +01:00
Jakob Naucke
0072cc2b66
osbuilder: Remove musl installations
Remove a lot of cruft of musl installations -- we needed those for the
Go agent, but Rustup just takes care of everything. aarch64 on
Debian-based & Alpine is an exception -- create a symlink
`aarch64-linux-musl-gcc` to `musl-tools`'s `musl-gcc` or `gcc` on
Alpine. This is unified -- arch-specific Dockerfiles are removed.

Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2022-03-07 11:58:46 +01:00
Jakob Naucke
5c3e553624
osbuilder: apk add --no-cache
Hadolint DL3019. If you're wondering why this is in this PR, that's
because I touch the file later, and we're only triggering the lints for
changed files.

Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2022-03-07 11:58:46 +01:00
Jianyong Wu
8828ef4176 kernel: add arm experimental kernel build support
Add a new entry of arm-kernel-experimental and let the kernel build
script support to build it.

Fixes: #3280
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2022-03-04 11:22:18 +08:00
Jianyong Wu
8a9007fe45 config: remove 2 config as they are removed in 5.15
I'm sure that it is correct to remove CONFIG_ARM64_UAO and
CONFIG_MANDATORY_FILE_LOCKING and . Both are gone in 5.15. Maintain a
specific config files for a kernel version is a little ugly. If someone
needs them, shout at me.

Fixes: #3280
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2022-03-04 11:22:18 +08:00
Jianyong Wu
1b6f7401e0 kernel: add arm experimental patches to support vcpu hotplug and virtio-mem
As the support for vcpu hotplug is on the road, I pick them up here as
experimental to let user try cpu hotplug and virtio-mem on arm64.

Fixes: #3280
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2022-03-04 11:22:18 +08:00
Fabiano Fidêncio
01c57da84b
Merge pull request #3552 from goodluckbot/update-hypervisor-version
Update QEMU >= 6.1.0 in configure-hypervisor.sh
2022-03-01 14:19:16 +01:00
Fabiano Fidêncio
6c2cc1fbd1
Merge pull request #3341 from Jakob-Naucke/centos-stream
osbuilder: Add CentOS Stream rootfs
2022-03-01 12:20:22 +01:00
goodluckbot
54d0a672c5 subsystem: build
With the ACPI PCI hotplug changes introduced in 2.3, QEMU >= 6.1 is required.
Remove unnecessary qemu version check in build script.

Fixes #3547

Signed-off-by: goodluckbot <tangbo_gl@hotmail.com>
2022-03-01 01:18:35 +08:00
Fabiano Fidêncio
827ab82a82 tools: clh: Fix unbound variable
4c164afbac renamed extra_build_args to
features, but did it only in one place, leading to:
```
21:15:28 /home/jenkins/workspace/kata-containers-2.0-ubuntu-ARM-PR/go/src/github.com/kata-containers/kata-containers/tools/packaging/static-build/cloud-hypervisor/build-static-clh.sh: line 55: features: unbound variable
21:15:29 make[1]: *** [tools/packaging/kata-deploy/local-build/Makefile:30: cloud-hypervisor-tarball-build] Error 1
```

Fixes: #3775

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-02-25 22:35:25 +01:00
Fabiano Fidêncio
4c164afbac versions: Update Cloud Hypervisor to 5343e09e7b8db
Let's bump the Cloud Hypervisor version to 5343e09e7b8db, as that brings
a few fixes we're interested in, such as:

* hypervisor, vmm: Handle TDX hypercalls with INVALID_OPERAND
  - https://github.com/cloud-hypervisor/cloud-hypervisor/pull/3723
    - This is needed for the TDX support on the cloud hypervisor driver,
      which is part of this very same series.

* openapi: Update the PciBdf types
  - https://github.com/cloud-hypervisor/cloud-hypervisor/pull/3748
    - This is needed due to a change in a DeviceNode field, which would
      cause a marshalling / demarshalling error when running with a
      version of cloud-hypervisor that includes the TDX fixes mentioned
      above.

* scripts: dev_cli: Don't quote $features_build
* scripts: dev_cli: Add --features option
  - https://github.com/cloud-hypervisor/cloud-hypervisor/pull/3773
    - This is needed due to changes in the scripts used to build Cloud
      Hypervisor, which are used as part of Kata Containers CIs and
      github actions.

      Due to this change, we're also adapting the build scripts as part
      of this very same commit.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-02-25 16:49:16 +01:00
GabyCT
7da7e0a8f5
Merge pull request #3724 from Jakob-Naucke/kata-deploy-s390x
kata-deploy: Simplify Dockerfile and support s390x
2022-02-23 11:38:01 -06:00
Fabiano Fidêncio
e604f83c40
Merge pull request #3735 from fidencio/wip/kata-deploy-use-kata-with-qemu-as-the-default-shim-v2-binary
kata-deploy: Use (kata with) qemu as the default shim-v2 binary
2022-02-21 14:52:55 +01:00
Jakob Naucke
9123fc098d
kata-deploy: Simplify Dockerfile and support s390x
The kata-deploy Dockerfile is based on CentOS 7, which has no s390x
support. Add an `IMAGE` argument to specify the registry, which still
defaults to CentOS, but e.g. ClefOS can be selected instead.

Other x86_64 assumptions are also removed. Other general simplicifations
are made.

This does not address the more general issue of #3723 -- what we're
doing here does not seem to be working with systemd >= something between
235-237.

Fixes: #3722
Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2022-02-21 11:06:54 +01:00
James O. D. Hunt
67c3195c9c
Merge pull request #3721 from Amulyam24/kernel-fix
kernel: remove SYS_SUPPORTS_HUGETLBFS from powerpc fragments
2022-02-21 09:10:21 +00:00
Fabiano Fidêncio
11220f052f kata-deploy: Use (kata with) qemu as the default shim-v2 binary
When using kata-deploy, no `containerd-shim-kata-v2` binary is deployed,
but we do deploy a `kata` runtime class, which seems very much
incosistent.

As the default configuration for kata-containers points to QEMU, let's
also use kata with QEMU as the default shim-v2 binary.

Fixes: #3228, #3734

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-02-21 10:03:47 +01:00
Amulyam24
8cc1b18636 kernel: remove SYS_SUPPORTS_HUGETLBFS from powerpc fragments
The name of SYS_SUPPORTS_HUGETLBFS has been changed to
ARCH_SUPPORTS_HUGETLBFS which is being selected on default
by another kernel config.
More info- 855f9a8e87
Change applicable from v5.13.

Fixes: #3720

Signed-off-by: Amulyam24 <amulmek1@in.ibm.com>
2022-02-18 18:06:50 +05:30