Skip to content

Commit

Permalink
virtcontainers: Jailer: Add jailer support for firecracker
Browse files Browse the repository at this point in the history
Firecracker provides a jailer to constrain the VMM. Use this
jailer to launch the firecracker VMM instead of launching it
directly from the kata-runtime.

The jailer will ensure that the firecracker VMM will run
in its own network and mount namespace. All assets required
by the VMM have to be present within these namespaces.
The assets need to be copied or bind mounted into the chroot
location setup by jailer in order for firecracker to access
these resouces. This includes files, device nodes and all
other assets.

Jailer automatically sets up the jail to have access to
kvm and vhost-vsock.

If a jailer is not available (i.e. not setup in the toml)
for a given hypervisor the runtime will act as the jailer.

Also enhance the hypervisor interface and unit tests to
include the network namespace. This allows the hypervisor
to choose how and where to lauch the VMM process, vs
virtcontainers directly launching the VMM process.

Fixes: kata-containers#1129

Signed-off-by: Manohar Castelino <[email protected]>
  • Loading branch information
mcastelino committed Jun 18, 2019
1 parent 1858c4d commit 9d4c671
Show file tree
Hide file tree
Showing 12 changed files with 283 additions and 43 deletions.
1 change: 1 addition & 0 deletions pkg/katautils/config-settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package katautils

var defaultHypervisorPath = "/usr/bin/qemu-lite-system-x86_64"
var defaultJailerPath = "/usr/bin/jailer"
var defaultImagePath = "/usr/share/kata-containers/kata-containers.img"
var defaultKernelPath = "/usr/share/kata-containers/vmlinuz.container"
var defaultInitrdPath = "/usr/share/kata-containers/kata-containers-initrd.img"
Expand Down
18 changes: 18 additions & 0 deletions pkg/katautils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ type factory struct {

type hypervisor struct {
Path string `toml:"path"`
JailerPath string `toml:"jailer_path"`
Kernel string `toml:"kernel"`
Initrd string `toml:"initrd"`
Image string `toml:"image"`
Expand Down Expand Up @@ -163,6 +164,16 @@ func (h hypervisor) path() (string, error) {
return ResolvePath(p)
}

func (h hypervisor) jailerPath() (string, error) {
p := h.JailerPath

if h.JailerPath == "" {
return "", nil
}

return ResolvePath(p)
}

func (h hypervisor) kernel() (string, error) {
p := h.Kernel

Expand Down Expand Up @@ -451,6 +462,11 @@ func newFirecrackerHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
return vc.HypervisorConfig{}, err
}

jailer, err := h.jailerPath()
if err != nil {
return vc.HypervisorConfig{}, err
}

kernel, err := h.kernel()
if err != nil {
return vc.HypervisorConfig{}, err
Expand Down Expand Up @@ -479,6 +495,7 @@ func newFirecrackerHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {

return vc.HypervisorConfig{
HypervisorPath: hypervisor,
JailerPath: jailer,
KernelPath: kernel,
InitrdPath: initrd,
ImagePath: image,
Expand Down Expand Up @@ -838,6 +855,7 @@ func updateRuntimeConfig(configPath string, tomlConf tomlConfig, config *oci.Run
func GetDefaultHypervisorConfig() vc.HypervisorConfig {
return vc.HypervisorConfig{
HypervisorPath: defaultHypervisorPath,
JailerPath: defaultJailerPath,
KernelPath: defaultKernelPath,
ImagePath: defaultImagePath,
InitrdPath: defaultInitrdPath,
Expand Down
Loading

0 comments on commit 9d4c671

Please sign in to comment.