mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-26 09:44:46 +01:00
cli: add vm factory management subcommand
Add enable_template option to the config file. When it is set, enable the vm template factory. cache factory cannot be used by kata cli directly because it requires a running daemon to maintain the cache VMs. `kata-runtime factory init` would initialize the vm factory and `kata-runtime factory destroy` would destroy the vm factory. When configured, a vm factory is loaded before creating new sandboxes. Signed-off-by: Peng Tao <bergwolf@gmail.com>
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
"strings"
|
||||
|
||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||
vf "github.com/kata-containers/runtime/virtcontainers/factory"
|
||||
"github.com/kata-containers/runtime/virtcontainers/pkg/oci"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
@@ -106,6 +107,25 @@ func create(containerID, bundlePath, console, pidFilePath string, detach bool,
|
||||
return err
|
||||
}
|
||||
|
||||
if runtimeConfig.FactoryConfig.Template {
|
||||
factoryConfig := vf.Config{
|
||||
Template: true,
|
||||
VMConfig: vc.VMConfig{
|
||||
HypervisorType: runtimeConfig.HypervisorType,
|
||||
HypervisorConfig: runtimeConfig.HypervisorConfig,
|
||||
AgentType: runtimeConfig.AgentType,
|
||||
AgentConfig: runtimeConfig.AgentConfig,
|
||||
},
|
||||
}
|
||||
kataLog.WithField("factory", factoryConfig).Info("load vm factory")
|
||||
f, err := vf.NewFactory(factoryConfig, true)
|
||||
if err != nil {
|
||||
kataLog.WithError(err).Info("load vm factory failed")
|
||||
} else {
|
||||
vci.SetFactory(f)
|
||||
}
|
||||
}
|
||||
|
||||
disableOutput := noNeedForOutput(detach, ociSpec.Process.Terminal)
|
||||
|
||||
var process vc.Process
|
||||
|
||||
Reference in New Issue
Block a user