Commit Graph

8929 Commits

Author SHA1 Message Date
Fabiano Fidêncio
7e5f11a52b vendor: Update containerd to 1.6.1
Let's bring in the latest release of Containerd, 1.6.1, released on
March 2nd, 2022.

With this, we take the opportunity to remove containerd/api reference as
we shouldn't need a separate module only for the API.

Here's the list of changes needed in the code due to the bump:
* stop using `grpc.WithInsecure()` as it's been deprecated
  - use `grpc.WithTransportCredentials(insecure.NewCredentials())`
    instead

Fixes: #3820

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
2022-03-04 10:28:40 +01:00
Fabiano Fidêncio
2af91b23e1
Merge pull request #3281 from jongwu/vcpu_hotplug_arm64
experimentally enable vcpu hotplug and virtio-mem on arm64 in kernel part
2022-03-04 09:14:31 +01:00
Fabiano Fidêncio
d4545ca099
Merge pull request #3826 from likebreath/0303/clh_v22.0
versions: Upgrade to Cloud Hypervisor v22.0
2022-03-04 09:08:59 +01:00
Jianyong Wu
42771fa726 runtime: don't set socket and thread for arm/virt
As this is just a initial vcpu hotplug support, thread and socket has
not been supported. So, don't set socket and thread when hotadd cpu for
arm/virt.

Fixes: #3280
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2022-03-04 11:22:18 +08: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
Feng Wang
f905161bbb runtime: mount direct-assigned block device fs only once
Mount the direct-assigned block device fs only once and keep a refcount
in the guest. Also use the ro flag inside the options field to determine
whether the block device and filesystem should be mounted as ro

Fixes: #3454

Signed-off-by: Feng Wang <feng.wang@databricks.com>
2022-03-03 18:57:02 -08:00
shuochen0311
27fb490228 agent: add get volume stats handler in agent
retrieve the stats of direct-assigned volumes from the guest

Fixes: #3454

Signed-off-by: shuochen0311 <shuo.chen@databricks.com>
2022-03-03 18:57:02 -08:00
Feng Wang
ea51ef1c40 runtime: forward the stat and resize requests from shimv2 to kata agent
Translate the volume path from host-known path to guest-known path
and forward the request to kata agent.

Fixes: #3454

Signed-off-by: Feng Wang <feng.wang@databricks.com>
2022-03-03 18:57:02 -08:00
Feng Wang
c39281ad65 runtime: update container creation to work with direct assigned volumes
During the container creation, it will parse the mount info file
of the direct assigned volumes and update the in memory mount object.

Fixes: #3454

Signed-off-by: Feng Wang <feng.wang@databricks.com>
2022-03-03 18:57:02 -08:00
Feng Wang
4e00c2377c agent: add grpc interface for stat and resize operations
Add GetVolumeStats and ResizeVolume APIs for the runtime to query stat
and resize fs in the guest.

Fixes: #3454

Signed-off-by: Feng Wang <feng.wang@databricks.com>
2022-03-03 18:57:02 -08:00
Feng Wang
e9b5a25502 runtime: add stat and resize APIs to containerd-shim-v2
To query fs stats and resize fs, the requests need to be passed to
kata agent through containerd-shim-v2. So we're adding to rest APIs
on the shim management endpoint.
Also refactor shim management client to its own go file.

Fixes: #3454

Signed-off-by: Feng Wang <feng.wang@databricks.com>
2022-03-03 18:56:53 -08:00
Feng Wang
6e0090abb5 runtime: persist direct volume mount info
In the direct assigned volume scenario, Kata Containers persists
the information required for managing the volume inside the guest
on host filesystem.

Fixes: #3454

Signed-off-by: Feng Wang <feng.wang@databricks.com>
2022-03-03 15:32:12 -08:00
Feng Wang
fa326b4e0f runtime: augment kata-runtime CLI to support direct-assigned volume
Add commands to add, remove, resize and get stats of a direct-assigned volume.
These commands are expected to be consumed by CSI.

Fixes: #3454

Signed-off-by: Feng Wang <feng.wang@databricks.com>
2022-03-03 15:32:03 -08:00
Bo Chen
b8844fb8a9 versions: Upgrade to Cloud Hypervisor v22.0
Highlights from the Cloud Hypervisor release v22.0: 1) GDB Debug Stub
Support; 2) `virtio-iommu` Backed Segments (to facilitate hotplug
devices that require being behind an IOMMU, e.g. QAT); 3) Before Boot
Configuration Changes; 4) `virtio-balloon` Free Page Reporting; 5)
Support for Direct Kernel Booting with TDX; 6) PMU Support for AArch64;
7) Documentation Under CC-BY-4.0 License; 8) Deprecation of "Classic"
virtiofsd (rust-based virtiofsd now is recommended); 9) Bug fixes on
`virtio-balloon`, `virtio-net` with multiple TAP fd support, REST APIs,
seccomp filters, migration with `vhost-user`, etc;

Details can be found: https://github.com/cloud-hypervisor/cloud-hypervisor/releases/tag/v22.0

Fixes: #3825

Signed-off-by: Bo Chen <chen.bo@intel.com>
2022-03-03 15:15:54 -08:00
Fabiano Fidêncio
a2422cf2a1
Merge pull request #3389 from zhsj/rm-distro-test
katatestutils: remove distro constraints
2022-03-03 23:26:58 +01:00
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