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

WIP: Debug: Enable VM debug console #658

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions config/configuration.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -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/<podid>/console.sock
#
#enable_debug = true

# Disable the customizations done in the runtime when it detects
Expand Down
14 changes: 11 additions & 3 deletions create.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,23 @@ 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",
Value: "/usr/lib/systemd/systemd",
},
{
Key: "systemd.unit",
Value: "clear-containers.target",
Value: systemdTarget,
},
{
Key: "systemd.mask",
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
Expand Down
9 changes: 9 additions & 0 deletions docs/debug-kernel.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use all lower case:
s/Virtual/virtual


If the kernel boots successfully then the virtual machine console can be accessed
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid using an "if" clause unless we provide options for when the kernel does not boot successfully.
Let us ensure that our instructions are accurate and assume the reader has followed the instructions exactly:
After the kernel boots, the virtual machine console can be accessed for further debugging.

for further debug.

```
socat /run/virtcontainers/pods/<pod id>/console.sock
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a $ prompt for consistency with the rest of the doc please. Also, presumably we need a sudo in there too?

@iphutch - please can you review these doc changes?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

```