how-to-use-virtio-mem-with-kata.md: Update doc to make it clear

Update this howto because the virtio-mem support of kata, qemu and Linux
was updated.

Fixes: #1845

Signed-off-by: Hui Zhu <teawater@antfin.com>
This commit is contained in:
Hui Zhu 2021-05-13 17:23:54 +08:00
parent bdc9a66bd9
commit 785be0bbde

View File

@ -13,26 +13,23 @@ Kata Containers with `virtio-mem` supports memory resize.
## Requisites ## Requisites
Kata Containers with `virtio-mem` requires Linux and the QEMU that support `virtio-mem`. Kata Containers just supports `virtio-mem` with QEMU.
The Linux kernel and QEMU upstream version still not support `virtio-mem`. @davidhildenbrand is working on them. Install and setup Kata Containers as shown [here](../install/README.md).
Please use following unofficial version of the Linux kernel and QEMU that support `virtio-mem` with Kata Containers.
The Linux kernel is at https://github.com/davidhildenbrand/linux/tree/virtio-mem-rfc-v4. ### With x86_64
The Linux kernel config that can work with Kata Containers is at https://gist.github.com/teawater/016194ee84748c768745a163d08b0fb9. The `virtio-mem` config of the x86_64 Kata Linux kernel is open.
Enable `virtio-mem` as follows:
The QEMU is at https://github.com/teawater/qemu/tree/kata-virtio-mem. (The original source is at https://github.com/davidhildenbrand/qemu/tree/virtio-mem. Its base version of QEMU cannot work with Kata Containers. So merge the commit of `virtio-mem` to upstream QEMU.) ```
$ sudo sed -i -e 's/^#enable_virtio_mem.*$/enable_virtio_mem = true/g' /etc/kata-containers/configuration.toml
Set Linux and the QEMU that support `virtio-mem` with following line in the Kata Containers QEMU configuration `configuration-qemu.toml`:
```toml
[hypervisor.qemu]
path = "qemu-dir"
kernel = "vmlinux-dir"
``` ```
Enable `virtio-mem` with following line in the Kata Containers configuration: ### With other architectures
```toml The `virtio-mem` config of the others Kata Linux kernel is not open.
enable_virtio_mem = true You can open `virtio-mem` config as follows:
``` ```
CONFIG_VIRTIO_MEM=y
```
Then you can build and install the guest kernel image as shown [here](../../tools/packaging/kernel/README.md#build-kata-containers-kernel).
## Run a Kata Container utilizing `virtio-mem` ## Run a Kata Container utilizing `virtio-mem`
@ -41,13 +38,35 @@ Use following command to enable memory overcommitment of a Linux kernel. Becaus
$ echo 1 | sudo tee /proc/sys/vm/overcommit_memory $ echo 1 | sudo tee /proc/sys/vm/overcommit_memory
``` ```
Use following command start a Kata Container. Use following command to start a Kata Container.
``` ```
$ docker run --rm -it --runtime=kata --name test busybox $ pod_yaml=pod.yaml
$ container_yaml=${REPORT_DIR}/container.yaml
$ image="quay.io/prometheus/busybox:latest"
$ cat << EOF > "${pod_yaml}"
metadata:
name: busybox-sandbox1
EOF
$ cat << EOF > "${container_yaml}"
metadata:
name: busybox-killed-vmm
image:
image: "$image"
command:
- top
EOF
$ sudo crictl pull $image
$ podid=$(sudo crictl runp $pod_yaml)
$ cid=$(sudo crictl create $podid $container_yaml $pod_yaml)
$ sudo crictl start $cid
``` ```
Use following command set the memory size of test to default_memory + 512m. Use the following command to set the container memory limit to 2g and the memory size of the VM to its default_memory + 2g.
``` ```
$ docker update -m 512m --memory-swap -1 test $ sudo crictl update --memory $((2*1024*1024*1024)) $cid
``` ```
Use the following command to set the container memory limit to 1g and the memory size of the VM to its default_memory + 1g.
```
$ sudo crictl update --memory $((1*1024*1024*1024)) $cid
```