Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 219ded8

Browse files
committedSep 30, 2020
docs: Update docs for enabling agent debug console
The systemd method of adding a debug console is not really user friendly. Since we have added a much more straightforward method to enable agent debug console, update developer guide to reflect this. Fixes #703 Signed-off-by: Archana Shinde <[email protected]>
1 parent 9dc866e commit 219ded8

File tree

1 file changed

+62
-30
lines changed

1 file changed

+62
-30
lines changed
 

‎Developer-Guide.md

+62-30
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@
4040
* [Checking Docker default runtime](#checking-docker-default-runtime)
4141
* [Set up a debug console](#set-up-a-debug-console)
4242
* [Create a custom image containing a shell](#create-a-custom-image-containing-a-shell)
43-
* [Create a debug systemd service](#create-a-debug-systemd-service)
4443
* [Build the debug image](#build-the-debug-image)
4544
* [Configure runtime for custom debug image](#configure-runtime-for-custom-debug-image)
4645
* [Ensure debug options are valid](#ensure-debug-options-are-valid)
46+
* [Enable debug console for the agent](#enable-debug-console-for-the-agent)
47+
* [Enabling debug console for QEMU](#enabling-debug-console-for-qemu)
48+
* [Enabling debug console for cloud-hypervisor / firecracker](#enabling-debug-console-for-cloud-hypervisor--firecracker)
4749
* [Create a container](#create-a-container)
4850
* [Connect to the virtual machine using the debug console](#connect-to-the-virtual-machine-using-the-debug-console)
4951
* [Obtain details of the image](#obtain-details-of-the-image)
@@ -524,35 +526,6 @@ $ export ROOTFS_DIR=${GOPATH}/src/github.com/kata-containers/osbuilder/rootfs-bu
524526
$ script -fec 'sudo -E GOPATH=$GOPATH USE_DOCKER=true EXTRA_PKGS="bash coreutils" ./rootfs.sh centos'
525527
```
526528

527-
### Create a debug systemd service
528-
529-
Create the service file that starts the shell in the rootfs directory:
530-
531-
```
532-
$ cat <<EOT | sudo tee ${ROOTFS_DIR}/lib/systemd/system/kata-debug.service
533-
[Unit]
534-
Description=Kata Containers debug console
535-
536-
[Service]
537-
Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
538-
StandardInput=tty
539-
StandardOutput=tty
540-
# Must be disabled to allow the job to access the real console
541-
PrivateDevices=no
542-
Type=simple
543-
ExecStart=/bin/bash
544-
Restart=always
545-
EOT
546-
```
547-
548-
**Note**: You might need to adjust the `ExecStart=` path.
549-
550-
Add a dependency to start the debug console:
551-
552-
```
553-
$ sudo sed -i '$a Requires=kata-debug.service' ${ROOTFS_DIR}/lib/systemd/system/kata-containers.target
554-
```
555-
556529
### Build the debug image
557530

558531
Follow the instructions in the [Build a rootfs image](#build-a-rootfs-image)
@@ -596,6 +569,59 @@ $ sudo awk '{if (/^\[proxy\.kata\]/) {got=1}; if (got == 1 && /^.*enable_debug/)
596569
$ sudo install -o root -g root -m 0640 /tmp/configuration.toml /etc/kata-containers/
597570
```
598571

572+
### Enable debug console for the agent
573+
574+
The steps required to enable debug console for QEMU slightly differ with
575+
those for firecracker / cloud-hypervisor.
576+
577+
#### Enabling debug console for QEMU
578+
579+
Add `agent.debug_console` to the guest kernel command line to allow the agent process to start a debug console.
580+
581+
```
582+
$ sudo sed -i -e 's/^kernel_params = "\(.*\)"/kernel_params = "\1 agent.debug_console"/g' "${kata_configuration_file}"
583+
```
584+
585+
Here `kata_configuration_file` could point to `/etc/kata-containers/configuration.toml`
586+
or `/usr/share/defaults/kata-containers/configuration.toml`
587+
or `/opt/kata/share/defaults/kata-containers/configuration-{hypervisor}.toml`, if
588+
you installed Kata Containers using `kata-deploy`.
589+
590+
#### Enabling debug console for cloud-hypervisor / firecracker
591+
592+
Slightly different configuration is required in case of firecracker and cloud hypervisor.
593+
Firecracker and cloud-hypervisor don't have a UNIX socket connected to `/dev/console`.
594+
Hence, the kernel command line option `agent.debug_console` will not work for them.
595+
These hypervisors support `hybrid vsocks`, which can be used for communication
596+
between the host and the guest. The kernel command line option `agent.debug_console_vport`
597+
was added to allow developers specify on which `vsock` port the debugging console should be connected.
598+
599+
600+
Add the parameter `agent.debug_console_vport=1026` to the kernel command line
601+
as shown below:
602+
```
603+
sudo sed -i -e 's/^kernel_params = "\(.*\)"/kernel_params = "\1 agent.debug_console_vport=1026"/g' "${kata_configuration_file}"
604+
```
605+
606+
> **Note** Ports 1024 and 1025 are reserved for communication with the agent
607+
> and gathering of agent logs respectively.
608+
609+
Next, connect to the debug console. The VSOCKS paths vary slightly between
610+
cloud-hypervisor and firecracker.
611+
In case of cloud-hypervisor, connect to the `vsock` as shown:
612+
```
613+
$ sudo su -c 'cd /var/run/vc/vm/{sandbox_id}/root/ && socat stdin unix-connect:clh.sock'
614+
CONNECT 1026
615+
```
616+
617+
**Note**: You need to type `CONNECT 1026` and press `RETURN` key after entering the `socat` command.
618+
619+
For firecracker, connect to the `hvsock` as shown:
620+
```
621+
$ sudo su -c 'cd /var/run/vc/firecracker/{sandbox_id}/root/ && socat stdin unix-connect:kata.hvsock'
622+
CONNECT 1026
623+
```
624+
599625
### Create a container
600626

601627
Create a container as normal. For example using Docker:
@@ -612,6 +638,12 @@ $ console="/var/run/vc/vm/${id}/console.sock"
612638
$ sudo socat "stdin,raw,echo=0,escape=0x11" "unix-connect:${console}"
613639
```
614640

641+
In case of firecracker, you would need the following command:
642+
```
643+
sudo su -c 'cd /var/lib/vc/firecracker/08facf/root/ && socat stdin unix-connect:kata.hvsock'
644+
CONNECT 1026
645+
```
646+
615647
**Note**: You need to press the `RETURN` key to see the shell prompt.
616648

617649
To disconnect from the virtual machine, type `CONTROL+q` (hold down the

0 commit comments

Comments
 (0)
This repository has been archived.