Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
virtcontainers: set agent's logs vsock port
Browse files Browse the repository at this point in the history
In firecracker, there is no socket connected to /dev/console, so let's
use a vsock port to get agent's logs

Depends-on: github.com/kata-containers/shim#210

fixes #2103

Signed-off-by: Julio Montes <[email protected]>
  • Loading branch information
Julio Montes committed Oct 7, 2019
1 parent 93197dd commit aa43e2a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
9 changes: 5 additions & 4 deletions virtcontainers/fc.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

httptransport "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
kataclient "github.com/kata-containers/agent/protocols/client"
persistapi "github.com/kata-containers/runtime/virtcontainers/persist/api"
"github.com/kata-containers/runtime/virtcontainers/pkg/firecracker/client"
models "github.com/kata-containers/runtime/virtcontainers/pkg/firecracker/client/models"
Expand Down Expand Up @@ -83,6 +84,9 @@ var fcKernelParams = append(commonVirtioblkKernelRootParams, []Param{
// Firecracker doesn't support ACPI
// Fix kernel error "ACPI BIOS Error (bug)"
{"acpi", "off"},

// Tell agent where to send the logs
{"agent.log_vport", fmt.Sprintf("%d", vSockLogsPort)},
}...)

func (s vmmState) String() string {
Expand Down Expand Up @@ -977,11 +981,8 @@ func (fc *firecracker) hotplugRemoveDevice(devInfo interface{}, devType deviceTy

// getSandboxConsole builds the path of the console where we can read
// logs coming from the sandbox.
//
// we can get logs from firecracker itself; WIP on enabling. Who needs
// logs when you're just hacking?
func (fc *firecracker) getSandboxConsole(id string) (string, error) {
return "", nil
return fmt.Sprintf("%s://%s:%d", kataclient.HybridVSockScheme, filepath.Join(fc.jailerRoot, defaultHybridVSocketName), vSockLogsPort), nil
}

func (fc *firecracker) disconnect() {
Expand Down
4 changes: 4 additions & 0 deletions virtcontainers/hypervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ const (
// CAP_NET_BIND_SERVICE capability may bind to these port numbers.
vSockPort = 1024

// Port where the agent will send the logs. Logs are sent through the vsock in cases
// where the hypervisor has no console.sock, i.e firecracker
vSockLogsPort = 1025

// MinHypervisorMemory is the minimum memory required for a VM.
MinHypervisorMemory = 256
)
Expand Down
5 changes: 4 additions & 1 deletion virtcontainers/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import (
"io"
"net"
"path/filepath"
"strings"

kataclient "github.com/kata-containers/agent/protocols/client"
"github.com/kata-containers/runtime/virtcontainers/store"
"github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -241,7 +243,8 @@ func (p *proxyBuiltin) start(params proxyParams) (int, string, error) {

// For firecracker, it hasn't support the console watching and it's consoleURL
// will be set empty.
if params.debug && params.consoleURL != "" {
// TODO: add support for hybrid vsocks, see https://github.com/kata-containers/runtime/issues/2098
if params.debug && params.consoleURL != "" && !strings.HasPrefix(params.consoleURL, kataclient.HybridVSockScheme) {
err := p.watchConsole(buildinProxyConsoleProto, params.consoleURL, params.logger)
if err != nil {
p.sandboxID = ""
Expand Down

0 comments on commit aa43e2a

Please sign in to comment.