katautils: check config template and vsock

Vsock conflicts with factory, when both of them are enabled,
kata will try to create a new vm template which is useless,
thus it's better to return an error directly to let users know
that those two config cannot be enabled at the same time.

Fixes: #1055

Signed-off-by: fupan <lifupan@gmail.com>
This commit is contained in:
fupan 2018-12-19 11:46:48 +08:00
parent bcf995bfe1
commit e4e7c3ae54

View File

@ -737,8 +737,14 @@ func checkNetNsConfig(config oci.RuntimeConfig) error {
// checkFactoryConfig ensures the VM factory configuration is valid. // checkFactoryConfig ensures the VM factory configuration is valid.
func checkFactoryConfig(config oci.RuntimeConfig) error { func checkFactoryConfig(config oci.RuntimeConfig) error {
if config.FactoryConfig.Template && config.HypervisorConfig.InitrdPath == "" { if config.FactoryConfig.Template {
return errors.New("Factory option enable_template requires an initrd image") if config.HypervisorConfig.InitrdPath == "" {
return errors.New("Factory option enable_template requires an initrd image")
}
if config.HypervisorConfig.UseVSock {
return errors.New("config vsock conflicts with factory, please disable one of them")
}
} }
return nil return nil