Commit Graph

8512 Commits

Author SHA1 Message Date
Fabiano Fidêncio
12af632952
Merge pull request #3814 from fidencio/wip/disable-block-device-use-minor-fixes
Minor fixes for the `disable_block_device_use` comments
2022-03-03 23:26:05 +01:00
Julio Montes
6628977fcd
Merge pull request #3823 from fidencio/wip/clh-stop-virtiofsd-if-clh-fails-to-boot-up-the-vm
clh: stop virtofsd if clh fails to boot up the vm
2022-03-03 14:53:52 -06:00
Fabiano Fidêncio
af80473496 clh: stop virtofsd if clh fails to boot up the vm
If, for some reason, we're able to launch cloud hypervisor but not able
to boot the VM up, the virtiofsd process would be left behind.

Let's ensure, via defer, that we stop virtiofsd in case of errors.

Fixes: #3819

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-03-03 19:10:37 +01:00
Fabiano Fidêncio
c54bc8e657
Merge pull request #3811 from fidencio/wip/clh-tdx-round-2
clh: tdx: Don't use sharedFS with Confidential Guests
2022-03-03 19:03:28 +01:00
Chelsea Mafrica
343138623c
Merge pull request #3818 from jodh-intel/golang-build-more-securely
runtime: Build golang components with extra security options
2022-03-03 09:50:51 -08:00
James O. D. Hunt
799c2f4f2a
Merge pull request #3800 from jodh-intel/git-clone-depth-1-where-possible
snap: Use git clone depth 1 for QEMU and dependencies
2022-03-03 16:27:07 +00:00
Fabiano Fidêncio
97951a2d12 clh: Don't use SharedFS with Confidential Guests
kata-containers/pulls#3771 added TDX support for Cloud Hypervisor, but
two big things got overlooked while doing that.

1. virtio-fs, as of now, cannot be part of the trust boundary, so the
   Confidential Guest will not be using it.

2. virtio-block hotplug should be enabled in order to use virtio-block
   for the rootfs (used with the devmapper plugin).

When trying to use cloud-hypervisor with TDX using virtio-fs, we're
facing the following error on the guest kernel:
```
virtiofs virtio2: device must provide VIRTIO_F_ACCESS_PLATFORM
```

After checking and double-checking with virtiofs and cloud-hypervisor
developers, it happens as confidential containers might put some
limitations on the device, so it can't access all of the guests' memory
and that's where this restriction seems to be coming from. Vivek
mentioned that virtiofsd do not support VIRTIO_F_ACCESS_PLATFORM (aka
VIRTIO_F_IOMMU_PLATFORM) yet, and that for ecrypted guests virtiofs may
not be the best solution at the moment.

@sboeuf put this in a very nice way: "if the virtio-fs driver doesn't
support VIRTIO_F_ACCESS_PLATFORM, then the pages corresponding to the
virtqueues and the buffers won't be marked as SHARED, meaning the VMM
won't have access to it".

Interestingly enough, it works with QEMU, and it may be due to some
change done on the patched QEMU that @devimc is packaging, but we won't
take the path to figure out what was the change and patch
cloud-hypervisor on the same way, because of 1.

Fixes: #3810

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-03-03 12:49:40 +01:00
Fabiano Fidêncio
c30b3a9ff1 clh: Adding a volume is not supported without SharedFS
As mounting volumes into the guest requires SharedFS setup, let's ensure
we error out if trying to do so in a situation where SharedFS is not
supported.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-03-03 12:49:30 +01:00
Fabiano Fidêncio
f889f1f957 clh: introduce supportsSharedFS()
supportsSharedFS() is a new method to be used to ensure that no SharedFS
specifics are called when, for a reason or another, Cloud Hypervisor is
in a mode where SharedFSs are not supported.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-03-03 12:49:28 +01:00
Fabiano Fidêncio
54d27ed721 clh: introduce loadVirtiofsDaemon()
Similarly to the `createVirtiofsDaemon` and `stopVirtiofsDaemon` methos,
let's introduce and use loadVirtiofsDaemon, at it'll also be handy later
in this series.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-03-03 12:48:38 +01:00
Fabiano Fidêncio
ae2221ea68 clh: introduce stopVirtiofsDaemon()
Similary to the `createVirtiofsDaemon` method, let's introduce and use
its counterpart, as it'll also be handy later in this series.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-03-03 12:48:26 +01:00
Fabiano Fidêncio
e8bc26f90d clh: introduce setupVirtiofsDaemon()
Similarly to what's been done with the `createVirtiofsDaemon`, let's
create a `setupVirtiofsDaemon` one.

It will also become handy later in this series.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-03-03 12:48:14 +01:00
Fabiano Fidêncio
413b3b477a clh: introduce createVirtiofsDaemon()
Let's introduce and use a new `createVirtiofsDaemon` method.  Its name
says it all, and it'll be handy later in this series when, spoiler
alert, SharedFS cannot be used (in such cases as in Confidential
Guests).

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-03-03 12:48:02 +01:00
James O. D. Hunt
55cd0c89d8 runtime: Build golang components with extra security options
Enable stack protector and fortify source for golang builds.

