diff --git a/docs/how-to/how-to-use-virtio-mem-with-kata.md b/docs/how-to/how-to-use-virtio-mem-with-kata.md index ce989a41e0..22116e956e 100644 --- a/docs/how-to/how-to-use-virtio-mem-with-kata.md +++ b/docs/how-to/how-to-use-virtio-mem-with-kata.md @@ -13,26 +13,23 @@ Kata Containers with `virtio-mem` supports memory resize. ## Requisites -Kata Containers with `virtio-mem` requires Linux and the QEMU that support `virtio-mem`. -The Linux kernel and QEMU upstream version still not support `virtio-mem`. @davidhildenbrand is working on them. -Please use following unofficial version of the Linux kernel and QEMU that support `virtio-mem` with Kata Containers. +Kata Containers just supports `virtio-mem` with QEMU. +Install and setup Kata Containers as shown [here](../install/README.md). -The Linux kernel is at https://github.com/davidhildenbrand/linux/tree/virtio-mem-rfc-v4. -The Linux kernel config that can work with Kata Containers is at https://gist.github.com/teawater/016194ee84748c768745a163d08b0fb9. - -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.) - -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" +### With x86_64 +The `virtio-mem` config of the x86_64 Kata Linux kernel is open. +Enable `virtio-mem` as follows: +``` +$ sudo sed -i -e 's/^#enable_virtio_mem.*$/enable_virtio_mem = true/g' /etc/kata-containers/configuration.toml ``` -Enable `virtio-mem` with following line in the Kata Containers configuration: -```toml -enable_virtio_mem = true +### With other architectures +The `virtio-mem` config of the others Kata Linux kernel is not open. +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` @@ -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 ``` -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 +```