cli: create vm factory if failed to load existing one

When vm factory is enabled, create vm factory automatically
during creation.

Fixes: #504

Signed-off-by: Peng Tao <bergwolf@gmail.com>
This commit is contained in:
Peng Tao 2018-07-23 08:46:53 +08:00
parent 14d25b82a4
commit 4656a72b92

View File

@ -120,8 +120,13 @@ func create(containerID, bundlePath, console, pidFilePath string, detach bool,
kataLog.WithField("factory", factoryConfig).Info("load vm factory") kataLog.WithField("factory", factoryConfig).Info("load vm factory")
f, err := vf.NewFactory(factoryConfig, true) f, err := vf.NewFactory(factoryConfig, true)
if err != nil { if err != nil {
kataLog.WithError(err).Info("load vm factory failed") kataLog.WithError(err).Warn("load vm factory failed, about to create new one")
} else { f, err = vf.NewFactory(factoryConfig, false)
if err != nil {
kataLog.WithError(err).Warn("create vm factory failed")
}
}
if err != nil {
vci.SetFactory(f) vci.SetFactory(f)
} }
} }