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

Commit

Permalink
cli: add guest hook path option
Browse files Browse the repository at this point in the history
Blocked on (kata-containers/agent#365), will need to revendor.
  • Loading branch information
eguzman3 committed Sep 12, 2018
1 parent a5f05bf commit 60e9fe4
Show file tree
Hide file tree
Showing 7 changed files with 610 additions and 156 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ DEFENABLEDEBUG := false
DEFDISABLENESTINGCHECKS := false
DEFMSIZE9P := 8192
DEFHOTPLUGVFIOONROOTBUS := false
DEFGUESTHOOKPATH :=

SED = sed

Expand Down Expand Up @@ -204,6 +205,7 @@ USER_VARS += DEFENABLEDEBUG
USER_VARS += DEFDISABLENESTINGCHECKS
USER_VARS += DEFMSIZE9P
USER_VARS += DEFHOTPLUGVFIOONROOTBUS
USER_VARS += DEFGUESTHOOKPATH

V = @
Q = $(V:1=)
Expand Down Expand Up @@ -299,6 +301,7 @@ const defaultEnableDebug bool = $(DEFENABLEDEBUG)
const defaultDisableNestingChecks bool = $(DEFDISABLENESTINGCHECKS)
const defaultMsize9p uint32 = $(DEFMSIZE9P)
const defaultHotplugVFIOOnRootBus bool = $(DEFHOTPLUGVFIOONROOTBUS)
const defaultGuestHookPath string = "$(DEFGUESTHOOKPATH)"

// Default config file used by stateless systems.
var defaultRuntimeConfiguration = "$(CONFIG_PATH)"
Expand Down Expand Up @@ -386,6 +389,7 @@ $(GENERATED_FILES): %: %.in Makefile VERSION
-e "s|@DEFDISABLENESTINGCHECKS@|$(DEFDISABLENESTINGCHECKS)|g" \
-e "s|@DEFMSIZE9P@|$(DEFMSIZE9P)|g" \
-e "s|@DEFHOTPLUGONROOTBUS@|$(DEFHOTPLUGVFIOONROOTBUS)|g" \
-e "s|@DEFGUESTHOOKPATH@|$(DEFGUESTHOOKPATH)|g" \
$< > $@

generate-config: $(CONFIG)
Expand Down
10 changes: 10 additions & 0 deletions cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ type hypervisor struct {
EnableIOThreads bool `toml:"enable_iothreads"`
UseVSock bool `toml:"use_vsock"`
HotplugVFIOOnRootBus bool `toml:"hotplug_vfio_on_root_bus"`
GuestHookPath string `toml:"guest_hook_path"`
}

type proxy struct {
Expand Down Expand Up @@ -275,6 +276,13 @@ func (h hypervisor) useVSock() bool {
return h.UseVSock
}

func (h hypervisor) guestHookPath() string {
if h.GuestHookPath == "" {
return defaultGuestHookPath
}
return h.GuestHookPath
}

func (p proxy) path() string {
if p.Path == "" {
return defaultProxyPath
Expand Down Expand Up @@ -375,6 +383,7 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
Msize9p: h.msize9p(),
UseVSock: useVSock,
HotplugVFIOOnRootBus: h.HotplugVFIOOnRootBus,
GuestHookPath: h.guestHookPath(),
}, nil
}

Expand Down Expand Up @@ -490,6 +499,7 @@ func loadConfiguration(configPath string, ignoreLogging bool) (resolvedConfigPat
EnableIOThreads: defaultEnableIOThreads,
Msize9p: defaultMsize9p,
HotplugVFIOOnRootBus: defaultHotplugVFIOOnRootBus,
GuestHookPath: defaultGuestHookPath,
}

err = config.InterNetworkModel.SetModel(defaultInterNetworkingModel)
Expand Down
5 changes: 5 additions & 0 deletions cli/config/configuration.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ enable_iothreads = @DEFENABLEIOTHREADS@
# Default false
#hotplug_vfio_on_root_bus = true

# If set to an absolute path within the guest rootfs, the agent
# will search this directory for OCI hooks and add them to the guest
# container's lifecycle.
#guest_hook_path = "@DEFGUESTHOOKPATH@"

[factory]
# VM templating support. Once enabled, new VMs are created from template
# using vm cloning. They will share the same initial kernel, initramfs and
Expand Down
3 changes: 3 additions & 0 deletions cli/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func makeRuntimeConfigFileData(hypervisor, hypervisorPath, kernelPath, imagePath
enable_iothreads = ` + strconv.FormatBool(enableIOThreads) + `
hotplug_vfio_on_root_bus = ` + strconv.FormatBool(hotplugVFIOOnRootBus) + `
msize_9p = ` + strconv.FormatUint(uint64(defaultMsize9p), 10) + `
guest_hook_path = "` + defaultGuestHookPath + `"
[proxy.kata]
path = "` + proxyPath + `"
Expand Down Expand Up @@ -143,6 +144,7 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (config testRuntimeConf
EnableIOThreads: enableIOThreads,
HotplugVFIOOnRootBus: hotplugVFIOOnRootBus,
Msize9p: defaultMsize9p,
GuestHookPath: defaultGuestHookPath,
}

agentConfig := vc.KataAgentConfig{}
Expand Down Expand Up @@ -562,6 +564,7 @@ func TestMinimalRuntimeConfig(t *testing.T) {
Mlock: !defaultEnableSwap,
BlockDeviceDriver: defaultBlockDeviceDriver,
Msize9p: defaultMsize9p,
GuestHookPath: defaultGuestHookPath,
}

expectedAgentConfig := vc.KataAgentConfig{}
Expand Down
Loading

0 comments on commit 60e9fe4

Please sign in to comment.