Skip to content

Commit

Permalink
Set guest memory
Browse files Browse the repository at this point in the history
Previously we didn't set the guest memory but only memory request, since
the guest memory property is optional and according to the documentation
it "Defaults to the requested memory in the resources section if not
specified.". However, if we don't set it and the migrated VM is based on
a template, the value of this field would be retrieved from the template
which may be different than what the VM had on the source and this could
lead to issues, e.g., starting with insufficient memory for booting.

Signed-off-by: Arik Hadas <[email protected]>
  • Loading branch information
ahadas committed Mar 28, 2024
1 parent 4e7b135 commit 995708b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/controller/plan/adapter/openstack/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ func (r *Builder) mapResources(vm *model.Workload, object *cnv.VirtualMachineSpe
memory := resource.NewQuantity(int64(vm.Flavor.RAM)*1024*1024, resource.BinarySI)
resourceRequests := map[core.ResourceName]resource.Quantity{}
resourceRequests[core.ResourceMemory] = *memory
object.Template.Spec.Domain.Memory = &cnv.Memory{Guest: memory}

object.Template.Spec.Domain.Resources.Requests = resourceRequests
}
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/plan/adapter/ova/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ func (r *Builder) mapMemory(vm *model.VM, object *cnv.VirtualMachineSpec) error
core.ResourceMemory: *reservation,
},
}
object.Template.Spec.Domain.Memory = &cnv.Memory{Guest: reservation}
return nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/controller/plan/adapter/ovirt/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ func (r *Builder) mapMemory(vm *model.Workload, object *cnv.VirtualMachineSpec)
core.ResourceMemory: *reservation,
},
}
object.Template.Spec.Domain.Memory = &cnv.Memory{Guest: reservation}
}
func (r *Builder) mapCPU(vm *model.Workload, object *cnv.VirtualMachineSpec) {
object.Template.Spec.Domain.Machine = &cnv.Machine{Type: "q35"}
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/plan/adapter/vsphere/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ func (r *Builder) mapMemory(vm *model.VM, object *cnv.VirtualMachineSpec) {
core.ResourceMemory: *reservation,
},
}
object.Template.Spec.Domain.Memory = &cnv.Memory{Guest: reservation}
}

func (r *Builder) mapCPU(vm *model.VM, object *cnv.VirtualMachineSpec) {
Expand Down

0 comments on commit 995708b

Please sign in to comment.