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

Commit b59bfde

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 e4b9b56 commit b59bfde

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

config/configuration.toml.in

+9-3
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,20 @@ disable_block_device_use = @DEFDISABLEBLOCK@
4444
#enable_swap = true
4545

4646
# Debug changes the default hypervisor and kernel parameters to
47-
# enable debug output where available.
47+
# enable debug output where available. Also enable the debug
48+
# console to be able to connect to the VM for guest debug.
49+
#
4850
# Default false
49-
# these logs can be obtained in the cc-proxy logs when the
51+
#
52+
# The logs can be obtained in the cc-proxy logs when the
5053
# proxy is set to run in debug mode
5154
# /usr/libexec/clear-containers/cc-proxy -log debug
5255
# or by stopping the cc-proxy service and running the cc-proxy
5356
# explicitly using the same command line
54-
#
57+
#
58+
# The console can be accessed typically via
59+
# /run/virtcontainers/pods/<podid>/console.sock
60+
#
5561
#enable_debug = true
5662

5763
# Disable the customizations done in the runtime when it detects

create.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,23 @@ func create(containerID, bundlePath, console, pidFilePath string, detach bool,
152152
return createPIDFile(pidFilePath, process.Pid)
153153
}
154154

155-
func getKernelParams(containerID string) []vc.Param {
155+
func getKernelParams(containerID string, runtimeConfig oci.RuntimeConfig) []vc.Param {
156+
var systemdTarget string
157+
158+
if runtimeConfig.HypervisorConfig.Debug {
159+
systemdTarget = "clear-containers-debug.target"
160+
} else {
161+
systemdTarget = "clear-containers.target"
162+
}
163+
156164
return []vc.Param{
157165
{
158166
Key: "init",
159167
Value: "/usr/lib/systemd/systemd",
160168
},
161169
{
162170
Key: "systemd.unit",
163-
Value: "clear-containers.target",
171+
Value: systemdTarget,
164172
},
165173
{
166174
Key: "systemd.mask",
@@ -179,7 +187,7 @@ func getKernelParams(containerID string) []vc.Param {
179187

180188
func createPod(ociSpec oci.CompatOCISpec, runtimeConfig oci.RuntimeConfig,
181189
containerID, bundlePath, console string, disableOutput bool) (vc.Process, error) {
182-
ccKernelParams := getKernelParamsFunc(containerID)
190+
ccKernelParams := getKernelParamsFunc(containerID, runtimeConfig)
183191

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

create_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ func TestCreateInvalidKernelParams(t *testing.T) {
838838
getKernelParamsFunc = savedFunc
839839
}()
840840

841-
getKernelParamsFunc = func(containerID string) []vc.Param {
841+
getKernelParamsFunc = func(containerID string, runtimeConfig oci.RuntimeConfig) []vc.Param {
842842
return []vc.Param{
843843
{
844844
Key: "",

docs/debug-kernel.md

+9
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)