vm.go
func (v *VM) updateVMX(updateFunc func(model *vmx.VirtualMachine) error) error {
	isVMRunning, err := v.IsRunning()
	if err != nil {
		return err
	}

	if isVMRunning {
		return &Error{
			Operation: "vm.updateVMX",
			Code:      100000,
			Text:      "The VM has to be powered off in order to change its vmx settings",
		}
	}

	err = v.vmxfile.Read()
	if err != nil {
		return &Error{
			Operation: "vm.updateVMX",
			Code:      300001,
			Text:      fmt.Sprintf("Error reading vmx file: %s", err),
		}
	}

	err = updateFunc(v.vmxfile.model)
	if err != nil {
		return &Error{
			Operation: "vm.updateVMX",
			Code:      300002,
			Text:      fmt.Sprintf("Error changing vmx value: %s", err),
		}
	}

	err = v.vmxfile.Write()
	if err != nil {
		return &Error{
			Operation: "vm.updateVMX",
			Code:      300003,
			Text:      fmt.Sprintf("Error writing vmx file: %s", err),
		}
	}

	return nil
}
func (v *VM) updateVMX(updateFunc func(model *vmx.VirtualMachine) error) error {
	isVMRunning, err := v.IsRunning()
	if err != nil {
		return err
	}

	if isVMRunning {
		return &Error{
			Operation: "vm.updateVMX",
			Code:      100000,
			Text:      "The VM has to be powered off in order to change its vmx settings",
		}
	}

	err = v.vmxfile.Read()
	if err != nil {
		return &Error{
			Operation: "vm.updateVMX",
			Code:      300001,
			Text:      fmt.Sprintf("Error reading vmx file: %s", err),
		}
	}

	err = updateFunc(v.vmxfile.model)
	if err != nil {
		return &Error{
			Operation: "vm.updateVMX",
			Code:      300002,
			Text:      fmt.Sprintf("Error changing vmx value: %s", err),
		}
	}

	err = v.vmxfile.Write()
	if err != nil {
		return &Error{
			Operation: "vm.updateVMX",
			Code:      300003,
			Text:      fmt.Sprintf("Error writing vmx file: %s", err),
		}
	}

	return nil
}
// updateVMX updates VMX file for the VM.