// SetCPUs sets the number of CPU cores on the VM
SetCPUs sets the number of CPU cores on the VM
// SetCPUs sets the number of CPU cores on the VM
func (v *VirtualMachine) SetCPUs(cpus int, limitCPUFeatures bool) error {
	hostCpus := runtime.NumCPU()
	if hostCpus < cpus {
		return fmt.Errorf("Number of cpus exceeded available host resources")
	}
	procSettingsResults, err := v.activeSettingsData.Get("associators_", nil, ProcessorSettingDataClass)
	if err != nil {
		return errors.Wrap(err, "getting ProcessorSettingDataClass")
	}
	procSettings, err := procSettingsResults.ItemAtIndex(0)
	if err != nil {
		return errors.Wrap(err, "ItemAtIndex")
	}
	if err := procSettings.Set("VirtualQuantity", uint64(cpus)); err != nil {
		return errors.Wrap(err, "VirtualQuantity")
	}
	if err := procSettings.Set("Reservation", cpus); err != nil {
		return errors.Wrap(err, "Reservation")
	}
	if err := procSettings.Set("Limit", 100000); err != nil {
		return errors.Wrap(err, "Limit")
	}
	if err := procSettings.Set("LimitProcessorFeatures", limitCPUFeatures); err != nil {
		return errors.Wrap(err, "LimitProcessorFeatures")
	}
	procText, err := procSettings.GetText(1)
	if err != nil {
		return errors.Wrap(err, "Failed to get VM instance XML")
	}
	return v.modifyResourceSettings([]string{procText})
}
func ( v * VirtualMachine ) SetCPUs ( cpus int , limitCPUFeatures bool ) error { hostCpus := runtime . NumCPU ( ) if hostCpus < cpus { return fmt . Errorf ( " " ) } procSettingsResults , err := v . activeSettingsData . Get ( " " , nil , ProcessorSettingDataClass ) if err != nil { return errors . Wrap ( err , " " ) } procSettings , err := procSettingsResults . ItemAtIndex ( 0 ) if err != nil { return errors . Wrap ( err , " " ) } if err := procSettings . Set ( " " , uint64 ( cpus ) ) ; err != nil { return errors . Wrap ( err , " " ) } if err := procSettings . Set ( " " , cpus ) ; err != nil { return errors . Wrap ( err , " " ) } if err := procSettings . Set ( " " , 100000 ) ; err != nil { return errors . Wrap ( err , " " ) } if err := procSettings . Set ( " " , limitCPUFeatures ) ; err != nil { return errors . Wrap ( err , " " ) } procText , err := procSettings . GetText ( 1 ) if err != nil { return errors . Wrap ( err , " " ) } return v . modifyResourceSettings ( [ ] string { procText } ) }
SetCPUs sets the number of CPU cores on the VM
SetCPUs sets the number of CPU cores on the VM
// Use 100% of CPU core