Skip to content
This repository was archived by the owner on May 6, 2020. It is now read-only.

Commit 44af25c

Browse files
committed
Debug: Enable VM debug console
Enable the VM debug console whenever the VM Kernel debug is enabled. Fixes: #559. Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
1 parent 0ac913f commit 44af25c

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

config/configuration.toml.in

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,20 @@ disable_block_device_use = @DEFDISABLEBLOCK@
3636
#enable_swap = true
3737

3838
# Debug changes the default hypervisor and kernel parameters to
39-
# enable debug output where available.
39+
# enable debug output where available. Also enable the debug
40+
# console to be able to connect to the VM for guest debug.
41+
#
4042
# Default false
41-
# these logs can be obtained in the cc-proxy logs when the
43+
#
44+
# The logs can be obtained in the cc-proxy logs when the
4245
# proxy is set to run in debug mode
4346
# /usr/libexec/clear-containers/cc-proxy -log debug
4447
# or by stopping the cc-proxy service and running the cc-proxy
4548
# explicitly using the same command line
46-
#
49+
#
50+
# The console can be accessed typically via
51+
# /run/virtcontainers/pods/<podid>/console.sock
52+
#
4753
#enable_debug = true
4854

4955
[proxy.cc]

create.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,23 @@ func create(containerID, bundlePath, console, pidFilePath string, detach bool,
144144
return createPIDFile(pidFilePath, process.Pid)
145145
}
146146

147-
func getKernelParams(containerID string) []vc.Param {
147+
func getKernelParams(containerID string, runtimeConfig oci.RuntimeConfig) []vc.Param {
148+
var systemdTarget string
149+
150+
if runtimeConfig.HypervisorConfig.Debug {
151+
systemdTarget = "clear-containers-debug.target"
152+
} else {
153+
systemdTarget = "clear-containers.target"
154+
}
155+
148156
return []vc.Param{
149157
{
150158
Key: "init",
151159
Value: "/usr/lib/systemd/systemd",
152160
},
153161
{
154162
Key: "systemd.unit",
155-
Value: "clear-containers.target",
163+
Value: systemdTarget,
156164
},
157165
{
158166
Key: "systemd.mask",
@@ -171,7 +179,7 @@ func getKernelParams(containerID string) []vc.Param {
171179

172180
func createPod(ociSpec oci.CompatOCISpec, runtimeConfig oci.RuntimeConfig,
173181
containerID, bundlePath, console string, disableOutput bool) (vc.Process, error) {
174-
ccKernelParams := getKernelParamsFunc(containerID)
182+
ccKernelParams := getKernelParamsFunc(containerID, runtimeConfig)
175183

176184
for _, p := range ccKernelParams {
177185
if err := (&runtimeConfig).AddKernelParam(p); err != nil {

docs/debug-kernel.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,12 @@ to enable kernel boot logs using the configuration file.
4444

4545
This will result in the `cc-proxy` log being printed on the terminal. This method
4646
can also be used to capture the logs in a specific `cc-proxy` file.
47+
48+
5. Connect to the Virtual machine console
49+
50+
If the kernel boots successfully then the virtual machine console can be accessed
51+
for further debug.
52+
53+
```
54+
socat /run/virtcontainers/pods/<pod id>/console.sock
55+
```

0 commit comments

Comments
 (0)