40
40
* [ Checking Docker default runtime] ( #checking-docker-default-runtime )
41
41
* [ Set up a debug console] ( #set-up-a-debug-console )
42
42
* [ 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 )
44
43
* [ Build the debug image] ( #build-the-debug-image )
45
44
* [ Configure runtime for custom debug image] ( #configure-runtime-for-custom-debug-image )
46
45
* [ 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 )
47
49
* [ Create a container] ( #create-a-container )
48
50
* [ Connect to the virtual machine using the debug console] ( #connect-to-the-virtual-machine-using-the-debug-console )
49
51
* [ 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
524
526
$ script -fec 'sudo -E GOPATH=$GOPATH USE_DOCKER=true EXTRA_PKGS="bash coreutils" ./rootfs.sh centos'
525
527
```
526
528
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
-
556
529
### Build the debug image
557
530
558
531
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/)
596
569
$ sudo install -o root -g root -m 0640 /tmp/configuration.toml /etc/kata-containers/
597
570
```
598
571
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
+
599
625
### Create a container
600
626
601
627
Create a container as normal. For example using Docker:
@@ -612,6 +638,12 @@ $ console="/var/run/vc/vm/${id}/console.sock"
612
638
$ sudo socat "stdin,raw,echo=0,escape=0x11" "unix-connect:${console}"
613
639
```
614
640
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
+
615
647
** Note** : You need to press the ` RETURN ` key to see the shell prompt.
616
648
617
649
To disconnect from the virtual machine, type ` CONTROL+q ` (hold down the
0 commit comments