diff --git a/config/configuration.toml.in b/config/configuration.toml.in index a588a584..9ee13788 100644 --- a/config/configuration.toml.in +++ b/config/configuration.toml.in @@ -44,14 +44,20 @@ disable_block_device_use = @DEFDISABLEBLOCK@ #enable_swap = true # Debug changes the default hypervisor and kernel parameters to -# enable debug output where available. +# enable debug output where available. Also enable the debug +# console to be able to connect to the VM for guest debug. +# # Default false -# these logs can be obtained in the cc-proxy logs when the +# +# The logs can be obtained in the cc-proxy logs when the # proxy is set to run in debug mode # /usr/libexec/clear-containers/cc-proxy -log debug # or by stopping the cc-proxy service and running the cc-proxy # explicitly using the same command line -# +# +# The console can be accessed typically via +# /run/virtcontainers/pods//console.sock +# #enable_debug = true # Disable the customizations done in the runtime when it detects diff --git a/create.go b/create.go index e1596443..2d718b3c 100644 --- a/create.go +++ b/create.go @@ -152,7 +152,15 @@ func create(containerID, bundlePath, console, pidFilePath string, detach bool, return createPIDFile(pidFilePath, process.Pid) } -func getKernelParams(containerID string) []vc.Param { +func getKernelParams(containerID string, runtimeConfig oci.RuntimeConfig) []vc.Param { + var systemdTarget string + + if runtimeConfig.HypervisorConfig.Debug { + systemdTarget = "clear-containers-debug.target" + } else { + systemdTarget = "clear-containers.target" + } + return []vc.Param{ { Key: "init", @@ -160,7 +168,7 @@ func getKernelParams(containerID string) []vc.Param { }, { Key: "systemd.unit", - Value: "clear-containers.target", + Value: systemdTarget, }, { Key: "systemd.mask", @@ -179,7 +187,7 @@ func getKernelParams(containerID string) []vc.Param { func createPod(ociSpec oci.CompatOCISpec, runtimeConfig oci.RuntimeConfig, containerID, bundlePath, console string, disableOutput bool) (vc.Process, error) { - ccKernelParams := getKernelParamsFunc(containerID) + ccKernelParams := getKernelParamsFunc(containerID, runtimeConfig) for _, p := range ccKernelParams { if err := (&runtimeConfig).AddKernelParam(p); err != nil { diff --git a/create_test.go b/create_test.go index 0f708954..e3d8e3b3 100644 --- a/create_test.go +++ b/create_test.go @@ -838,7 +838,7 @@ func TestCreateInvalidKernelParams(t *testing.T) { getKernelParamsFunc = savedFunc }() - getKernelParamsFunc = func(containerID string) []vc.Param { + getKernelParamsFunc = func(containerID string, runtimeConfig oci.RuntimeConfig) []vc.Param { return []vc.Param{ { Key: "", diff --git a/docs/debug-kernel.md b/docs/debug-kernel.md index ab26b4f6..ec08d91a 100644 --- a/docs/debug-kernel.md +++ b/docs/debug-kernel.md @@ -44,3 +44,12 @@ to enable kernel boot logs using the configuration file. This will result in the `cc-proxy` log being printed on the terminal. This method can also be used to capture the logs in a specific `cc-proxy` file. + +5. Connect to the Virtual machine console + + If the kernel boots successfully then the virtual machine console can be accessed + for further debug. + + ``` + socat /run/virtcontainers/pods//console.sock + ```