Merge pull request #3226 from liubin/fix/3193-fill-hypervisorconfig

runtime/template: Handling new attributes for hypervisor config
This commit is contained in:
Fabiano Fidêncio
2021-12-09 13:29:23 +01:00
committed by GitHub
2 changed files with 14 additions and 7 deletions

View File

@@ -113,20 +113,23 @@ func resetHypervisorConfig(config *vc.VMConfig) {
config.HypervisorConfig.BootFromTemplate = false
config.HypervisorConfig.MemoryPath = ""
config.HypervisorConfig.DevicesStatePath = ""
config.HypervisorConfig.SharedPath = ""
config.HypervisorConfig.VMStorePath = ""
config.HypervisorConfig.RunStorePath = ""
}
// It's important that baseConfig and newConfig are passed by value!
func checkVMConfig(config1, config2 vc.VMConfig) error {
if config1.HypervisorType != config2.HypervisorType {
return fmt.Errorf("hypervisor type does not match: %s vs. %s", config1.HypervisorType, config2.HypervisorType)
func checkVMConfig(baseConfig, newConfig vc.VMConfig) error {
if baseConfig.HypervisorType != newConfig.HypervisorType {
return fmt.Errorf("hypervisor type does not match: %s vs. %s", baseConfig.HypervisorType, newConfig.HypervisorType)
}
// check hypervisor config details
resetHypervisorConfig(&config1)
resetHypervisorConfig(&config2)
resetHypervisorConfig(&baseConfig)
resetHypervisorConfig(&newConfig)
if !utils.DeepCompare(config1, config2) {
return fmt.Errorf("hypervisor config does not match, base: %+v. new: %+v", config1, config2)
if !utils.DeepCompare(baseConfig, newConfig) {
return fmt.Errorf("hypervisor config does not match, base: %+v. new: %+v", baseConfig, newConfig)
}
return nil

View File

@@ -163,6 +163,10 @@ func (t *template) createFromTemplateVM(ctx context.Context, c vc.VMConfig) (*vc
config.HypervisorConfig.BootFromTemplate = true
config.HypervisorConfig.MemoryPath = t.statePath + "/memory"
config.HypervisorConfig.DevicesStatePath = t.statePath + "/state"
config.HypervisorConfig.SharedPath = c.HypervisorConfig.SharedPath
config.HypervisorConfig.VMStorePath = c.HypervisorConfig.VMStorePath
config.HypervisorConfig.RunStorePath = c.HypervisorConfig.RunStorePath
return vc.NewVM(ctx, config)
}