Fixes: #3817.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-03-03 10:41:26 +00:00
Fabiano Fidêncio
76e4f6a2a3 Revert "hypervisors: Confidential Guests do not support Device hotplug"
This reverts commit df8ffecde0, as device
hotplug *is* supported and, more than that, is very much needed when
using virtio-blk instead of virtio-fs.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-03-03 09:59:55 +01:00
David Gibson
42e35505b0 agent: Verify that we allocated as many hugepages as we need
allocate_hugepages() writes to the kernel sysfs file to allocate hugepages
in the Kata VM.  However, even if the write succeeds, it's not certain that
the kernel will actually be able to allocate as many hugepages as we
requested.

This patch reads back the file after writing it to check if we were able to
allocate all the required hugepages.

fixes #3816

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2022-03-03 15:59:45 +11:00
David Gibson
608e003abc agent: Don't attempt to create directories for hugepage configuration
allocate_hugepages() constructs the path for the sysfs directory containing
hugepage configuration, then attempts to create this directory if it does
not exist.

This doesn't make sense: sysfs is a view into kernel configuration, if the
kernel has support for the hugepage size, the directory will already be
there, if it doesn't, trying to create it won't help.

For the same reason, attempting to create the "nr_hugepages" file
itself is pointless, so there's no reason to call
OpenOptions::create(true).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2022-03-03 11:24:11 +11:00
Julio Montes
934788eb53
Merge pull request #3812 from fidencio/wip/disable-clh-build-on-ppc64le
snap: Don't build cloud-hypevisor on ppc64le
2022-03-02 15:40:01 -06:00
Fabiano Fidêncio
fa8b93927c config: qemu: Fix disable_block_device_use comments
virtio-fs, instead of virtio-9p, is the default shared file system type
in case virtio-blk is not used.

Fixes: #3813

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-03-02 20:43:36 +01:00
Fabiano Fidêncio
9615c8bc9c config: fc: Don't expose disable_block_device_use
Relying on virtio-block is the *only* way to use Firecracker with Kata
Containers, as shared FS (virtio-{fs,fs-nydus,9p}) is not supported by
Firecracker.

As configuration doesn't make sense to be exposed, we hardcode the
`false` value in the Firecracker configuration structure.

Fixes: #3813

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-03-02 20:43:28 +01:00
Fabiano Fidêncio
c1fb4bb726 snap: Don't build cloud-hypevisor on ppc64le
snapcraft build is failing due to:
 ``
utils.mk:130: "WARNING: powerpc64le-unknown-linux-musl target is unavailable"
```

It seems to happen as powerpc64-unknown-linux-musl is a target that
although there's support for it, it's not exactly built or
automatically tested, at least according to:
https://doc.rust-lang.org/rustc/platform-support.html

Fixes: #3803

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-03-02 19:04:30 +01:00
James O. D. Hunt
58913694d3 snap: Use git clone depth 1 for QEMU and dependencies
Use `git clone --depth 1 ...` for QEMU and its dependencies
to speed up checkouts.

Fixes: #3799.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-03-02 08:31:06 +00:00
Bin Liu
2ae8bd696a
Merge pull request #3367 from wfly1998/main
build: always reset ARCH after getting it
2022-03-02 14:42:45 +08:00
Bin Liu
75877f8793
Merge pull request #3187 from Kvasscn/kata_dev_remove_temp_vsock_dir
virtcontainers: remove temp dir created for vsock in test code
2022-03-02 11:05:47 +08:00
Chelsea Mafrica
c49e261819
Merge pull request #3782 from jodh-intel/docs-add-ut-presentation
docs: Add unit testing presentation
2022-03-01 11:03:54 -08:00
James O. D. Hunt
b27c7f4068 docs: Add unit testing presentation
Add the Kata Containers unit testing presentation I gave to the Kata
outreach students as this may be of some use to others.

Fixes: #3781

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-03-01 15:52:03 +00:00
Francesco Giudici
7f638dd049
Merge pull request #3764 from Jakob-Naucke/hugepages-test-s390x
virtcontainers: Use available s390x hugepages
2022-03-01 14:33:59 +01: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
4ab35b0899
Merge pull request #3796 from jodh-intel/fix-monitor-listen-address
Fix monitor listen address
2022-03-01 13:51:01 +01:00
Fabiano Fidêncio
8d4412d89f
Merge pull request #3728 from fidencio/wip/snapcraft-update-clh-installation
snap: clh: Re-use kata-deploy script here
2022-03-01 13:07:13 +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
Fabiano Fidêncio
97c17085b0
Merge pull request #3770 from Jakob-Naucke/gofmt-vmm-s390x
runtime: Gofmt fixes
2022-03-01 11:34:15 +01:00
James O. D. Hunt
e64c54a2ad monitor: Listen to localhost only by default
Change `kata-monitor` to listen to port `8090` on the local interface
only by default.

> **Note:**
>
> This is a breaking change as previously it listened on all interfaces.

Fixes: #3795.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-03-01 10:00:43 +00:00
James O. D. Hunt
e6350d3d45 monitor: Fix build options
Removed redundant and duplicated build options to build
`kata-monitor` the same way as the other components:

- `CGO_ENABLED=0` is not necessary.
- `-buildmode=exe` is not necessary since `BUILDFLAGS` already sets the
  build mode.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2022-03-01 10:00:43 +00:00
Fabiano Fidêncio
a67b93bb03 snap: clh: Re-use kata-deploy script here
The current snap build for clh is broken as it's not aware of how to
build the binary from sources.

Instead of fixing it here, let's take advantage of the kata-deploy
script, which is capable of building from sources, and re-use it here.

Fixes: #3693

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-03-01 09:03:51 +01:00
Fabiano Fidêncio
f31125fe92 version: Bump cloud-hypervisor to b0324f85571c441f
This bump brings a fix on the build script, for ARM, so we can use the
very same build script everywhere.

The commit of our interest is b0324f85571c441f840e9bdeb25410514a00bb74:
```
scripts: Fix musl build on aarch64

Adding the missing TARGET_CC environment variable to get the build to
complete correctly.

Fixes #3776

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-03-01 09:03:51 +01:00
GabyCT
ccb063b848
Merge pull request #3788 from fidencio/wip/update-clh-confidential-guest-comments
Update `confidential_guest` comments
2022-02-28 15:11:01 -06:00
GabyCT
bc1733bb0e
Merge pull request #3774 from egernst/delinux-runtime
cleanup runtime pkgs for Darwin build, add basic Darwin build/unit test
2022-02-28 15:08:09 -06:00
GabyCT
506ad6f6e7
Merge pull request #3792 from GabyCT/topic/updateread
docs: Update Readme document
2022-02-28 14:16:43 -06: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
21a8ba93c5
Merge pull request #3784 from liubin/fix/3783-use-exec-pipe
runtime: use Cmd.StdoutPipe instead of self-created pipe
2022-02-28 18:04:58 +01:00
Gabriela Cervantes
edf20766d1 docs: Update Readme document
This PR updates the README document by using the proper link for
the contributing guide as well as a misspelling.

Fixes #3791

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
2022-02-28 16:52:26 +00:00
Jakob Naucke
eda8ea154a
runtime: Gofmt fixes
- Mostly blank lines after `+build` -- see
  https://pkg.go.dev/go/build@go1.14.15 -- this is, to date, enforced by
  `gofmt`.
- 1.17-style go:build directives are also added.
- Spaces in govmm/vmm_s390x.go

Fixes: #3769
Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2022-02-28 17:24:47 +01:00
Eric Ernst
4afb278fe2 ci: add github action to exercise darwin build, unit tests
There are a few outstanding changes required to build the runtime on
Darwin.

Let's add a GitHub action to exercise build and unit tests of the
packages which we do expect to work. Eventually this should be dropped
and we can run any Darwin specific tests, or just add MacOS to the
matrix for our static check OSes.

Fixes: #3778

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2022-02-28 08:01:53 -08:00
Eric Ernst
e355a71860 container: file is not linux specific
This should not be linux specific -- drop restriction.

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2022-02-28 08:01:53 -08:00
Eric Ernst
b31876eefb device-manager: move linux-only test to a linux-only file
We can't Mkdev on Darwin - let's make sure the vfio test is in a
linux-only file.

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2022-02-28 08:01:53 -08:00
Eric Ernst
6a5c634490 resourcecontrol: SystemdCgroup check is not necessarily linux specific
This utility function is also used to check the spec that will run in
the guest - no need for this to be linux specific.

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2022-02-28 08:01:53 -08:00
Eric Ernst
cc58cf6993 resourcecontrol: convert stats dev_t to unit64types
Their types may differ on various host OSes, but
unix.Major|Minor always takes a uint64

Depends-on: github.com/kata-containers/tests#4516
Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2022-02-28 08:01:53 -08:00
Eric Ernst
5be188cc29 utils: Add darwin stub
Add a stub for utils_darwin to facilitate building this package on
Darwin. We can probably drop this empty stub if we have better
abstraction for the various parts of virtcontainers that call it
today...

Fixes:# 3777

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2022-02-28 08:01:53 -08:00
Samuel Ortiz
ad0449195d virtcontainers: Convert stats dev_t to uint64
We need to convert them to uint64 as their types may differ on various
host OSes, but unix.Major|Minor takes a uint64 regardless.

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
2022-02-28 08:01:53 -08:00